topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 3:29 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Super Efficient Extended Hotkey Mapper  (Read 24705 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
IDEA: Super Efficient Extended Hotkey Mapper
« on: October 24, 2006, 08:07 PM »
People have asked for support for non-standard hotkeys in some of my programs (like Ctrl+Ctrl tap for Find+Run Robot) (see https://www.donation...index.php?topic=5925).

I'm a little bit hesitant to add this because my understanding is you could only do this by hooking keyboard events in a more cpu-intensive way.

Of course i could add it and make it optional, BUT i had another idea, that would make a great coding snack.

What about an ultra-efficient, ultra-lightweight tray tool which had only 1 function:
It would capture hotkeys like ctrl+ctrl taps, or shift-shift taps, or alt-alt taps, and trigger a configured hotkey when pressed.

A Bonus would be detecting winkey+ combinations.

So for example, the config would simply be something like:


==============

TapSpeed: 1
Shift Tap -> Ctrl+Space
Ctrl Tap -> Ctrl+Space
Alt Tap -> Ctrl+Space
Win+F -> Ctrl+Space

================


that config file simply says how to convert taps and winkey combos to other standard hotkeys (all to Ctrl+space standard hotkey in my example above), and could be used to provide such functionality to ANY apps.

Note this could probably be done with something like AutoHotKey, but i'm really thinking this would be an ideal VisualC++ coding snacks, designed for maximum speed and efficiency.

Anyone up for this?  I'd love to feature such a tool on DC and include it with Find+Run Robot.

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,119
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #1 on: October 25, 2006, 02:08 AM »
i think this is an excellent idea and i hope it will be done - but i'd just like to point out why i'm always asking for 'wink key' hotkeys...

as i mainly use the computer for messing around with adobe programs, they often conflict with other utils that have 'ctrl', 'alt' and 'shift' keyboard shortcuts - but they never conflict with anything that used the 'win key'.

the problem with creating the tool that you suggest would be that even though i could configure it to act upon a 'win key' shortcut - it would then lead to the same trouble, as above, if the next step was to behave as if i'd hit a 'ctrl' or 'alt', etc combination - photoshop, or whatever, would intercept the hotkeys if it had the main focus.

i assume there would be other software that would suffer the same problem.

as the other forum members requests for different shortcut keys never mention this problem i think i must be in the minority (a minority of one) so i don't think it's anything to be concerned about - i just wanted to mention a possible drawback that would still be encountered.

but, i can think of many other ways of using the app you describe so i'm really looking forward to seeing it done.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #2 on: October 25, 2006, 04:47 AM »
i see your point, but one solution would allow you to configure impossibly annoying hotkey stuff for your other program.  for example, configure farr to open on ctrl+alt+shift+F10.  then use this tool to send that.  im sure you could find a few unsed hotkey combos that could be used for this purpose.  the program could even come preconfigured with these which would suit most users..

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,119
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #3 on: October 25, 2006, 06:25 AM »
very good point.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #4 on: October 25, 2006, 06:45 AM »
also pays to reiterate the strangth of this solution is that it would basically give you a generic way to use these unusual hotkeys with any program..

you know.. i actually wrote something very similar to this when i first started farr, the mini tray helper.. whose only purpose was to catch hotkey and launch program..

why dont i just modify that for this task!  ok i will..

shouldnt take more than a couple of days.

lets call it "TapTap Extended Hotkey Mapper"

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,119
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #5 on: October 25, 2006, 07:02 AM »
sounds like a good idea.

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #6 on: October 25, 2006, 07:31 AM »
Note this could probably be done with something like AutoHotKey

AFAIK such global hotkey feature was the (main) reason why the author of AHK left AutoIt and created AHK.  ;)


AHK can catch any hotkey/mouse-click combination and send own keys.

Adding a simple "IfWinActive" command, you can send different keys to different applications.

Example, if I middle-click in my browser, AHK sends a shortcut combination. In my emailer it sends a different shortcut combination. And in all other application it sends a standard middle-click.


Of course, an own GUI driven program would be easier to use. No doubt.

NeilS

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 78
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #7 on: October 25, 2006, 09:52 PM »
Although I can understand the desire to have a small, fast app to provide this functionality, it's fairly easy to do with AHK, and I don't find AHK that much of a system hog anyway. Using AHK also has the advantage that you can do plenty of other things besides sending alternative keystrokes, if you need to.

I've just added a simple double tap feature to my default AHK script (which runs at startup and provides most of my global hotkeys). One nice thing about this is that it's one less tray icon to worry about, and also minimises the overhead of running multiple hotkey processes.

The code for this is pretty simple. Near the top of my script, I have the following function:

DoubleKey(key, timeout, sendKeys)
{
  global
 
  if(tapped%key% and (A_TickCount - tapTime%key% < timeout))
  {
    Send, %sendKeys%
    tapped%key% = 0
  }
  else
  {
    tapped%key% = 1
    tapTime%key% := A_TickCount
  }
}

And then to use it, I just create a hotkey which calls this function. For example, my FARR double tap hotkey is as follows:

Ctrl:: DoubleKey("ctrl", 500, "^!k")

The "^!k" is the CTRL+ALT+K key sequence I use to bring up FARR normally, and the 500 is the time allowed between the two taps in milliseconds - if you wait any longer before pressing CTRL again, it resets and you have to tap twice again.

The "crtl" is used by the function to distinguish between different double tap keys. For example, if I also set up a hotkey for a double tap of SHIFT, it's probably better if the state of the double tap is kept separate from the state of any CTRL double tap, so the "ctrl" is used as part of the state variable names. The SHIFT hotkey would use "shift" (or anything else, so long as it's different from "ctrl"). If you don't do this, then SHIFT followed quickly by CTRL would fire the CTRL sequence, as if CTRL had been pressed twice.

Interestingly, it might be possible to make use of this kind of sequence, e.g. SHIFT then CTRL could fire a different sequence from CTRL-CTRL or SHIFT-SHIFT, as could CTRL-SHIFT. My current script can't do this, but it should be possible.

The only thing I haven't managed to solve yet is using the left and right SHIFT/CONTROL keys separately. If you use the LCtrl/RCtrl/LShift/RShift hotkeys in AHK, there seems to be some sort of repetition happening, which causes the sequence to fire any time you hold those particular keys down. I'll see if I can fix that when I have more time, but the current code seems to work very well for the Ctrl, Shift and Alt hotkeys.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #8 on: October 25, 2006, 10:24 PM »
really nice work neil - i knew it would be easy in ahk, but that's quite impressive.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #9 on: October 26, 2006, 03:57 AM »
Cool work, NeilS. I think i'll be using that script pretty soon ;)
I love the way it's encapsulated into a neat function.

The only thing I haven't managed to solve yet is using the left and right SHIFT/CONTROL keys separately. If you use the LCtrl/RCtrl/LShift/RShift hotkeys in AHK, there seems to be some sort of repetition happening, which causes the sequence to fire any time you hold those particular keys down. I'll see if I can fix that when I have more time, but the current code seems to work very well for the Ctrl, Shift and Alt hotkeys.

If you feel it's ahk's fault, post ait at the ahk forum. I'm sure they'll be able to provide a solution or if there is no solution, they'll solve it on the next release. At least, that's how it's happened with me ;)

NeilS

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 78
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #10 on: October 26, 2006, 05:26 PM »
If you feel it's ahk's fault, post ait at the ahk forum. I'm sure they'll be able to provide a solution or if there is no solution, they'll solve it on the next release. At least, that's how it's happened with me ;)

I just tried a search there and found a solution, as well as a better way to do what I was trying to do. :)

It turns out that AHK provides useful built-in variables for the previous and current hotkey, as well as the time since the last hotkey. Using them, DoubleKey() turns into:

DoubleKey(sendKeys, timeout)
{
  if(A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < timeout)
    Send, %sendKeys%
}

Pretty nifty. In fact, there's not really much benefit to my nice, neat function any more. ;)

The problem with using separate left/right Ctrl/Alt/Shift can be solved by doing two things.

First, the "repeating key when held down" issue is strangely solved by making the hotkey respond to key-up events instead of key-down events - you can do this by putting " Up" in the hotkey name. This also seems to solve a problem I noticed when you make the timeout quite short (200ms or less), where the trigger sometimes wouldn't work - this seems to be related to which key you are using.

The other issue that was happening was that the LCtrl/RCtrl versions weren't allowing normal CTRL+key presses to get through to other apps. This is fixed by using the "~" modifier, which tells AHK to pass the hotkey to the underlying app rather than swallowing it completely. This shouldn't be necessary, since CTRL+key is a different key to CTRL on its own, and isn't for the non-left-right versions, but it seems to be necessary for the left-right variants.

So my hotkey for running FARR is now:

~RCtrl Up:: DoubleKey("^!k", 200)

One other thing I noticed (while typing this actually), is that setting SHIFT as a double tap key can be slightly problematic depending on how fast you type. For me, quoted strings seem to involve a quick shift to make the " and then a quick shift to make the capital letter or symbol following it. It seems that I quite often do this sequence in less than 500ms, so I've got my timeout set at 200ms now. It's amazing the things you find out about yourself sometimes. :)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #11 on: October 28, 2006, 02:30 PM »
im nearly done with taptap, should have a version out tonight.

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,119
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #12 on: October 28, 2006, 03:12 PM »
excellent.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #13 on: October 28, 2006, 10:09 PM »
taptap is done and fully working.
but i'm too tired to post it now and it probably needs a little bit of a help file, so i'll post it tomorrow.
but it does seem to work well, and you can map the following things to other hotkeys

doubletap LeftControl
doubletap RightControl
doubletap LeftShift
doubletap RightShift
doubletap LeftAlt
doubletap RightAlt
doubletap Insert
doubletap capslock
doubletap numlock
doubletap scrolllock

pause key

winkey+Key combinations


so all you crazy people who like double tapping to do stuff, now you should be in heaven..
and as promised, it is super super lightweight on cpu and memory.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #14 on: October 29, 2006, 08:47 AM »
I have finished "TapTap Hotkey Extender", or at least the first beta version.

Web Page: https://www.donation...er/TapTap/index.html
Forum Thread: https://www.donation...dex.php?topic=5971.0

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #15 on: October 29, 2006, 04:16 PM »
From the .ini file:
// double right shift to Control F1
keymap   DRS      :   F1

1) I don't understand this.  How does that get control-F1? Typo?
2) My keyboard has no winkey so;
  a) Do I have to remap another key (easy enough, I'm using XP) to get letters and numbers?
  b) If I do remap another key, which key will TapTap 'see'? 
      E.g., suppose I remap left-control to be winkey, does TapTap see l-ctrl or winkey?
TIA

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #16 on: October 29, 2006, 04:23 PM »
sorry, that's a typo.
to map it to Control F1 it would be:
keymap DRS : C+F1

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #17 on: October 29, 2006, 04:24 PM »
hotkey can't map left control to winkey (although i actually could add something like that in a future version - maybe map right control to winkey?)

so if you dont have a winkey, it means your options are limited to having taptap work with double presses of leftcontrol,rightcontrol,lefshift,rightshift,leftalt,rightalt,numlock,scrolllock, ins

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #18 on: October 29, 2006, 06:24 PM »
hotkey can't map left control to winkey (although i actually could add something like that in a future version - maybe map right control to winkey?)
so if you dont have a winkey, it means your options are limited
Sorry, I didn't explain myself clearly.
I posit using XP's ability to remap keys (not your utility).
First I would use that to remap, say, l-ctrl to be winkey.
Presume that I have done so, and that the system sees l-ctrl as winkey (I've remapped other keys to 'windows' keys successfully in the past)
Will TapTap now also see my remapped l-ctrl as winkey or will it still see it as l-ctrl?

I've only used l-ctrl as an example. It works just as well for me if it is, for example, r-alt.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #19 on: October 29, 2006, 06:52 PM »
well that's a great question.  i ASSUME it will see it as winkey - i.e. that windows will FIRST internally remap it as you say, and then pass it to my program, but there is only one way to know and that is to try :)

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #20 on: October 29, 2006, 08:16 PM »
there is only one way to know and that is to try
Oh, sure, leave me to do all the work.  :)

I have mapped my R-Alt key to Windows-key (not using your utility).
That remapped key won't behave as Windows-key with TapTap.  That's a shame because "letters&numbers can only be used with W".

Before you ask the obvious, I'm using Northgate OmniKey keyboards with my computers.  I've had these keyboards for at least 10 years and haven't found anything to match them in terms of durability and, most importantly, tactile feedback.  I'm not about to trade them for something with a windows key.  A phrase about "cold dead hands" springs to mind.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #21 on: October 29, 2006, 08:31 PM »
so does taptap see it as r-alt?
i mean i cant think of any reason i couldnt make taptap itself have an option that says to treat r-alt as winkey for its own private purposes.

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #22 on: October 29, 2006, 10:23 PM »
I set TapTap to use:
keymap      RA+F2      :   F1
that should work, right? It's pointless but I thought I'd use your example line from the config, just as a test.

That does nothing other than give me an 'available' beep (odd?) and open the start menu (due to R-Alt's role as winkey).
However I set R-Alt, it responds on key-up, not key down.  I'll have to dig around and recall by what means I set up R-Alt to be winkey.
Let me do some more checking...

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #23 on: October 29, 2006, 11:16 PM »
it sounds like as you say, taptap is seeing the right alt as right-alt, instead of as winkey.

this means that it is refusing to work with it.

taptap is not meant to detect things like alt+F2 and map them to something else.. i could add support for such things but right now taptap wont every try to catch alt combos or control combos, or shift combos.

it's really just designed now to catch NON-STANDARD hotkey events.

i use non-standard to mean the kind of hotkeys that many programs can't be configured to catch, like double taps of control/shift/alt, keys like pause, print, etc., and also the win+key combos that some programs can't be configured to use.

SO,
don't expect to use taptap to catch and re-map standard ctrl+key or alt+key combos.

in your case you've got this strange situation where you want alts to be winkeys.. 

i could probably pretty easily add some options/flags to do this once we decide it's something you and maybe others could benefit from..

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: Super Efficient Extended Hotkey Mapper
« Reply #24 on: October 30, 2006, 11:14 AM »
All I was really trying to do was find out if TapTap would see the (in fact, any) key that I remapped to winkey as winkey.  If not, I'm locked out of some TapTap potential as your config says "(letters&numbers can only be used with W)".  I don't want some esoteric conversion from one control key to another, that was just my trying to discover what would work on my own keyboard. 
I'm a long-time user of Macro Express, so I can do pretty much all I want with that.  Double-tapping is a nice addition.