Jump to content

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

[solved] - Three-letter combination shortcuts


  • Please log in to reply
10 replies to this topic
McTyper
  • Members
  • 8 posts
  • Last active: Oct 26 2011 05:10 AM
  • Joined: 28 Sep 2011
Hi.

I want the following behavior: When 'p' is pressed (and not released), after that 'r' is pressed (and not released) and after that 'o' is pressed, and after that all three keys are released, in any order, then besides the normal 'pro' the string 'cedure' should be sent, so the 3-key combination results in the whole word 'procedure'. You get the idea. I want quite a lot of such combinations.

Is this possible/easy to solve within the ahk framework?

If so, any hints to what I should study? I am a software developer, but I am new to ahk.

Thanks!

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Your hardware and drivers may not support 3 keys held down anyway. If they do, try <!-- m -->http://d.ahk4.me/~GetKeyState<!-- m -->
#If GetKeyState()

McTyper
  • Members
  • 8 posts
  • Last active: Oct 26 2011 05:10 AM
  • Joined: 28 Sep 2011

Your hardware and drivers may not support 3 keys held down anyway. If they do, try <!-- m -->http://d.ahk4.me/~GetKeyState<!-- m -->
#If GetKeyState()


Thanks. Ok, lets assume that the hardware and drivers support this, at least for the 3-key combinations of interest. Interesting point, but I just want it to work on my own computers.

So something like this could be done by making 'o' a conditional hotkey, where the condition is that GetKeyState says 'p' is physically down, and GetKeyState also says that 'r' is physically down? Then and only then should 'o' send not only 'o' but also add 'cedure'. Does this outline seem correct to you?

If I would want to go further and have this particular abbreviation only work if 'p' was pressed before 'r', but not vice versa, then this perhaps could be done by making any letters hotkeys in such a way that variables store the last two letters pressed. And then make (in this example) 'o' a conditional hotkey with the conditions that the next-to-last key was 'p', and that the last key was 'r', and that GetKeyState says that both these keys are still down. Then and only then, the 'cedure' part is also sent. Does this outline seem correct to you?

Thanks for helping!

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
I would use code like
#If GetKeyState("p", "P") && GetKeyState("r", "P")
~o::Send cedure
but only if you type fast.
Another way is Loop+Chr()+Hotkey

McTyper
  • Members
  • 8 posts
  • Last active: Oct 26 2011 05:10 AM
  • Joined: 28 Sep 2011

but only if you type fast.


Will you tell me how fast?
Thanks!

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
is there any reason you don't want to use a hotstring?

::pro::procedure

as a user, I would find holding down p, r, and o to be annoying at best.

McTyper
  • Members
  • 8 posts
  • Last active: Oct 26 2011 05:10 AM
  • Joined: 28 Sep 2011

is there any reason you don't want to use a hotstring?

::pro::procedure

as a user, I would find holding down p, r, and o to be annoying at best.


Yeah, that's a good question. First, there is a clear reason. I simply don't want ordinarily typed 'pro' to automatically expand further. There are many words that begin with that (here is a list: http://www.morewords...tarts-with/pro/). Even just "pro" is a word.

The other part of your comment is also interesting. The way I type, is NOT having my hands still (index fingers on 'f' and 'j' etc), no its more like it depends on the word. Mostly index and long fingers, and sometimes the others. Even space is not just for the thumb. Well, enough said about that. The point is that I would expect the proposed shortcuts to work for me, but its just an experiment.

Thanks for commenting.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
you could use a special char to do replacements. pro- for example. (specific start or end char)

maybe also look at my wiki prompt script? (link inside (Common Answers))

Also, if you want to stick to your original request, be sure to look at A_PriorHotkey, which can help you keep track of the previous two. (or see below)

did nimda's script work for you?

Lastly try GIRPto practice the finger stretches you would need for this:
#SingleInstance force

combolist =
(
procedure
engunneer
)

Loop, 26
{
  ThisChar := Chr(Asc("a") + A_Index - 1)
	Hotkey, ~$%ThisChar%, hotkeyHandler
	Hotkey, ~$%ThisChar% up, hotkeyReleased
}
Loop, 10
{
  ThisChar := Chr(Asc("0") + A_Index - 1)
	Hotkey, ~$%ThisChar%, hotkeyHandler
	Hotkey, ~$%ThisChar% up, hotkeyReleased
}
Return

hotkeyHandler:
hotkeybuffer3 := hotkeybuffer2
hotkeybuffer2 := hotkeybuffer1
hotkeybuffer1 := SubStr(A_ThisHotkey, 0)
comboPressed := hotkeybuffer3 . hotkeybuffer2 . hotkeybuffer1
Loop, parse, combolist, `n, `r
{
  If SubStr(A_LoopField, 1, 3) = comboPressed
	{
	  Send, % SubStr(A_LoopField, 4)
	  break
	} 
}
Return

hotkeyReleased:
	hotkeybuffer3 := ""
	hotkeybuffer2 := ""
	hotkeybuffer1 := ""
Return
Tested!

McTyper
  • Members
  • 8 posts
  • Last active: Oct 26 2011 05:10 AM
  • Joined: 28 Sep 2011

did nimda's script work for you?

No, but this worked:
~o::
  If GetKeyState("p", "p") && GetKeyState("r", "p") {
    Send cedure
  }
return
Next step is to make only "pro" work, and not "rpo". I will look into your tips and report back. Thanks!

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
the script I posted is completely tested and working, and only pro (as opposed to rpo) will trigger it. It is even already set up that you just give it a list of words, and it automatically handles all of them.

the list can even be appended to in real time., and allows numbers in the three key combo.

McTyper
  • Members
  • 8 posts
  • Last active: Oct 26 2011 05:10 AM
  • Joined: 28 Sep 2011

the script I posted is completely tested and working, and only pro (as opposed to rpo) will trigger it. It is even already set up that you just give it a list of words, and it automatically handles all of them.

the list can even be appended to in real time., and allows numbers in the three key combo.

whatwhatWHAT!! Sorry, I didn't realize you just implemented the whole idea! It works great!!

Thank you so very much!!!