Jump to content

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

How to catch special application keys?


  • Please log in to reply
7 replies to this topic
halweg
  • Members
  • 127 posts
  • Last active: Jul 06 2015 06:54 AM
  • Joined: 27 Jan 2005
Looking at my (new) keyboard (Microsoft desktop) I see a lot of extra keys for special tasks: E-mail, Internet, Messenger, volume up and down a. s. o.
Why not use these keys instead of Alt-/Win-/CTRL-combinations. This way I could ban the special key functions from the "normal" keyboard. Instead I can use well pictured buttons above the normal keyboard. Using multiple key-presses gives the extended keys a very intuitively use:
Pressing the Internet-Button twice could start the preferred Search Engine, pressing it triple could open the list of recently visited Internet-Pages.
Pressing the E-Mail-Button twice could open a new mail to send.
Pressing the My Documents-Button twice or triple could open different folders for different live spheres.
Every application button could have multiple functions.

So far so good. The problem: Not all of those keys generates recognizable by HK events (e.g. Buttons like "Messenger", "My Documents", and "My Pictures"). But they can be assigned to commands (e.g. compiled scripts) using manufacturers software.

Is there a possibility to detect multiple key-presses of these buttons? I could imagine, that a special scripts fired by them will detect, if it is fired twice or triple in a short period of time.

Thanks, Uwe

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
Well, there is a way, but since disk access and running an executable twice in quick succession are already part of this, the end result will probably be quite slow. It would be better to choose an obscure option in the driver that you're not likely to reproduce manually, and then see if you can get AutoHotkey to recognize it without having to start a whole new script.

But, if you want to willingly skewer your CPU, here's the concept: (it's worked before)

If you right-click on a script's tray menu, and click Open, you'll see a gray window with various info about the script. What you might not know about this window is that it's always there, just hidden. So, you implement code at the top to check for this hidden window, and if it exists, you know that a different instance is already running, and you can act accordingly. #SingleInstance has to be turned off for this to work.

I want to emphasize one last time how inefficient and slow (relatively) this would be, but if it isn't going to be a problem for you, I can post some code that illustrates the concept.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Another longshot is to configure the manufacturer's software to send an alternate keystroke, if it's capable of doing that. Such a keystroke, such as Ctrl+F12, can be caught by a running script that has ^F12 defined as a hotkey.

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004

It would be better to choose an obscure option in the driver that you're not likely to reproduce manually,

configure the manufacturer's software to send an alternate keystroke,


In effect, we meant the same thing, but I see now mine was poorly worded. That's kind of what I meant, halweg.

halweg
  • Members
  • 127 posts
  • Last active: Jul 06 2015 06:54 AM
  • Joined: 27 Jan 2005
Thanks jonny and chris,
The keyboard that came with the MS Desktop uses the MS IntelliType Software. In difference to the mouse driver (IntelliPoint) it seems not to be possible to assign the application keys directly to keystrokes. :( They can be assigned to commands only (like "Close" "New").
Following jonny I explored the MS IntelliType software. I detected a file named commands.xml. It's a big one, but it shows the manner how internal commands may be assigned to Keystrokes. That’s very complex, because there are quite a lot of assignments for every country and every application.
The most interesting part of that file seems to be that:

	<ALL>
		<Application UniqueName="StandardSupport">
			<C309 Type="5" KeySeq="ctrl F4" />
			<C201 Type="5" KeySeq="ctrl c" />
			<C200 Type="5" KeySeq="ctrl x" />
			<C301 Type="5" KeySeq="alt F4" />
			<C302 Type="5" KeySeq="F1" />
			<C202 Type="5" KeySeq="ctrl v" />
			<C203 Type="5" KeySeq="ctrl z" />
			<C205 Type="5" KeySeq="delete" />
			<C100 Type="5" KeySeq="alt leftarrow" />
			<C101 Type="5" KeySeq="alt rightarrow" />
			<C103 Type="5" KeySeq="escape" />
			<C300 Type="5" KeySeq="enter" />
			<C319 Type="6" Activator="ZoomIn" />
			<C320 Type="6" Activator="ZoomOut" />			
			<C1101 Type="6" Activator="HorizontalScroll" />
			<C1003 Type="7" Subtype="0" />
		</Application>
The numbers at the beginning of the lines (i.e. C309) are the internal command codes (in this example "Close"). These commands can be assigned to application buttons by the IntelliPoint GUI or directly in the registry.
The most important thing: the keystrokes written in that file can be recognized by AHK. When assigning the C200 command ("Cut") to the messenger button, pressing that button will generate the CTRL and X press up and down events.
A2  01D	 	d	3.50	STRG           	
58  02D	 	d	0.00	X              	
58  02D	 	u	0.00	X              	
A2  01D	 	u	0.00	STRG   
I tried it out – multiple presses are recognizable :D . Long presses not :? (probably because the generated key presses contains key up events without a time shift, the key up event follows directly the key down event, regardless if I still hold down the key).
That seems to be a problem with all application keys; the Volume_Mute key can't be recognized as a long press too.
It remains to spend some brain work in finding free keystrokes and commands to be free assigned. 8)

Uwe

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Another thing you might consider is disabling or removing the IntelliType software. There is a chance that this will allow a script to see more of the special keys/buttons. This operates under the theory that IntelliType intercepts some of the keystrokes and hides them from AutoHotkey and the rest of the system.

halweg
  • Members
  • 127 posts
  • Last active: Jul 06 2015 06:54 AM
  • Joined: 27 Jan 2005
I tried this out before. There's no better event catching without the IntelliType software installed! But I'm not sure if uninstalling the IntelliType Software cleans my computer from all resident keyboard drivers.
It seems like the special application keys that are not listed in the AHK-Help don't generate events.
Uwe

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks for reporting your findings.