奇怪的无效点击,求教!
本帖最后由 lynfr8 于 2009-5-13 19:04 编辑有个au3友让我帮他解决一个问题
他提出问题最后倒是解决了
而奇怪的解决后的代码是时而出现了button点击无法反应
代码看似应该无问题
代码发上来
请教原因和解决方法
如下:
未解决前的代码(无法通过点击下一页实现盘符次序显示)$title="测试"
$oIE = ObjCreate("Shell_Explorer.2")
$Form1 = GUICreate($title, 788, 455, 365, 235)
$Button1 = GUICtrlCreateButton("下一页", 8, 8, 64, 64)
$Back = GUICtrlCreateButton("返回", 100, 8, 64, 64)
$GUIActiveX = GUICtrlCreateObj($oIE, 1, 88, 786, 360)
GUISetState()
$oIE.navigate("c:\")
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
While 1
$msg = GUIGetMsg()
If GUIGetMsg() = -3 Then Exit
Select
Case $msg = $Back
$oIE.GoBack
Case $msg = $Button1
$oIE.navigate("d:\")
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
EndSelect
WEnd 我修改后的代码(解决了上面问题,但是按钮奇怪的不定时出现无法点击)
$title="测试"
$oIE = ObjCreate("Shell_Explorer.2")
$Form1 = GUICreate($title, 788, 455, 365, 235)
$Button1 = GUICtrlCreateButton("下一页", 8, 8, 64, 64)
$Back = GUICtrlCreateButton("返回", 100, 8, 64, 64)
$GUIActiveX = GUICtrlCreateObj($oIE, 1, 88, 786, 360)
GUISetState()
$oIE.navigate("c:\")
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
$line="c:\ d:\ e:\ f:\ g:\"
$array = StringSplit($line, " ", 1)
dim $count = 0;
While 1
$msg = GUIGetMsg()
If GUIGetMsg() = -3 Then Exit
Select
Case $msg = $Back
$count = $count - 1
if $count < 0 Then
$count = 0;
EndIf
;MsgBox(4096,'Count', $count)
$oIE.navigate($array[$count])
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
Case $msg = $Button1
$count = $count + 1
if $count > (UBound($array) - 1) Then
$count = (UBound($array) - 1)
EndIf
;MsgBox(4096,'Count', $count)
$oIE.navigate($array[$count])
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
;$count=$count+1
EndSelect
WEnd
一直不得其解
恳请赐教 If $msg = -3 Then Exit
你在一个循环里读了2次事件 另外还发现一个问题。StringSplit分离产生的数组,元素0是合计,1才是c:\,所以$count的起始位应该是1。
因此造成返回到c:后($count=1),如果多点几次“返回”($count=0),之后要点2次下一步才出来d:($count=2)。 改了一点点循环部分Dim $count = 1
While 1
$msg = GUIGetMsg()
If $msg = -3 Then Exit
Select
Case $msg = $Back
If $count > 1 Then $count -= 1
;MsgBox(4096,'Count', $count)
$oIE.navigate($array[$count])
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
Case $msg = $Button1
If $count < UBound($array) - 1 Then $count += 1
;MsgBox(4096,'Count', $count)
$oIE.navigate($array[$count])
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
;$count=$count+1
EndSelect
WEnd 看来还要继续学习,谢谢楼上的解疑!
好喜欢这句话!
本帖最后由 lynfr8 于 2009-5-13 19:06 编辑授人鱼,不如授人与渔 谢谢LS两位,能否再加上一个正在查看的盘符显示. 6# lynfr8
lynfr8兄客气了,在这里就是互相学习。 8# lxz
在界面上创建一个Label控件,Button事件后GUICtrlSetData数组$array[$count]值到此控件。 本帖最后由 lynfr8 于 2009-5-13 23:49 编辑
谢谢LS两位,能否再加上一个正在查看的盘符显示.
lxz 发表于 2009-5-13 19:12 http://www.autoitx.com/images/common/back.gif
可以做到显示盘符(注意仅仅是显示盘符根目录而已,再深的路径我不知道怎么写,应该需要获取鼠标点击触发的事件来写,可能本人能力有限,其他人懂的来补充下)
修改下加了GUICtrlCreateInput,然后获取文本$array[$count]显示出来
$title="测试"
$oIE = ObjCreate("Shell_Explorer.2")
$Form1 = GUICreate($title, 788, 455, 365, 235)
$Button1 = GUICtrlCreateButton("下一页", 500, 8, 64, 64)
$Back = GUICtrlCreateButton("返回", 400, 8, 64, 64)
$GUIActiveX = GUICtrlCreateObj($oIE, 1, 88, 786, 360)
GUICtrlCreateInput("c:\", 10, 35, 300, 20)
GUISetState()
$oIE.navigate("c:\")
ControlListView($title, "", "SysListView321", "ViewChange", "smallicons")
$line="c:\ d:\ e:\ f:\ g:\"
$array = StringSplit($line, " ", 1)
Dim $count = 1
While 1
$msg = GUIGetMsg()
If $msg = -3 Then Exit
Select
Case $msg = $Back
If $count > 1 Then $count -= 1
;MsgBox(4096,'Count', $count)
$oIE.navigate($array[$count])
GUICtrlCreateInput($array[$count], 10, 35, 300, 20)
ControlListView($title, "", "SysListView321", "ViewChange",
"smallicons")
Case $msg = $Button1
If $count < UBound($array) - 1 Then $count += 1
;MsgBox(4096,'Count', $count)
$oIE.navigate($array[$count])
ControlListView($title, "", "SysListView321", "ViewChange",
"smallicons")
GUICtrlCreateInput($array[$count], 10, 35, 300, 20)
EndSelect
WEnd 搞定...... 把解决方法发出来大家分享下
别只是搞个图片上来
要是别人想学习下呢
真是的:face (17): sensel 兄所言极是!!
页:
[1]