Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Hotkey command strange behavior


  • Please log in to reply
11 replies to this topic
evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

I am probably trying to use it in a way not originally intended, but here goes anyway.

 

Consider the following code:

; Declare a hotkey for CTRL-A. When used, select all should NOT work, you hear a beep instead
hotkey, ^a, test, ON
; Turn it off
hotkey, ^a, test, OFF
; change it to a pass-through. Ctrl-a for select all should work, AND you should hear a beep
hotkey, ~^a, test, ON
; It doesn't work. Comment out the first two hotkey commands, and it does.
 
return
 
test:
soundbeep
return


Masonjar13
  • Members
  • 1517 posts
  • Last active:
  • Joined: 16 Sep 2012

When a hotkey is first created -- either by the Hotkey command or a double-colon label in the script -- its key name and the ordering of its modifier symbols becomes the permanent name of that hotkey as reflected by A_ThisHotkey. This name does not change even if the Hotkey command later accesses the hotkey with a different symbol ordering.

Not exactly explicit, but this is why.

Tested.

#If !Pass
^a:: Gosub test
#If Pass
~^a:: Gosub test
#If
 
^+a:: Pass:= !Pass
 
test:
Msgbox
Return

OS: Windows 7 Ultimate / Windows 8.1 Pro | Editor: Notepad++


evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

"ordering of" can mean "a different set of"??

 

I think I see a reason why it happens, it is just very annoying, and it should also be stated in the docs that it is impossible to change the ~ status of a hotkey once it is set.

Making the change later has no effect - the original inclusion or exclusion of ~ will take effect in the newly declared hotkey.

 

This is not the case with * for example - you can add or remove wildcard status to a hotkey no problems.

 

ie, this works where the above code does not:

; Declare a hotkey for CTRL-A. When used, select all should NOT work, you hear a beep instead
hotkey, ^a, test, ON
; Turn it off
hotkey, ^a, test, OFF
; change it to a pass-through. Ctrl-a for select all should work, AND you should hear a beep
hotkey, *^a, test, ON
; Works fine
 
return


evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005
Bump

Could still do with a solution here...

Would it maybe be possible to add a command to AHK that totally removes all hotkeys that were declared with the hotkey command?

As it stands, any utility that attempts to allow the user to dynamically assign hotkeys simply will not work properly. IMHO this is a major shortcoming of AHK.

Masonjar13
  • Members
  • 1517 posts
  • Last active:
  • Joined: 16 Sep 2012

Why not do something like..

1::
if(!Passthrough)
    Send %A_ThisHotkey%
... ; rest of the hotkey subroutine

OS: Windows 7 Ultimate / Windows 8.1 Pro | Editor: Notepad++


RHCP
  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006

Press F1 to enable/disable the pass through hotkey.

#if, var
#if
Hotkey, If, var
hotkey, ~^a, test
Hotkey, If

; Since this is not a context sensitive hotkey, it can 
; come before or after the above hotkey. As context sensitive
; hotkeys take priority over global hotkeys
hotkey, ^a, test
return
 
test:
soundbeep
return

f1::
var := !var 
return

Having a command to completely remove all hotkeys would be useful, but it won't be added. And this isn't really a suitable solution for your main goal - on the fly user hotkeys.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Would it maybe be possible to add a command to AHK that totally removes all hotkeys that were declared with the hotkey command?

 

No.  Hotkeys can't be deleted, only suspended.

 

As it stands, any utility that attempts to allow the user to dynamically assign hotkeys simply will not work properly.

 

You make it sound like a much bigger issue than it is.  Any such utility which also allows the ~ modifier to be optionally used (this is the first I've heard of) will not work properly with respect to adding or removing ~.  Any other hotkeys, and the hundreds of other scripts which never attempt to add or remove ~, will work just fine.

 

This is not the case with * for example - you can add or remove wildcard status to a hotkey no problems.

 

No, you cannot add or remove *.  ^a and *^a are two distinct hotkeys; depending on the order, you can have ^a fire when you press Ctrl+A and *^a fire only if other modifiers are also used (Shift+Ctrl+A, Alt+Ctrl+A, etc.).

 

 

Having a command to completely remove all hotkeys would be useful, but it won't be added.

 

True, though it isn't your place to say.

 

And this isn't really a suitable solution for your main goal - on the fly user hotkeys.

 

Agreed.

 

It seems to me that the actual issue here, the inability to add or remove ~ to an existing hotkey variant, might be fixable.



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

You make it sound like a much bigger issue than it is.  Any such utility which also allows the ~ modifier to be optionally used (this is the first I've heard of) will not work properly with respect to adding or removing ~.  Any other hotkeys, and the hundreds of other scripts which never attempt to add or remove ~, will work just fine.

Big in what sense?
Number of users it affects? Thousands for my scripts alone.
In terms of impact? It stops what would potentially be the first AHK dynamic hotkey solution that properly reflects the capabilities of AHK (Recognizes all keys / mouse buttons with all modifier combinations including just modifier keys, * and ~ options for each binding etc etc) from working. So close to perfection and yet so far :(

It seems to me that the actual issue here, the inability to add or remove ~ to an existing hotkey variant, might be fixable.

Well that is some consolation. I take it you would be unable / unwilling to give me some idea on timeframe here?

Thanks for taking the time to have a look at this.

C

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Big in what sense?

 

Exaggerating the scope and impact of the problem by making broad or vague statements.

 

In my experience, utilities which allow users to dynamically assign hotkeys (AutoHotkey based or not) typically don't provide pass-through as an option, which is probably because pass-through isn't appropriate in the vast majority of cases.  So to say that the problem affects any such utility is inaccurate.  "Simply will not work properly" might be true strictly speaking (if by "properly" you mean "perfectly and completely in every circumstance") but the fact is that those utilities "simply will work" most of the time.  If not, how did your utility get thousands of users?  Lastly, having likely been around for 8 years or so, I cannot see this limitation as much of a problem.

 

I take it you would be unable / unwilling to give me some idea on timeframe here?

 

I'll take a look now, and likely fix it in the next release.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Done.



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

Exaggerating the scope and impact of the problem by making broad or vague statements.

In my experience, utilities which allow users to dynamically assign hotkeys (AutoHotkey based or not) typically don't provide pass-through as an option, which is probably because pass-through isn't appropriate in the vast majority of cases.  So to say that the problem affects any such utility is inaccurate.  "Simply will not work properly" might be true strictly speaking (if by "properly" you mean "perfectly and completely in every circumstance") but the fact is that those utilities "simply will work" most of the time.  If not, how did your utility get thousands of users?  Lastly, having likely been around for 8 years or so, I cannot see this limitation as much of a problem.
 
I'll take a look now, and likely fix it in the next release.

By "properly", I mean "perfectly and completely in as many circumstances as are reasonably attainable" happy.png

And seeing as I thought it may well quite simple to fix, I just tried to convey that this little issue was stopping the "ideal solution" from working.
If you feel I over-egged it, apologies...

Unfortunately, auto-email does not seem to be working for me, so I missed your speedy response. Thanks for the new version, I will check it out soon. Not now though, been up late fixing the UI issues in Elite Dangerous, time for bed ;)



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

New version tested and working !

 

bindmode.gif

 

Finally a fully functional bindings tab!