Jump to content
Sign in to follow this  

HotKeySet and application capturing the hotkey

Recommended Posts


I have a simple script like this:

; Press Pause/Break to terminate

#Include <Clipboard.au3>

#Include <Math.au3>

Global $Paused

HotKeySet("{PAUSE}", "Terminate")

HotKeySet("{BREAK}", "Terminate")

HotKeySet("!{F2}", "CopyToClipboard")

HotKeySet("!{F3}", "PasteProperCase") ;

; Do nothing until special key is pressed.

While 1



; Handle special keys.

Func Terminate()

Exit 0


Func CopyToClipboard()

Send ("^c")


Func PasteProperCase()

; Read what's on the clipboard

$CopiedData = StringLower(_ClipBoard_GetData())

; Proper case the string

$CopiedData = StringReplace($CopiedData, "_", " ")

$CopiedData = StringRegExpReplace($CopiedData, "\b", "\+")

$CopiedData = StringReplace($CopiedData, " ", "_")

; Paste

Send ($CopiedData)


Two problems: no matter what key or key combination I use for the hotkey, the application I am in might have that hotkey registered for its own use. I thought that AutoIt would capture any hotkey (except the documented ones like F12) and it was up to me to send the key on to the application if I felt like it.

In particular, SQL Server 2008 Management Studio has a bunch of F keys assigned. I want to use unescaped F keys for my purposes. In some applications, you can un-set their hotkeys yourself, but that is tedious if you want ot use Auto-It regardless of which app has focus.

The second issue is that if I use a modfier with hotkey (Alt or Ctrl), when the script starts, AND after the script is finished, Windows still thinks the modifier key is held down. In fact, any keys that were sent with Send would be "Sent" with the modifier key still pressed. Things I typed after the script exited would act as if the key was pressed. I have to press and release the Alt or Ctrl key to get Windows straightened out.

Do I need to un-set the modifier key myself? I had some scripts that sent Alt-Up at their start, but that SHOULD not be necessary (IMHO) and it didn't always work right anyway.

Item 2.5: The hotkeys will be captured during the sleep, right?

OS is Windows 7 Ultimate, 64-bit, relatively standard.

Thanks for any advice. Great product.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.