Giving priority + combinations

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
recs999
Posts: 9
Joined: 15 Jun 2017, 05:14

Giving priority + combinations

18 Jun 2017, 09:25

I have a problem that then I rapidly hit q and e, the script doesnt work properly. Maybe you have some ideas?
Spoiler
I understood, i have to make a prior of a last pressed key and deactivate previous one.
Moreover, it does not work with combination of other keys, like control, shift etc.
Found one more bug. When I am pressing W and then Q, then releasing q, w has no effect. I understand why it happens (because when i release q it sets w to UP), but I dont know how to fix that, chech if initial w is pressed?
Rohwedder
Posts: 7626
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Giving priority + combinations

18 Jun 2017, 11:23

Hallo,
perhaps this way?

Code: Select all

#InstallKeybdHook
q::
If !GetKeyState("w", "P")
	Send {w Down}
Send {, down}
KeyWait q
If !GetKeyState("w", "P")
	Send {w Up}
Send {, Up}
Return
recs999
Posts: 9
Joined: 15 Jun 2017, 05:14

Re: Giving priority + combinations

18 Jun 2017, 11:32

Rohwedder wrote:Hallo,
perhaps this way?

Code: Select all

#InstallKeybdHook
q::
If !GetKeyState("w", "P")
	Send {w Down}
Send {, down}
KeyWait q
If !GetKeyState("w", "P")
	Send {w Up}
Send {, Up}
Return
yeap, that works perfectly, one problem is solved, still trying to change priority
Rohwedder
Posts: 7626
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Giving priority + combinations

19 Jun 2017, 00:29

Hallo,
perhaps another way:

Code: Select all

; -------- Down Up Hotkeys with higher priority --------
~w:: WPri := True ;w down with higher priority
~w Up:: WPri := False
~,:: CommaPri := True
~, Up:: CommaPri := False
; -------- Down Up Hotkeys with lower priority --------
q:: ;w down and Comma down with lower priority
	Gosub, WDown
	Gosub, CommaDown
Return
q Up::
	Gosub, WUp
	Gosub, CommaUp
Return
; -------- Down Up Subroutines with lower priority --------
WDown:
If (!WLow And !WPri)
{
	Send {w Down}
	WLow := True ;w down with lower priority
}
Return
WUp:
If (WLow And !WPri)
{
	Send {w Up}
	WLow := False
}
Return
CommaDown:
If (!CommaLow And !CommaPri)
{
	Send {, Down}
	CommaLow := True
}
Return
CommaUp:
If (CommaLow And !CommaPri)
{
	Send {, Up}
	CommaLow := False
}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 261 guests