1
I use AHK 1.1 to set the CapsLock to be a hotkey to toggle ArtRage full screen mode (workbench mode), I do so because ArtRage doesn't allow me to set CapsLock as a hotkey, but I'm quite used to use that key to do that in many programs, so I thought AHK could help me, my script was simple:
; AR4 Toggle Workbench Mode
Capslock::
Send {Ctrl Down}{Right}{Ctrl Up} ; Ctrl Right is the key I set to toogle the workbench mode
WinActivate ahk_class ArtRage 3
return
#If
The script works only the first time I enable the full screen mode and the first time I disable it, I mean the first two times I press CapsLock , but then it won't work unless I manually click on the ArtRage window. If I do so I can use the hotkey two more times.
So I guess I'm somehow loosing focus on the window. I have tried also this:
Capslock::
ControlSend,, {Ctrl Down}{Right}{Ctrl Up}, ahk_class ArtRage 3
WinActivate ahk_class ArtRage 3
return
#If
with the same result, I google about it, and I tried:
Capslock::
WinGet, AR4_id, ID, A
Send {Ctrl Down}{Right}{Ctrl Up}
ControlFocus,,%AR4_id%
return
but it doesn't work at all. Hope some superuser could help me on this one.
EDITED >>>>
So Now I have tried to make the script work if WinExist AND if WinActive, is that possible? I made it like this, but it doesn't work, CapsLock still calls ArtRage on every application.
#If WinActive("ahk_class ArtRage 3")
#If WinExist("ahk_class ArtRage 3")
Capslock::
ControlSend, ahk_parent, {SC037}, ahk_class ArtRage 3 ; NumpadMult
return
#If
#If
EDIT2>>>>
I tweaked the code like this:
If WinActive("ahk_class ArtRage 3")
Capslock::
ControlSend, ahk_parent, {SC037}, ahk_class ArtRage 3 ; NumpadMult
return
#If
the code works, but if ArtRage is open (not focused) and I'm in MS Word, if I press CapsLock it will not send CapsLock but it will send the "work in benchmode" in Artrage despite is not focused.
PD: Now NumpadMult is the new hotkey to enter the full screen mode (it's easier).
I'm currently testing, I don't know sometimes works, sometimes not. Not working I stil have to make click on ArtRage window after performing the first two times, any idea? – litu16 – 2016-11-29T02:42:20.773
Check my edited answer. – user3419297 – 2016-11-29T09:32:08.670
Nop, it doesn't create a new instance of ArtRage, the AHK script always prints "there is only 1 window fo this ahk class. The curious thing is that I have tried that key with two macro recorders, "Key Manager" and "Hot Keyboard Pro" both work fine, so I gues there isn't nothing special on the Artrage window. can I use
contrlsendin this case? – litu16 – 2016-11-29T11:16:13.913See also EDIT2 above. – user3419297 – 2016-11-29T11:32:50.630
thanks it worked using the
#If WinExistand theahk_parent. But now the problem is that if artrage is open (even not focused) Capslock won't fire Capslock in any other application instead it will jump to ArtRage and press^{Right}, so other apps that use Capslock to enter in full screen mode won't work, until I close either ArtRage or Autohotkey. What can I do? I EDITED my question to show what I did, Thanks Advanced. – litu16 – 2016-11-29T17:52:32.267There are many ways to solve this problem, and it will depend on your situation. I'd start another question to discuss it. – user3419297 – 2016-11-29T18:08:20.697
Let us continue this discussion in chat.
– user3419297 – 2016-11-29T18:10:39.590A new question would be very similar to this one, cuz it would need to kinda summarize all what was explained in this questions, things like... I use AHK 1.1 to set the capslock to be a hotkey to toogle ArtRage full screen mode (workbench mode), I do so, cuz ArtRage doesn't allow me to set capslock as a hotkey, but I'm quite used to use that key to do that in many programs. So far
#if winexistis to wide handle, but If I use#if winactiveit won't work, how can I solve this? thanks advanced. – litu16 – 2016-11-29T18:55:01.657See EDIT3 above. – user3419297 – 2016-11-29T20:12:44.020
Hi, user3419297, I don't understand, #if WinExist is a wide handle, but only if you give priority to it, that is, if you put it before other #if directives in the script. Try to give priority to #if WinActive directives (put them before #if WinExist in your script). isn't that what I just did?, I tried to put another
#Ifbefore the#ifWinExist. Could you please show an example of How to do it? I posted in my edidted code how I thought I could put another#ifbefore the#ifWinExistbut then you said it is wrong, how should I do it? thanks advanced. – litu16 – 2016-11-29T22:05:04.980Hi user3419297I made a new question about this issue, hope you could help me out http://superuser.com/questions/1151188/autohotkey-hotkey-overriding-key-in-all-windows-apps-instead-of-just-if-windo thanks advanced.
– litu16 – 2016-11-29T23:26:09.253See Example in EDIT3. – user3419297 – 2016-11-29T23:30:03.700
I see that spaces have no meaning in AHK scripting. Thanks for the example, now I think I could do it, but I usually put the
#If WinActivethen do some code then#if(end of context-sensitive hotkeys) before start another different piece of code, cuz otherwise most of the hotkeys won't work to me. So I tested as your example but I set the precedence, put the code, then closed the context-sensitive hotkeys, and open the new#IfWinActive ArtRageand it worked, but... would it mean that I have to kinda LIST all apps different tahn ArtRage where I want thecapslockto work different. Thank – litu16 – 2016-11-30T00:01:16.050anoother thing that confuse me of AHK scripting is that
Ifandelsestatements need braces (if the code within them are larger than 1 line), but these in your example doesn't need them, why? – litu16 – 2016-11-30T00:02:49.420hi user3419297 I solved it, but I have problems refocusing on ArtRage window after the script have run, I posted what I did in this new question with all details, could you please check it out? tahnks advanced. http://superuser.com/questions/1151188/autohotkey-hotkey-overriding-key-in-all-windows-apps-instead-of-just-if-windo
– litu16 – 2016-11-30T03:21:52.550