Page 1 of 1

script stopped working after adding a second script

Posted: 02 Nov 2015, 16:47
by schwarzgrau
I wrote this script for my F13 key, which sends out k if pressed long and right if pressed short.

Code: Select all

F13::                                              
    KeyWait, F13, T0.5                              
    If ErrorLevel {                                    
        SendInput k 			;LONG - k	                          
        KeyWait, F13	
    }Else {                                             
        SendInput {Right}   		;SHORT - right                           
     	}
Return
It works like it should, but if I add this toggle script for the win-key to the script my long-press-script stopped working and I don't know why.

Code: Select all

LWin:: 
  toggle:=!toggle
  if toggle {
    SendInput, 2
  }Else {
   	SendInput, 1
   	}
Return
Maybe someone can tell me why

Re: script stopped working after adding a second script

Posted: 02 Nov 2015, 19:44
by RobertL
I test this which should be the same, it works, can't recur any error.

Code: Select all

a::                                              
    KeyWait, a, T0.5                              
    If ErrorLevel {                                    
        SendInput k 			;LONG - k	                          
        KeyWait, a
    }Else {                                             
        SendInput {b}   		;SHORT - right                           
	}
	Return
c:: 
  toggle:=!toggle
	if toggle {
		SendInput, 2
	}Else {
		SendInput, 1
	}
	Return

Re: script stopped working after adding a second script

Posted: 02 Nov 2015, 20:01
by schwarzgrau
Ya you're right. Everything seems to work as it should. I tried to edit your version back to mine and if I'm right, it has something to do with the LWin:: command, but I don't know why it causes this error in the other script.

Re: script stopped working after adding a second script

Posted: 02 Nov 2015, 23:31
by RobertL
I test again, works as uaual. Using LWin instead of c::, and split the two hotkey procedure in different script.
Is there any conflict in your other script? e.g. LWin in another script, with any context?

Re: script stopped working after adding a second script

Posted: 03 Nov 2015, 05:09
by schwarzgrau
No unfortunately not. It's a pretty short script, since I just want to test if every hotkey procedure works to write the whole thing.

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.

;::::::::: K R E I S :::::::::::::::::::::::::::::::::::::

;......... ZENTRUM ..........................................

LWin:: 
  toggle:=!toggle				;SINGLE - fullscreen
  if toggle {
    SendInput, 2
  }Else {
   	SendInput, 1
   	}
Return


;......... RECHTS ........................................

F10::                                              
    KeyWait, F10, T0.5                              
    If ErrorLevel {                                    
        SendInput k 				;LONG - k - new Key 			                          
        KeyWait, F10	
    }Else {                                             
        SendInput, {Right}   			;SINGLE - right - next frame                                  
     	}
Return

Re: script stopped working after adding a second script

Posted: 03 Nov 2015, 08:11
by RobertL
BTW, what does 'stopped working' mean in the top post? Means F13 or whatever hotkey won't be triggered if there is LWin? so, procedure under that hotkey is never reached.
Check keyboard / language layout, IME, or test other combination with LWin, like ~LWin, RWin, a & LWin etc.
Sorry, I have no idea, try some more test.

Re: script stopped working after adding a second script

Posted: 03 Nov 2015, 16:51
by schwarzgrau
My F10 hotkey procedure sends out {Right} if pressed short and k if pressed long. If I add LWin to the script it still sends out{Right} but not k.
Unfortunately I already tried ~LWin, $LWin, *LWin, a & LWin and also

Code: Select all

LWin::x
x::
But as soon, as I add LWin (or RWin) to my script a lot of stuff stops working. I guess I just need to activate two scripts, but thank you a lot for your help.

Re: script stopped working after adding a second script

Posted: 03 Nov 2015, 19:16
by RobertL
schwarzgrau wrote:My F10hotkey procedure sends out{Right} if pressed short and k if pressed long. If I add LWin to the script it still sends out {Right} but not k.
Simplifying this, LWin break out the time out part (ErrorLevel always equal false) of KeyWait in the whole script, even LWin never pressed. If so, this should be a bug.

And, I guess it is about your keyboard layout, since I see your location - Germany.

Try to use scan code instead of key name. Index this part - key list \ Special Keys - from document.

Re: script stopped working after adding a second script

Posted: 03 Nov 2015, 20:10
by schwarzgrau
I guess you're right. Every part of the script which uses Keywait stops working if using Lwin anywhere in the script, but also if I use Alt or #IfWinActive.
Never thought about it, but maybe you're right about the keyboard-layout too, even if I can't imagine to be the first with a german keyboard-layout trying to useLwin in combination withKeywait.

I tried using <#a and SC15B:: (the scan code of my left Win key) instead of LWin, but with the same result.

Re: script stopped working after adding a second script

Posted: 04 Nov 2015, 07:09
by schwarzgrau
Shit! In the beginning the LWin command didn't worked with Keywait if I use it on my regular keyboard or on the Expresskeys of my Wacom Cintiq and since the script should work on the Cintiq I lastly tested it only on the Cintiq. BUT everything works if I use the script on my regular keyboard, only if I use it with the Express Keys of the Cintiq I can't use keywait in combination with Alt::, #IfWinActive, LWin:: and so on.
I'm really sorry stealing your time, since this seems to be a problem with the buttons of the Cintiq and not with the script.
I guess I should try to find out why the buttons of the Cintiq are so problematic.

Re: script stopped working after adding a second script

Posted: 05 Nov 2015, 00:36
by RobertL
Glad to hear you find the issue.
Also, new experience got:
Problem may happen if using multi keyboard such as peripheral device, especially which have entity keys like your Expreeskey on Wacom. It seems only use regular keyboard or one from Cintiq will be OK. Imagin that, KeyWait didn't know to wait from which keyboard.
Perhaps, the install sequence will effect the result too. Check the latest one? Maybe.

It will be a good question - decide from multi keyboard. Search and get a new topic.