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

[AU3基础] 请问如何用Hotkeyset 将数字键盘上的方向键设为快捷键?

 火.. [复制链接]
发表于 2011-3-9 18:19:50 | 显示全部楼层 |阅读模式
大家都知道在NumLock灯关闭的时候,数字键盘上的方向键便可以使用,但在AU3的帮助里却找不到如何将其设为快捷键,倒是AHK可以很方便的做到,不知用AU3怎么做,请指点
发表于 2011-3-9 21:44:35 | 显示全部楼层
帮顶,同问????
 楼主| 发表于 2011-3-9 22:25:21 | 显示全部楼层
回复 2# wsfda

谢谢,键盘上快捷键都要让我用光了,只能开发小键盘了,愁
发表于 2011-3-10 00:14:41 | 显示全部楼层
帮顶 ,我曾经也问过这样的问题。
发表于 2011-3-10 00:46:43 | 显示全部楼层
回复 3# xyold1

有效
HotKeySet("{RIGHT}", "On_Exit")

Func On_Exit()
        Exit
EndFunc   ;==>On_Exit

While 1
        Sleep(10)
WEnd

评分

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

查看全部评分

发表于 2011-3-10 02:00:24 | 显示全部楼层
numpad9-numpad9
numpadadd numpadsub...
 楼主| 发表于 2011-3-10 10:01:50 | 显示全部楼层
回复 5# lixiaolong


汗,果真有效,两个方向键都被HotKeySet了,没达我要的效果,纠结啊
发表于 2011-3-10 13:28:19 | 显示全部楼层
本帖最后由 lixiaolong 于 2011-3-10 13:30 编辑

回复 7# xyold1

变通一下,这里是关闭 NUMLOCK,你再打开NUMLOCK试试.
#include <Misc.au3>

AdlibRegister("_HotKeySet", 10)

Send('{NUMLOCK off}'); 关闭 NUMLOCK.

While 1
        Sleep(10)
WEnd

Func _HotKeySet()
        Local $Ctrl = _IsPressed("11")
        Local $Shift = _IsPressed("10")
        Local $Alt = _IsPressed("12")
        Local $NumLeft = _IsPressed("25")
        Local $NumUP = _IsPressed("26")
        Local $NumRIGHT = _IsPressed("27")
        Local $NumDOWN = _IsPressed("28")
        
        If $Ctrl And $Shift And $NumLeft Then
                MsgBox(0, '你同时按了以下键', 'Ctrl+Shift+NumLeft')
        ElseIf $Ctrl And $Alt And $NumUP Then
                MsgBox(0, '你同时按了以下键', 'Ctrl+Alt+NumUP')
        ElseIf _IsPressed("27") Then
                MsgBox(0, 0, 'RIGHT ARROW')
        ElseIf _IsPressed("28") Then
                MsgBox(0, 0, 'DOWN ARROW')
        EndIf
EndFunc   ;==>_HotKeySet

评分

参与人数 1金钱 +25 贡献 +5 收起 理由
xyold1 + 25 + 5 深受启发

查看全部评分

 楼主| 发表于 2011-3-10 14:53:24 | 显示全部楼层
回复 8# lixiaolong

我有一个脚本是要向某程序发送方向键的,我想用数字键盘上的方向键后台控制另一程序,所以上面的方法很巧,但也没有解决我的问题,比如我关numlock按下了小键盘上的2(向下方向键)和我的脚本send("{down}")产生的效果是一样的,貌似在AU3里,down方向键和关了numlock数字键盘上的2是一样的,然而在AHK却能把它们区分开,我想虽然语言不同,但功能的实现上应该相似,别的语言办得到的,Au3也应该没有什么问题吧。
发表于 2011-3-10 17:00:22 | 显示全部楼层
本帖最后由 lixiaolong 于 2011-3-10 17:02 编辑

回复 9# xyold1

down方向键和关了numlock数字键盘上的2是一样的.
判断numlock开关不行吗?难题啊

If numlock 打开时
send("{down}")
处理...

else

send("{down}")
处理...
endif

评分

参与人数 1金钱 +10 贡献 +1 收起 理由
xyold1 + 10 + 1 非常感谢

查看全部评分

 楼主| 发表于 2011-3-10 19:57:17 | 显示全部楼层
你的方法可以区分小键盘上的数字键和方向键,但我还有个脚本要send方向键给另一程序,这时候若是关闭小键盘灯是无法区分这两个方向键的。。。先这样吧
发表于 2011-3-10 21:32:22 | 显示全部楼层
小键盘方向键和方向键的VKCode,SCANCode都是相同的.所以无法区别.也许应该继续检查$tKEYHOOKS结构中的'flag'的返回值吧.
 楼主| 发表于 2011-3-11 00:46:35 | 显示全部楼层
回复 12# 3mile
同意你的观点
下面是AHK源文件里对几个方向键的定义,没学过C,看得一知半解

// These are the same scan codes as their counterpart except the extended flag is 0 rather than
// 1 (0xE0 uncompressed):
#define SC_ENTER 0x1C
// In addition, the below dual-state numpad keys share the same scan code (but different vk's)
// regardless of the state of numlock:
// If use VK for some of these (due to them being more likely to be used as hotkeys, thus minimizing the
// use of the keyboard hook), be sure to use SC for its counterpart.
// Always use the compressed version of scancode, i.e. 0x01 for the high-order byte rather than vs. 0xE0.
#define SC_NUMPADENTER 0x11C
#define SC_INSERT 0x152
#define SC_DELETE 0x153
#define SC_HOME 0x147
#define SC_END 0x14F
#define SC_UP 0x148
#define SC_DOWN 0x150
#define SC_LEFT 0x14B
#define SC_RIGHT 0x14D
#define SC_PGUP 0x149
#define SC_PGDN 0x151

// These are the same scan codes as their counterpart except the extended flag is 0 rather than
// 1 (0xE0 uncompressed):
#define SC_ENTER 0x1C
// In addition, the below dual-state numpad keys share the same scan code (but different vk's)
// regardless of the state of numlock:
#define SC_NUMPADDEL 0x53
#define SC_NUMPADINS 0x52
#define SC_NUMPADEND 0x4F
#define SC_NUMPADHOME 0x47
#define SC_NUMPADCLEAR 0x4C
#define SC_NUMPADUP 0x48
#define SC_NUMPADDOWN 0x50
#define SC_NUMPADLEFT 0x4B
#define SC_NUMPADRIGHT 0x4D
#define SC_NUMPADPGUP 0x49
#define SC_NUMPADPGDN 0x51
发表于 2011-3-11 01:03:05 | 显示全部楼层
autoit可以设置所有的按键的吧.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 10:48 , Processed in 0.082570 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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