AppleScript 中的击键将数字映射到小键盘上的数字,这会导致一些问题
我需要将一些按键发送到另一个程序,并且我在 AppleScript 中尝试了击键
。一切都很顺利,直到我发现当我向 Parallels 虚拟机中运行的 Windows 程序发送数字时,它不起作用,而是改变了光标的位置。
然后我使用程序keyboardSee查找问题所在,发现所有数字和一些符号都映射到数字键盘上的按键,而不是数字行。因此,虚拟机中的 NumLock 可能处于关闭状态,映射到小键盘的按键触发的不是数字而是控制键。
我发现有人说使用key code
可以解决这个问题,但我找不到完美的字符到键码表,而且我还注意到人们说同一字符的键码可能不同在不同的键盘布局中。
那么我怎样才能完美地解决这个问题,意味着我怎样才能让它总是将数字映射到数字行,并在无论什么键盘布局下执行相同的操作?
I need to send some keys to another program, and I tried keystroke
in AppleScript. Everything worked well until I found that when I sent numbers to a Windows program running in Parallels virtual machine, it didn't work, but instead, it change the position of cursor.
Then I use program keyboardSee to find what's wrong, and I found that all numbers and some symbols are mapped to the keys on numeric keypad, not the numeric line. So maybe the NumLock is off in the virtual machine, and the keys mapped to keypad trigger not numeric but control keys.
I found some people says that use key code
can solve this problem, but I cannot find a perfect char-to-keycode table, and I also notice that people said key code could be different for the same character in different keyboard layout.
So how can I solve this problem perfectly, means how can I make it always map numbers to numeric line, and perform the same in no matter what keyboard layout?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不敢说,我认为目前这是不可能的。一般来说,Mac 应用程序知道 Mac 的数字键盘上甚至没有与 PC 相同的字符(没有箭头、没有数字锁定等),因此这种区别毫无意义。不过,一些移植不佳的 Mac 应用程序确实有所区别,例如《魔兽世界》(尽管无论如何它都不是最差的移植版)。我相信parallels在其菜单中的某个地方有一个数字锁(如果我没记错的话),所以你应该能够通过这种方式绕过它。
I'm afraid to say that I don't think this is possible at the moment. In general, Mac apps know that macs don't even have the same characters on their Numberpads that PCs do (no arrows, no num lock, etc), so the distinction is meaningless. Some poorly ported Mac apps do make a distinction though, such as World of Warcraft (although it isn't the worst port out there by any means). I believe parallels has a num lock in its menus somewhere (if I recall correctly), so you should be able to get around it that way.