Macros 自动热键-我想将A设置为Shift A

Macros 自动热键-我想将A设置为Shift A,macros,key,autohotkey,remap,Macros,Key,Autohotkey,Remap,有人能告诉我如何用自动热键编辑脚本吗 我使用宏录制器执行多次重复任务,即“上移n下移”,因此我使用宏快捷键反复按下。问题是,在我使用的宏录制器中,如果您指定了一个带有修改器的快捷方式来调用宏(即Shift a),那么每次要执行宏时,您都必须释放修改器,因此我通常必须(按Shift、按a、释放Shift和释放a),每次我要调用宏时,而不是只按Shift,按住它,然后多次按下并释放。哪一个更容易。 我正在寻找一个可以解决这个问题的自动热键脚本,我有很多这样的宏,所以我不能为每个宏创建一个bat或ex

有人能告诉我如何用自动热键编辑脚本吗

我使用宏录制器执行多次重复任务,即“上移n下移”,因此我使用宏快捷键反复按下。问题是,在我使用的宏录制器中,如果您指定了一个带有修改器的快捷方式来调用宏(即Shift a),那么每次要执行宏时,您都必须释放修改器,因此我通常必须(按Shift、按a、释放Shift和释放a),每次我要调用宏时,而不是只按Shift,按住它,然后多次按下并释放。哪一个更容易。 我正在寻找一个可以解决这个问题的自动热键脚本,我有很多这样的宏,所以我不能为每个宏创建一个bat或exe文件,我基本上需要一个自动热键 脚本如下:

if keystate, SHIFT, P
a::
send (Shift down)
send (a down)
send (Shift up)
send (a up)
或者任何其他脚本,可以在每次按A时发送Shift和A键,但仅在按下Shift键时

我一直在尝试循环,但我只是不知道如何让它停止

考虑到我不必在每次调用宏时都必须释放并再次按下“Shift+a”,也可以是“Alt+a”,也可以是“Alt+Win+a”,每个不同的组合调用不同的宏。因此,将“a”键设置为始终为“Shift+a”是个坏主意,因为我需要“a”键来执行不同的宏,根据同时按下的其他修改器键执行不同的宏

我在这个应用程序中使用的热键列表是(每个人都做一些不同的事情,它不能被任何其他热键替换)

大多数字母(S、D、Q、W、E等)和数字1、2、3等都是如此 此外:

(释放Shift和Tab键,然后再次按下这两个键,这真的很烦人,每次我想运行宏时,我都会重复多次运行此宏) 我认为这些都是热键,它们都做不同的事情,我每次都会重复运行

请,我确实需要一个脚本,将启动不同的行动按下同一个“a”键,根据其他修改键是在同一时间按下

嗨,罗伯特,我不太明白你说的话,但我把剧本编辑成这样

#MaxThreadsPerHotkey 2

#SingleInstance Force
#installKeybdHook
#Persistent
AppName=MyKeys
Menu, Tray, Tip, %AppName%
Menu, Tray, Icon , Shell32.dll, 45, 1 ; 45, 28, 113, 74, 134
TrayTip, %AppName%, Started, 1 


*a::
GoSub, MyGetKeyStateSub
If (MyGetKeyStateValue=0)
{
    SendInput, a
}
Else
{
    if( MyGetKeyStateValue & 1 > 0) ; Compare first bit
        send {LAlt down}
        send {d down}
        send {LAlt up}
        send {d up}
    if( MyGetKeyStateValue & 10 > 0) ; compare second bit
        MsgBox, RShift
    if( MyGetKeyStateValue & 100 > 0) ; compare third bit
        send {LAlt down}
            send {d down}
        send {LAlt up}
        send {d up}
    if( MyGetKeyStateValue & 1000 > 0)
        MsgBox, RShift
    if( MyGetKeyStateValue & 10000 > 0)
        MsgBox, LAlt
    if( MyGetKeyStateValue & 100000 > 0)
        MsgBox, RAlt
    if( MyGetKeyStateValue & 1000000 > 0)
        MsgBox, LWin
    if( MyGetKeyStateValue & 10000000 > 0)
        MsgBox, RWin
    if ( MyGetKeyStateValue & 00000011 > 0) ; If LCtrl AND LShift pressed
        MsgBox, LCtrl AND LShift
}
Return


MyGetKeyStateSub:
MyGetKeyStateValue:=0
if getkeystate("LCtrl", P)
    MyGetKeyStateValue+=1 ; set least significant bit
if getkeystate("RCtrl", P)
    MyGetKeyStateValue+=2 ; set 2nd least significant bit, etc, etc.
if getkeystate("LShift", P)
    MyGetKeyStateValue+=4
if getkeystate("RShift", P)
    MyGetKeyStateValue+=8
if getkeystate("Lalt", P)
    MyGetKeyStateValue+=16
if getkeystate("Ralt", P)
    MyGetKeyStateValue+=32
if getkeystate("LWin", P)
    MyGetKeyStateValue+=64
if getkeystate("RWin", P)
    MyGetKeyStateValue+=128
Return



*d::
GoSub, MyGetKeyStateSub
If (MyGetKeyStateValue=0)
{
    SendInput, d
}
Else
{
    if( MyGetKeyStateValue = 1) ; LAlt
    {
        SendInput, {LAlt Down}d{LAlt Up}
        Return
    }
    if( MyGetKeyStateValue = 4) ; LWin
    {
        SendInput, {LAlt Down}{LWin Down}d{LAlt Up}{LWin Up}
        Return
    }
}
Return
打开程序,但还是没用, 第一次按Alt D时,我得到宏,第二次按住Alt键按D时,我得到一个普通的D

我在想你说的关于XY问题的话,也许我应该把我所有的宏从HK4(热键盘Pro 4)重建成自动热键。我在HK4 GUI的帮助下创建了很多宏,但是宏本身存储在一个xml脚本文件中,我曾经用文本编辑器打开过这个文件,它非常庞大!,在AHK中编写所有这些宏需要多少时间

我已经设置了25个变量,应用于每个宏(比如200个宏),主要是鼠标移动、鼠标单击、从应用程序内的浮动窗口复制选定文本(数值),对它们应用算术运算,并将结果再次粘贴到相同的框中(HK4有播放键的和选项,因为否则它不能在应用程序内粘贴),根据哪个软件、哪个浮动窗口名称、哪个变量被启用或禁用(反转条件)运行,也有切换宏(用一个热键在两个宏之间切换),我的意思是,我需要花多少时间才能学会如何在AHK中编写所有这些宏?,,我在互联网上查看过,但很难理解每个发布的案例,它们并不完全适用于我打算做的事情,谢谢罗伯特,你有什么建议吗?我的意思是,我会在AHK中重建所有宏,因为在AHK中我不必发布修改器键可以同时执行一个宏很多次,那么Autoit呢?它更容易学习吗?我读到它有macrorecorder?谢谢。

这个怎么样

:*:a::+a
如果您想让这一点变得有趣,可以将其封装在一个#IfWinActive语句中,以便仅在特定应用程序处于活动状态时获取移位a,否则所有a将始终成为移位a

这个怎么样:

:*:a::
    Send, {Shift Down}a{Shift Up} ; or use the more modern SendInput
Return
这里有一个小例子,你可以这样做。不确定这是否符合你的要求。在这个例子中,我只为字母a创建了这个,但你可以通过对其他字母重复这个来扩展它

#SingleInstance Force
#installKeybdHook
#Persistent
AppName=MyKeys
Menu, Tray, Tip, %AppName%
Menu, Tray, Icon , Shell32.dll, 45, 1 ; 45, 28, 113, 74, 134
TrayTip, %AppName%, Started, 1 


*a::
GoSub, MyGetKeyStateSub
If (MyGetKeyStateValue=0)
{
    SendInput, a
}
Else
{
    if( MyGetKeyStateValue & 1 > 0) ; Compare first bit
        MsgBox, LCtrl
    if( MyGetKeyStateValue & 10 > 0) ; compare second bit
        MsgBox, RCtrl
    if( MyGetKeyStateValue & 100 > 0) ; compare third bit
        MsgBox, LShift
    if( MyGetKeyStateValue & 1000 > 0)
        MsgBox, RShift
    if( MyGetKeyStateValue & 10000 > 0)
        MsgBox, LAlt
    if( MyGetKeyStateValue & 100000 > 0)
        MsgBox, RAlt
    if( MyGetKeyStateValue & 1000000 > 0)
        MsgBox, LWin
    if( MyGetKeyStateValue & 10000000 > 0)
        MsgBox, RWin
    if ( MyGetKeyStateValue & 00000011 > 0) ; If LCtrl AND LShift pressed
        MsgBox, LCtrl AND LShift
}
Return


MyGetKeyStateSub:
MyGetKeyStateValue:=0
if getkeystate("LCtrl", P)
    MyGetKeyStateValue+=1 ; set least significant bit
if getkeystate("RCtrl", P)
    MyGetKeyStateValue+=2 ; set 2nd least significant bit, etc, etc.
if getkeystate("LShift", P)
    MyGetKeyStateValue+=4
if getkeystate("RShift", P)
    MyGetKeyStateValue+=8
if getkeystate("Lalt", P)
    MyGetKeyStateValue+=16
if getkeystate("Ralt", P)
    MyGetKeyStateValue+=32
if getkeystate("LWin", P)
    MyGetKeyStateValue+=64
if getkeystate("RWin", P)
    MyGetKeyStateValue+=128
Return
Eduard,在我的情况下,这是一个很好的例子,可能是你的应用程序正在查看被按下的物理键。在这种情况下,我会去看一看你监控的窗口的状态,看看是否需要停止或继续查看。在这个例子中,我将子例程保留为d我没有零钱(但你需要在这里)


只需使用
a::a
,保存并运行。
a
被解释为
Shift
+
a
,并可用于键重新映射。这也可用于
#IfWinActive
#IfWinExist
>(很抱歉,它不起作用。它是一样的,每次我想执行宏时,我仍然必须释放修改器。还有其他想法吗???我想我需要一个发送键代码的脚本(一个depper代码)罗伯特,谢谢你的注意,在我想要使用你的脚本的应用程序内部似乎运行良好,尽管我必须用大写字母键入文件名。但是有一个巨大的麻烦,你能告诉我,如何修改你的脚本以解决我的问题,但是同时使用一个和两个修改器吗?我的意思是,我不需要be必须释放并再次按下:Shift+A、Alt+A和Alt+Win+A(每个不同的组合调用不同的宏)但是对于你的脚本,我只得到了Shift+A,总是,不知道还有什么其他的修改键被按下。谢谢Vanced请阅读上面我在最后添加了一段,以便更好地解释我的问题,谢谢高级Robert,我想我需要另一种脚本,考虑到哪些修改键被按下了
:*:a::
    Send, {Shift Down}a{Shift Up} ; or use the more modern SendInput
Return
#SingleInstance Force
#installKeybdHook
#Persistent
AppName=MyKeys
Menu, Tray, Tip, %AppName%
Menu, Tray, Icon , Shell32.dll, 45, 1 ; 45, 28, 113, 74, 134
TrayTip, %AppName%, Started, 1 


*a::
GoSub, MyGetKeyStateSub
If (MyGetKeyStateValue=0)
{
    SendInput, a
}
Else
{
    if( MyGetKeyStateValue & 1 > 0) ; Compare first bit
        MsgBox, LCtrl
    if( MyGetKeyStateValue & 10 > 0) ; compare second bit
        MsgBox, RCtrl
    if( MyGetKeyStateValue & 100 > 0) ; compare third bit
        MsgBox, LShift
    if( MyGetKeyStateValue & 1000 > 0)
        MsgBox, RShift
    if( MyGetKeyStateValue & 10000 > 0)
        MsgBox, LAlt
    if( MyGetKeyStateValue & 100000 > 0)
        MsgBox, RAlt
    if( MyGetKeyStateValue & 1000000 > 0)
        MsgBox, LWin
    if( MyGetKeyStateValue & 10000000 > 0)
        MsgBox, RWin
    if ( MyGetKeyStateValue & 00000011 > 0) ; If LCtrl AND LShift pressed
        MsgBox, LCtrl AND LShift
}
Return


MyGetKeyStateSub:
MyGetKeyStateValue:=0
if getkeystate("LCtrl", P)
    MyGetKeyStateValue+=1 ; set least significant bit
if getkeystate("RCtrl", P)
    MyGetKeyStateValue+=2 ; set 2nd least significant bit, etc, etc.
if getkeystate("LShift", P)
    MyGetKeyStateValue+=4
if getkeystate("RShift", P)
    MyGetKeyStateValue+=8
if getkeystate("Lalt", P)
    MyGetKeyStateValue+=16
if getkeystate("Ralt", P)
    MyGetKeyStateValue+=32
if getkeystate("LWin", P)
    MyGetKeyStateValue+=64
if getkeystate("RWin", P)
    MyGetKeyStateValue+=128
Return
*d::
GoSub, MyGetKeyStateSub
If (MyGetKeyStateValue=0)
{
    SendInput, d
}
Else
{
    if( MyGetKeyStateValue = 1) ; LCtrl
    {
        ;MsgBox, LCtrl
        SendInput, {LShift Down}d{LShift Up}
        Return
    }
    if( MyGetKeyStateValue = 4) ; LShift
    {
        ;MsgBox, LShift
        SendInput, {LCtrl Down}{LShift Down}d{LShift Up}{LCtrl Up}
        Return
    }
}
Return