script stopped working after adding a second script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
schwarzgrau
Posts: 23
Joined: 01 Nov 2015, 11:16
Location: Germany
Contact:

script stopped working after adding a second script

02 Nov 2015, 16:47

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
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: script stopped working after adding a second script

02 Nov 2015, 19:44

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
我为人人,人人为己?
User avatar
schwarzgrau
Posts: 23
Joined: 01 Nov 2015, 11:16
Location: Germany
Contact:

Re: script stopped working after adding a second script

02 Nov 2015, 20:01

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.
Last edited by schwarzgrau on 03 Nov 2015, 16:51, edited 1 time in total.
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: script stopped working after adding a second script

02 Nov 2015, 23:31

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?
我为人人,人人为己?
User avatar
schwarzgrau
Posts: 23
Joined: 01 Nov 2015, 11:16
Location: Germany
Contact:

Re: script stopped working after adding a second script

03 Nov 2015, 05:09

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
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: script stopped working after adding a second script

03 Nov 2015, 08:11

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.
我为人人,人人为己?
User avatar
schwarzgrau
Posts: 23
Joined: 01 Nov 2015, 11:16
Location: Germany
Contact:

Re: script stopped working after adding a second script

03 Nov 2015, 16:51

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.
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: script stopped working after adding a second script

03 Nov 2015, 19:16

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.
我为人人,人人为己?
User avatar
schwarzgrau
Posts: 23
Joined: 01 Nov 2015, 11:16
Location: Germany
Contact:

Re: script stopped working after adding a second script

03 Nov 2015, 20:10

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.
User avatar
schwarzgrau
Posts: 23
Joined: 01 Nov 2015, 11:16
Location: Germany
Contact:

Re: script stopped working after adding a second script

04 Nov 2015, 07:09

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.
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: script stopped working after adding a second script

05 Nov 2015, 00:36

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.
我为人人,人人为己?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: FanaticGuru, yabab33299 and 141 guests