找回密码
 加入
搜索
查看: 2203|回复: 5

[已解决]同目录调用程序正常,上级目录调用却出错(程序内调用图片问题)

[复制链接]
发表于 2009-10-19 13:32:32 | 显示全部楼层 |阅读模式
本帖最后由 jycel 于 2009-10-21 17:08 编辑

解决方法:
非同目录必须加上工作目录
如:ShellExecute ( "文件名" [, "参数" [, "工作目录" [, "verb" [, 显示标志]]]] )

真奇怪此问题!
我是做的一个图片浏览器
在当前目录调用这个程序或直接运行可以显示,从上级其它目录调用就不行
GUICtrlSetImage函数有问题么?用GUICtrlCreatePic重建也一样!
如图:


本目录调用

Run(@ScriptDir&"\Browser.exe")


上级目录调用

Run(@ScriptDir&"\Historical Pictures\Browser.exe")

Browser源码

#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=Browser.ico
#AutoIt3Wrapper_outfile=Browser.exe
#AutoIt3Wrapper_Res_Comment=图片查看器
#AutoIt3Wrapper_Res_Description=图片查看器
#AutoIt3Wrapper_Res_LegalCopyright=BY-Jycel
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Local $_INI_File = @ScriptDir & "\Image.ini";读取配置文件
if not FileExists($_INI_File) then 
msgbox(16,"错误提示","未找到Image.ini配置文件"&@CRLF&"请手动建立"&@CRLF&"字段名为[历史]",5)
Exit
EndIf
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Form1.kxf
$Form1 = GUICreate("图片查看器", 587, 373, 216, 186)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event")
$Group1 = GUICtrlCreateGroup("", 2, 0, 468, 369)
$Pic1 = GUICtrlCreatePic("", 8, 8, 457, 353)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 472, 0, 113, 369)
$TreeView1 = GUICtrlCreateTreeView(480, 14, 97, 321)
GUICtrlSetOnEvent(-1, "Event")
$Button1 = GUICtrlCreateButton("退出查看器", 480, 344, 97, 20, -1, $WS_EX_STATICEDGE)
GUICtrlSetOnEvent(-1, "Event")
$item=GUICtrlCreateTreeViewItem("历史图片", $TreeView1)
$IniSection = IniReadSection($_INI_File, "历史");读取配置文件主值
if not @error Then
        For $i = 1 To $IniSection[0][0]
                $datez=GUICtrlCreateTreeViewItem($IniSection[$i][0],$item)
                GUICtrlSetOnEvent(-1, "Event")
        Next
EndIf

GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
Sleep(100)
WEnd
Func Event()
   Switch @GUI_CtrlId
      Case $GUI_EVENT_CLOSE
         Exit
          case $Button1
                        Exit
      Case Else
         $Val = GUICtrlRead(@GUI_CtrlId,1)
         $Val = StringReplace ( $Val, "|","")
                 GUICtrlSetImage($Pic1,IniRead($_INI_File,"历史",$Val,""),-1,1)
   EndSwitch
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-10-19 15:39:03 | 显示全部楼层
没人知道?
发表于 2009-10-20 08:39:49 | 显示全部楼层
Historical Pictures
             ↑

去掉试试呢
 楼主| 发表于 2009-10-20 10:07:06 | 显示全部楼层
本帖最后由 jycel 于 2009-10-20 12:36 编辑


Run(@ScriptDir&"\Historical Pictures\Browser.exe")

Historical Pictures这去掉了,程序怎么认它目录下的呢?当前有几个文件夹,如果说中间有空格造成的,我试了换成任何一个单词的都一样!
程序调用是可以运行,主要问题是在调用的程序内,显示图片不对,本目录和手动调用可以,其它目录就不行!如果不明白试下就明白了!
发表于 2009-10-21 15:42:18 | 显示全部楼层
Run(@ScriptDir&"\Historical Pictures\Browser.exe",@ScriptDir&"\Historical Pictures")
设置一下工作目录参数!
 楼主| 发表于 2009-10-21 17:06:01 | 显示全部楼层
Run(@ScriptDir&"\Historical Pictures\Browser.exe",@ScriptDir&"\Historical Pictures")
设置一下工作目录参数!
maxkingmax 发表于 2009-10-21 15:42

正解!我在使用ShellExecute时参数加了,没有加工作目录!为可选,我就没用!
问题终于解决!感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 19:47 , Processed in 0.074039 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表