AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change A_(This|Prior)Hotkey behavior with Hotstrings

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Sat Dec 08, 2007 5:06 am    Post subject: Change A_(This|Prior)Hotkey behavior with Hotstrings Reply with quote

My previous idea seems not to be relivant, so I've changed to topic to reflect a different suggestion to address the same "problem". My new suggestion is below.

I previously wrote:
I recently asked for advice on how to detect when a hotstring is activated. Someone helped me come up with a clever workaround, but there doesn't seem to be any general purpose way to do this.

That's what prompts this suggestion, but not the only time it would be useful. Anyway, I suggest adding A_ThisHotstring and A_PriorHotstring. These would work just like A_ThisHotkey and A_PriorHotkey. Alternatively the A_*Hotkey variables could be changed to include hotstrings, but I guess that could cause compatibility problems (though it seems a bit unlikely).


Last edited by ManaUser on Mon Dec 10, 2007 12:49 am; edited 2 times in total
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Sat Dec 08, 2007 5:18 am    Post subject: Reply with quote

Help File wrote:

A_ThisHotkey The key name of the most recently executed hotkey or hotstring (blank if none), e.g. #z. This value will change if the current thread is interrupted by another hotkey, so be sure to copy it into another variable immediately if you need the original value for later use in a subroutine.

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. See also: A_ThisLabel

A_PriorHotkey Same as above except for the previous hotkey. It will be blank if none.

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Sat Dec 08, 2007 6:12 pm    Post subject: Reply with quote

So it's already supposed to do that? It didn't seem to work when I tried... but I'll test it again.

[edit] I see what's going on now. Apparently these variables are updated for block hotstrings but not one-line, auto-replace hotstrings. I guess I can see where that makes sense, but I wasn't expecting it.
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Dec 09, 2007 12:19 pm    Post subject: Reply with quote

ManaUser wrote:
Apparently these variables are updated for block hotstrings but not one-line, auto-replace hotstrings.

...that could be an overlooked bug...& need fixing...but technically the only use would be to auto-replace with the name of the hotstring...

Code:
::btw::A_ThisHotkey(%A_ThisHotkey%)

...or not...I've never used Hotstrings yet, but my quick review of the help sorta tells me that auto-replace hotstrings are kinda special, like Key Remapping...they only take the parameters they are expecting, not the full AutoHotkey Syntax...I need to test what this would do...msgbox or no msgbox...

Code:
::btw::msgbox, A_ThisHotkey(%A_ThisHotkey%)
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Sun Dec 09, 2007 8:08 pm    Post subject: Reply with quote

an autoreplace hotstring can't have variables in it, so you would only get your variable name as an output.

There is a use for this outside your hotstring replacement, though. It would allow you to have another thread (via settimer or hotkey or whatever) keep track of which hotstrings were used. As an example, this could then allow you to keep track of what words you mis-spell the most (with the mega spelling hotstring script) and then you can look to see which ones you need to memorize.

I'd almost submit this as a bug, except it states this in the remarks:
Quote:

Non-auto-replace hotstrings will create a new thread when launched. In addition, they will update the built-in hotkey variables such as A_ThisHotkey.

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Mon Dec 10, 2007 12:46 am    Post subject: Reply with quote

I'll be darned, so it's all documented and everything. Can't call it a bug then, but I can still suggest this behavior be changed, right? Wink (Thus the new title.) So why not just go ahead and update A_ThisHotkey (and A_PriorHotkey) when an auto-replace hotstring is called?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group