I have some actions defined in an Autohotkey script and I want to run it
whenever I press SPACE+Alt+Q.
How can I do it?
I have read that space has some issues, because it is already used by AHK to confirm the abbreviations or something like that, but I really don't use abbreviations.
~Space & j::
If GetKeyState("Alt") = 0
Send {Left}
Else
Send +{Left}
Return
What suggestions do you have?
now I'm trying this that got from AHK forum, so far, its allow me to run the script continuosly without having to realease the space bar
; THIS IS THE FIRST PART OF MY SCRIPT, ITS FOR THE e, +e, d, +d HOTKEYS...
ARprecColPickerFn(a, b, c)
{
clipboard = ; Start off empty to allow ClipWait to detect when the text has arrived.
MouseGetPos posX, posY
BlockInput, MouseMove
MouseClick, Left, a, b
Sleep 50
SendInput {Ctrl Down}{c Down}
SendInput {c Up}{Ctrl Up}
ClipWait, 2 ; Waits 3 secs for the clipboard to contain text
clipboard += %c%
SendInput {Ctrl Down}{v Down}
SendInput {v Up}{Ctrl Up}
Send {Enter}
BlockInput, MouseMoveOff
MouseMove %posX%, %posY%
}
e::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerLumY, 2)
return
+e::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerLumY, 1)
return
d::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerLumY, -2)
return
+d::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerLumY, -1)
return
; THIS IS THE SECOND PART OF THE SCRIPT, IS FOR THE Space & e, Space & !e, Space & d, Space & !d...
~$Space::
KeyWait,Space,T0.2
If (ErrorLevel)
{
HotstringsEnabled:=true
KeyWait,Space
HotstringsEnabled:=false
}
else
Send {Space}
Return
#If HotstringsEnabled
#Hotstring *
e::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerBluY, 4)
return
!e::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerBluY, 2)
return
d:
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerBluY, -4)
return
!d::
ARprecColPickerFn(ARprecColPickerRestX, ARprecColPickerBluY, -2)
#If
So far the script works fine, but I have an issue. the first part of the script, the one that use "d" as hotkey, it gets triggered whenever I press "space + d", how can I make both actions coexist together? (the one that is triggered by "d" and the other that its triggered by "space & d" Please any AHK superuser that could check it out, thanks advanced.
Btw, what does mean...
#Hotstring *
EDITED>>>>
In an Autohotkey script I would like Space Alt E
to ADD FIVE, and Space Alt D
to SUBTRACT FIVE, and Space E
to ADD TEN, and Space D
to SUBTRACT TEN.
I want to add or subtract consecutively and quickly, so I want to hold down Space Alt
and then have distinct events when pressing E
or D
. e.g. SpaceHoldDown AltHoldDown Edown Eup Edown Eup Edown Eup
would ADD FIVE 3 times.
Also sometimes I first press Space
and then Alt
(in order to hold them down before pressing E
or D
to ADD or SUBTRACT) and other times I press first Alt
then Space
, but in either case I would like to get the same result when pressing E
or D
afterwards. This is something my current script can't do, meaning I always have to take care to press first Space
and then Alt
before pressing E
or D
in order for the script to work, cuz if I press first Alt
and then Space
it wont work. I would like the script to work no matter in what order Space
and Alt
Key are pressed.
Finally I need the Space
Key to keep its native function (not to be blocked) cuz it is used to navigate in the application.
Currently the script is working letting me hold down Space Alt
and E
or D
consecutively in order to ADD or SUBTRACT multiple times, but it has the problems that I have to press first Space
then Alt
otherwise it won't work, also this whole peace of script must be placed at the very end of my AHK script cuz otherwise it will interfere with other subroutines.
LAST EDIT, THE CODE IM TRYING BASED ON JJHONSTON2 ANSWER...
#If WinActive("ahk_class xxx") || WinActive("ahk_class YYY")
#If (GetKeyState("Alt", "P")) && (GetKeyState("Space", "P"))
q::
msgbox you typed Alt Space Q
#If
#If <----- do I need to put a second #If (turn off context sensitivity)?
but it doesn't work.
After testing, I have realized that I have to use #If
and not If
cuz the latter only will trigger the subroutine if I press Alt and Space AFTER I have pressed Q.
But using #If
doesn't allow me to test 2 keys using the && operand.
please would somebody know how to use the #If GetKeyState
with 2 keys Space
and Alt
Please notice that I do need to be able to hold down space
and alt
and press and release Q multiple times in order to ADD 10 consecutively, that's very important, that's why a workaround like this below is not usefull cuz it force me to release alt
or space
between subroutines (run it multiple times)
#If GetKeyState("Space", "P")
!q:: ; The word UP may follow the name of a hotkey to cause the hotkey to fire upon release of the key rather than when the key is pressed down.
msgbox wttffff
Return
#If
#If GetKeyState("Alt", "P")
Space & q:: ; The word UP may follow the name of a hotkey to cause the hotkey to fire upon release of the key rather than when the key is pressed down.
msgbox wttffff
Return
#If
thanks advanced.
Space+Alt Q→J→J→Q→Q
orSpace+Alt Q→J
(multiple Q/J presses or one each)?Space Alt Q
to ADD FIVE, andSpace Alt A
to SUBTRACT FIVE, andSpace Q
to ADD TEN, andSpace A
to SUBTRACT TEN. I want to add or subtract consecutively and quickly, so I want to hold down Space Alt and then have distinct even when pressing Q or A. e.g.SpaceHoldDown AltHoldDown Qdown Qup Qdown Qup Qdown Qup
would ADD FIVE 3 times. Also sometimes I first press Space and then Alt (in order to hold them down) and other times I press first Alt then Space, but in either case I would like to get the same result when pressing Q or A afterwards. My current script can't do both.