找回密码
 加入
搜索
查看: 1426|回复: 13

奇怪的无效点击,求教!

[复制链接]
发表于 2009-5-13 15:52:02 | 显示全部楼层 |阅读模式
本帖最后由 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 

本帖子中包含更多资源

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

×
 楼主| 发表于 2009-5-13 15:54:03 | 显示全部楼层
一直不得其解
恳请赐教
发表于 2009-5-13 17:43:52 | 显示全部楼层
If $msg = -3 Then Exit

你在一个循环里读了2次事件
发表于 2009-5-13 17:55:38 | 显示全部楼层
另外还发现一个问题。StringSplit分离产生的数组,元素0是合计,1才是c:\,所以$count的起始位应该是1。
因此造成返回到c:后($count=1),如果多点几次“返回”($count=0),之后要点2次下一步才出来d:($count=2)。
发表于 2009-5-13 18:06:49 | 显示全部楼层
改了一点点循环部分
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

评分

参与人数 2金钱 +16 贡献 +5 收起 理由
lxz + 1
lynfr8 + 15 + 5 谢谢赐教!感激!

查看全部评分

 楼主| 发表于 2009-5-13 19:04:03 | 显示全部楼层
看来还要继续学习,谢谢楼上的解疑!
 楼主| 发表于 2009-5-13 19:04:12 | 显示全部楼层

好喜欢这句话!

本帖最后由 lynfr8 于 2009-5-13 19:06 编辑

授人鱼,不如授人与渔
发表于 2009-5-13 19:12:53 | 显示全部楼层
谢谢LS两位,能否再加上一个正在查看的盘符显示.
发表于 2009-5-13 23:24:26 | 显示全部楼层
6# lynfr8


lynfr8兄客气了,在这里就是互相学习。
发表于 2009-5-13 23:26:22 | 显示全部楼层
8# lxz


在界面上创建一个Label控件,Button事件后GUICtrlSetData数组$array[$count]值到此控件。
 楼主| 发表于 2009-5-13 23:28:41 | 显示全部楼层
本帖最后由 lynfr8 于 2009-5-13 23:49 编辑
谢谢LS两位,能否再加上一个正在查看的盘符显示.
lxz 发表于 2009-5-13 19:12


可以做到显示盘符(注意仅仅是显示盘符根目录而已,再深的路径我不知道怎么写,应该需要获取鼠标点击触发的事件来写,可能本人能力有限,其他人懂的来补充下)
修改下加了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

本帖子中包含更多资源

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

×
发表于 2009-5-13 23:29:26 | 显示全部楼层
搞定......

本帖子中包含更多资源

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

×
 楼主| 发表于 2009-5-13 23:32:48 | 显示全部楼层
把解决方法发出来大家分享下
别只是搞个图片上来
要是别人想学习下呢
真是的
 楼主| 发表于 2009-5-13 23:35:15 | 显示全部楼层
sensel 兄所言极是!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-8 06:06 , Processed in 0.092786 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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