找回密码
 加入
搜索
查看: 3092|回复: 6

[AU3基础] 请教_ispressed函数监测功能键{F12}被按下的方法

  [复制链接]
发表于 2011-4-21 12:32:03 | 显示全部楼层 |阅读模式
网上看到_ispressed函数的第一个参数都是按键的ASCII码,但是没有找到F12的使用方法,试过"{F12}"也不行。请大家指点,谢谢!
发表于 2011-4-22 19:56:17 | 显示全部楼层
_IsPressed函数的原理其实就是调用User32.dll的GetAsyncKeyState函数。
Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
        ; $hexKey must be the value of one of the keys.
        ; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is.
        Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey)
        If @error Then Return SetError(@error, @extended, False)
        Return BitAND($a_R[0], 0x8000) <> 0
EndFunc   ;==>_IsPressed
详细按键的代码表可以到这里查看Virtual-Key Codes
使用方法比如:
F12的十六进制代码是0x7B
那么_IsPressed的按键码就是7B
发表于 2011-4-22 22:06:31 | 显示全部楼层
网上看到_ispressed函数的第一个参数都是按键的ASCII码,但是没有找到F12的使用方法,试过"{F12}"也不行。请 ...
泡泡小顽童 发表于 2011-4-21 12:32


include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("7B", $dll) Then
        MsgBox(0,"_IsPressed", "F12 Key Pressed")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

当然若是用SCite来做au3的Editor,其本身会截掉F12消息。
发表于 2011-4-23 13:27:58 | 显示全部楼层
本帖最后由 pusofalse 于 2011-4-23 13:35 编辑

这又不是消息传递,就算scite截断{f12}按键消息,那又会怎样呢?难道_IsPressed函数会因此失效了吗?~
发表于 2011-4-23 13:33:51 | 显示全部楼层
回复 4# pusofalse

难道是传说中的错别字?^_^

评分

参与人数 1金钱 +5 收起 理由
pusofalse + 5 被你发现了~

查看全部评分

 楼主| 发表于 2011-4-28 21:13:21 | 显示全部楼层
谢谢,学习了。好几天没上了。
发表于 2011-4-28 23:18:12 | 显示全部楼层
这又不是消息传递,就算scite截断{f12}按键消息,那又会怎样呢?难道_IsPressed函数会因此失效了吗?~
pusofalse 发表于 2011-4-23 13:27


你理解错了,不是_IsPressed函数没有效了,而是在SCite直接试的话,因被截了,会有时没有想要的效果,而变成SCite没有语法高亮的效果,只是提示楼主一下呀
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 08:40 , Processed in 0.070968 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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