pause controlsend loop when using keyboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gmion11
Posts: 6
Joined: 17 Feb 2017, 13:27

pause controlsend loop when using keyboard

17 Feb 2017, 13:39

I have the following loop that sends F9 to an inactive window:

Code: Select all

loop
{
Sleep 1000
ControlSend,,{F9},inactivewindow
}
the problem is, this interferes with my keystrokes in the active window.

for example, if the above script is running and I open up a notepad and press SHIFT+A . a lot of time I get a lowercase A instead because the my SHIFT keystroke didnt register. the same with CTRL+S to save my notepad, it often sends an S to the notepad instead of CTRL+S to save the file.

is there a way to pause the script for 10 seconds while i am using the keyboard?

i would like to stay away from having to press a key to toggle on/off the script
User avatar
aztec3
Posts: 177
Joined: 07 Apr 2014, 12:05

Re: pause controlsend loop when using keyboard

17 Feb 2017, 14:07

So, you would want it to wait for a keypress (other than F9) and then pause for the 10 seconds, correct?
gmion11
Posts: 6
Joined: 17 Feb 2017, 13:27

Re: pause controlsend loop when using keyboard

18 Jan 2018, 19:35

for anybody interested in the answer:

Code: Select all

Loop,
{
	if A_TimeIdlePhysical < 1000
	{
		Sleep, 7000
	}
	if A_TimeIdlePhysical > 1000
	{
		ControlSend, , {f9}, myWindowName
		Sleep, 1000
	}
}
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: pause controlsend loop when using keyboard

18 Jan 2018, 21:25

gmion11 wrote:... this interferes with my keystrokes in the active window. ...
It should be not possible, that your code above interferes with another windows.
Maybe you're running more ahk-code as you have showed. Are you using Ctrl or Shift as modifier for any hotkey or label together with keywait?
Code using keywait could cause your described problems.
Einfach nur ein toller Typ. :mrgreen:
gmion11
Posts: 6
Joined: 17 Feb 2017, 13:27

Re: pause controlsend loop when using keyboard

21 Jan 2018, 23:57

divanebaba wrote:
gmion11 wrote:... this interferes with my keystrokes in the active window. ...
It should be not possible, that your code above interferes with another windows.
Maybe you're running more ahk-code as you have showed. Are you using Ctrl or Shift as modifier for any hotkey or label together with keywait?
Code using keywait could cause your described problems.

Yes, I have other AHK scripts where I have hotkeys that use CTRL or ALT or SHIFT to complete small tasks such as move a window.

an example script would be :

Code: Select all

!o:: 
WinMove, Google Chrome,,1961,446,1299,608
Perhaps that's what was interfering with the F9 script?
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: pause controlsend loop when using keyboard

22 Jan 2018, 05:52

gmion11 wrote:...
Perhaps that's what was interfering with the F9 script?
I don't know.
Even possible, that you have defined F9 as a hotkey in another running AHK-script.
I have learned, that using KeyWait or similar action for modifier keys or the hotkey itself sometimes causes strange behaviour.

Try to test your script without running any another AHK-script. I think, if the problem is not in the code that you have not showed, your modifier key problems should be past.
Einfach nur ein toller Typ. :mrgreen:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder, ruespe and 370 guests