找回密码
 加入
搜索
查看: 2349|回复: 8

[AU3基础] 关于控件数据读取的问题,请高手指点。

  [复制链接]
发表于 2011-11-2 15:24:15 | 显示全部楼层 |阅读模式
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 364, 146, -1, -1)
$Button1 = GUICtrlCreateButton("选择", 312, 48, 27, 21)
$Input1 = GUICtrlCreateInput("Input1", 32, 48, 265, 21)
$Button2 = GUICtrlCreateButton("确定", 112, 96, 131, 21)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                     $Browser = FileOpenDialog ( "选择" , @ProgramFilesDir & "\" , "可执行程序(*.exe)" , 1 + 2 )
                     GUICtrlSetData ( $Input1, $Browser )
                Case $Button2
                     MsgBox ( 0, "提示", GUICtrlRead ( $Input1 ) )
                     IniWrite ( "11.ini", "1", "2", GUICtrlRead ( $Input1 ) )
        EndSwitch
WEnd


直接输入的值可以写入配置文件,但选择的值就不能写入了,请各位指点,谢谢!
发表于 2011-11-2 15:34:01 | 显示全部楼层
GUICtrlRead ( $Input1 )
当执行$Button1的时候才会改写$Input1
这个和$Button2没有必然的联系!
理顺思路想想就明白了!
 楼主| 发表于 2011-11-2 15:45:39 | 显示全部楼层
Case $Button1
                     $Browser = FileOpenDialog ( "选择" , @ProgramFilesDir & "\" , "可执行程序(*.exe)" , 1 + 2 )
                     GUICtrlSetData ( $Input1, $Browser )
                Case $Button2
                     MsgBox ( 0, "提示", GUICtrlRead ( $Input1 ) )
                     IniWrite ( "11.ini", "1", "2", GUICtrlRead ( $Input1 ) )

$Button2  去掉,还是不能写入,不知道是什么原因,请指点。
 楼主| 发表于 2011-11-2 15:46:49 | 显示全部楼层
Case $Button1
                     $Browser = FileOpenDialog ( "选择" , @ProgramFilesDir & "\" , "可执行程序(*.exe)" , 1 + 2 )
                     GUICtrlSetData ( $Input1, $Browser )
                     MsgBox ( 0, "提示", GUICtrlRead ( $Input1 ) )
                     IniWrite ( "11.ini", "1", "2", GUICtrlRead ( $Input1 ) )
发表于 2011-11-2 22:12:50 | 显示全部楼层
IniWrite (@ScriptDir & "\11.ini", "1", "2", GUICtrlRead ( $Input1 ) )

这样试试看

评分

参与人数 1金钱 +10 收起 理由
nuoyan + 10

查看全部评分

发表于 2011-11-2 22:24:14 | 显示全部楼层
这个貌似iniwrite()的问题,我试用run(GUICtrlRead($input1))代替IniWrite ( "11.ini", "1", "2", GUICtrlRead ( $Input1 ) ),是可以正常运行选择的程序的。
所以我也很迷惑,希望楼下有人能够解惑。
发表于 2011-11-2 22:41:17 | 显示全部楼层
5楼正解,我也找到问题原因了,因为ini文件路径没有定义,所以通过选择按钮产生的路径会成为ini文件的路径。故问题不是GUICtrlRead读取的问题,而是路径改变了的问题。

评分

参与人数 1金钱 +10 收起 理由
nuoyan + 10

查看全部评分

 楼主| 发表于 2011-11-3 18:30:49 | 显示全部楼层
谢谢大家!!  问题解决。。
发表于 2011-11-4 08:26:58 | 显示全部楼层
解决了就把标题改为已解决嘛,我还看了半天呢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 14:53 , Processed in 0.093764 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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