KeyWait blocking other hotkeys Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Cakes
Posts: 23
Joined: 23 Apr 2018, 09:56

KeyWait blocking other hotkeys

04 Jun 2018, 09:50

Hey,

I'm looking for some help. I have spent hours trying to figure out how to get around this. I have two hotkeys ~w and MButton.

If w is down then the Mbutton hotkey works fine. However, If I press MButton then w, The script pauses until I release w. I thought it was the KeyWait but it still happens if I take it out. I can't seem to figure it out.

Code: Select all

MButton::
	toggle := !toggle
	Loop
	{
		if !toggle
			break
		else
		{
			Send {3}
			Sleep, 800
			Send {LButton}
			Send {Shift down}
			Send {4}
			Sleep, 800
			Send {LButton}
			Send {Shift down}
		}
	}
	Send {Shift up}
return
~w:: 
	Send {Shift down}
	KeyWait, w
	Send {Shift up}
return
Cakes
Posts: 23
Joined: 23 Apr 2018, 09:56

Re: KeyWait blocking other hotkeys

04 Jun 2018, 10:48

I tried the changes below but it has the same problem.

Code: Select all

KeyWait, w 
to

Code: Select all

While GetKeyState("w", "P")
    Sleep -1
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: KeyWait blocking other hotkeys  Topic is solved

04 Jun 2018, 12:00

I think this is a good read for you: Why you should avoid while(GetKeyState("a", "P")) to detect release of key

Besides that, using a toggle variable to end a loop, don't work when the hokey itself alters it and you don't change #maxthreadsperhotkey.
Cakes
Posts: 23
Joined: 23 Apr 2018, 09:56

Re: KeyWait blocking other hotkeys

04 Jun 2018, 12:49

Nextron wrote:I think this is a good read for you: Why you should avoid while(GetKeyState("a", "P")) to detect release of key
Wow, this is good to know. I had no idea about threads but this explains a lot. I was able to get it to work by splitting hotkeys between ~w and ~w up
Nextron wrote: Besides that, using a toggle variable to end a loop, don't work when the hokey itself alters it and you don't change #maxthreadsperhotkey.
I have #maxthreadsperhotkey 2 set. I'm not sure how else to write that loop. I tried a while loop and it would go in to endless loop. Basically I want it to do the loop until I press MButton again.

Thank you sir. It's working perfect now.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Joey5, slowwd, Xaucy and 202 guests