发送键向下/向上事件使用AppleScript数字键 [英] Send key down / up events for number keys using AppleScript

查看:442
本文介绍了发送键向下/向上事件使用AppleScript数字键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要发送的键,/键事件作为数字键来使用AppleScript的应用程序。但是,这些命令:

 键,6
延迟1
键上6

发送键击,就好像它们是从数字键盘来。我需要他们PTED从数量来排在键盘的顶部间$ P $。

我也尝试过使用(ASCII字符54)而不是文字,都没有成功。

注意我需要键,发送 - 发送一个击键键code 不会做。


解决方案
而不是

尝试发送键,中的虚拟键code 的一个按键的文字,即

 键不放(键code< INT>)

其中, INT 是一个

  1→18
2→19
3→20
4→21
5→23
6→22
7→26
8→28
9→25
0→29

您会发现所有的虚拟键codeS宣布

<$p$p><$c$c>/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h

但如果你不喜欢做的十六进制整数转换,看看他们最简单的方法可能是使用的重点codeS 通过花样繁多,通过的 ://stackoverflow.com/users/1075643/dj-bazzie-wazzie> DJ bazzie wazzie

I need to send a key down / key up event for number keys to an application using AppleScript. However, the commands:

key down "6"
delay 1
key up "6"

send the keystrokes as if they were coming from the number pad. I need them to be interpreted as coming from the number row at the top of the keyboard.

I’ve also tried using (ASCII character 54) instead of a literal, without success.

Note I need key down to be sent – sending a keystroke or key code will not do.

解决方案

Try sending key down the virtual key code instead of a keystroke literal, i.e.

key down (key code <int>)

where int is one of

1 → 18
2 → 19
3 → 20
4 → 21
5 → 23
6 → 22
7 → 26
8 → 28
9 → 25
0 → 29

You will find all virtual key codes declared in

/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h

but if you don’t feel like doing hex to integer conversion, the easiest way to look them up is probably to use Key Codes by Many Tricks, as suggested by dj bazzie wazzie.

这篇关于发送键向下/向上事件使用AppleScript数字键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆