找回密码
 加入
搜索
查看: 1373|回复: 3

关于快捷键问题!!

[复制链接]
发表于 2008-12-14 10:07:51 | 显示全部楼层 |阅读模式
在GUI中,用Hotkeyset设定的快捷键.能否让他只在窗口激活的情况下有效,在窗口未激活时无效?

[ 本帖最后由 amgloon 于 2008-12-14 15:29 编辑 ]
发表于 2008-12-14 12:28:56 | 显示全部楼层
这个是白文大哥的解决方案
使用HotKey停止 又怕影响其它的软件运行
可以使用判定窗口状态来解决
举例:

The au3 Code:
关于插件打印代码保存代码复制代码普通浏览HotKeySet ( "{Enter}" ,"GuiExit" )
$Form = GuiCreate("",200,200)
GuiSetState()
while 1
    sleep(50)
wend
Func GuiExit()
    if bitand(WinGetState ( $Form),8 ) then
        exit
    else
        HotKeySet("{Enter}")
        Send("{Enter}")
        HotKeySet("{Enter}", "GuiExit")
    endif
EndFunc

评分

参与人数 1金钱 +5 收起 理由
amgloon + 5 谢谢

查看全部评分

发表于 2008-12-14 13:12:29 | 显示全部楼层

这样也行,借花献佛了。

#include <GuiConstants.au3>
HotKeySet("{ENTER}", "catchguikey")
$gui = GuiCreate("Hotkey Test")
GuiCtrlCreateLabel("Press Enter", 0, 0)
GuiSetState()

While 1    
        $msg = GUIGetMsg()    
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Func catchguikey()    
        Local $opt = Opt("WinTitleMatchMode", 4)    
        If WinGetHandle("active") = $gui Then        
                If @HotKeyPressed = "{ENTER}" Then                        
                        ;Do something here
                        ToolTip("Key Pressed")            
                        Sleep(1000)            
                        ToolTip("")        
                EndIf    
        Else        
                HotKeySet(@HotKeyPressed)        
                Send(@HotKeyPressed)        
                HotKeySet(@HotKeyPressed, "catchguikey")    
        EndIf    
        Opt("WinTitleMatchMode", $opt)
EndFunc

评分

参与人数 1金钱 +5 收起 理由
amgloon + 5 谢谢

查看全部评分

 楼主| 发表于 2008-12-14 15:28:41 | 显示全部楼层
..谢了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 03:58 , Processed in 0.089144 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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