stange #if behavior? need help figuring this out.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Crimson_V
Posts: 9
Joined: 14 May 2016, 06:54

stange #if behavior? need help figuring this out.

28 Dec 2017, 11:34

So my problem is that #if in my script stops working randomly (takes about 5-50 seconds of holding the key or 1-7 presses of the hotkey (namely e in this case))
Here's the piece of the code that i isolated:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

toggle := !toggle

F10::
toggle := !toggle
	if toggle
		{
		Progress, m2 b fs36 zh0, TK:F10 `nHK:E `nE spam ON, , , Franklin Gothic
		Sleep, 1000
		Progress, Off
		}
	else
		{
		Progress, m2 b fs36 zh0, TK:F10 `nHK:E `nE spam OFF, , , Franklin Gothic
		Sleep, 1000
		Progress, Off
		}
return

#if ( toggle )

$*e:: 
   While ( GetKeyState( "e","P" ) ) 
   { 
      Sleep, 5
      Send, {Blind}{e}
      Sleep, 10
   } 
Return
#if

F12::
ExitApp
and the interesting part is that when #if stops working F12 hotkey also does? and strangely only the F10 hotkey keeps working! Removing #if's fixes the script.

removing #if's from my script does prevent it from breaking, but as far as alternatives go i can't use suspend because it shuts down the other parts of the script not shown here, and putting a simple " if " statement after the " $*e:: " does work, when i toggle it off pressing " e " will do nothing and i need to act it as regular e key when the spamming isn't toggled.

I'm so confused :crazy:, could someone give me some directions?
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: stange #if behavior? need help figuring this out.

29 Dec 2017, 04:15

I can't reproduce your problem, are you sure it is ot another part of your script that interferes?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: stange #if behavior? need help figuring this out.

29 Dec 2017, 12:12

Hello Crimson_V.
The issue might be that the keyboard hook is being uninstalled, the system can do that without notifying the application. When the issue occurs, you can try to suspend and unsuspend the hotkeys from the tray menu. If the hotkeys start working again, it is likely the keyboard hook is the issue. Also see #IfTimeout.

Good luck.

Edit: Also, if you check ListHotkeys you will see that F10 isn't using the hook, but e and F12 are, hence, only F10 works if the hook is uninstalled,

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Kodakku and 359 guests