AutoHotkey Community

It is currently May 27th, 2012, 12:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: February 1st, 2010, 1:46 pm 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
From the Help File

Quote:
Normally, the windows API function RegisterHotkey() is used to implement a keyboard hotkey whenever possible. However, the responsiveness of hotkeys might be better under some conditions if the keyboard hook is used instead.

Turning this directive ON is equivalent to using the $ prefix in the definition of each affected hotkey. The exception to this is Windows 95/98/Me, upon which #UseHook is ignored (though the $ prefix works in a limited fashion).

As with all # directives -- which are processed only once when the script is launched -- #UseHook should not be positioned in the script as though it were a command (that is, it is not necessary to have it contained within a subroutine). Instead, position it immediately before the first hotkey label you wish to have affected by it.

Hotkeys that use the keyboard hook cannot be triggered by means of the Send command. Similarly, mouse hotkeys cannot be triggered by commands such as Click because all mouse hotkeys use the mouse hook. To work around this, use Gosub to jump directly to the hotkey's subroutine. For example: Gosub #LButton

If this directive does not appear in the script at all, it will behave as though set to OFF.


Also

Quote:
The keyboard hook monitors keystrokes for the purpose of activating hotstrings and any keyboard hotkeys not supported by RegisterHotkey (which is a function built into the operating system). It also supports a few other features such as the Input command.

The keyboard hook is not supported under Windows 95/98/Me because those operating systems require a different type of hook that must reside in a DLL file.

AutoHotkey does not install the keyboard and mouse hooks unconditionally because together they consume at least 500 KB of memory. Therefore, the keyboard hook is normally installed only when the script contains one of the following: 1) hotstrings; 2) one or more hotkeys that require the keyboard hook (most do not); 3) SetCaps/Scroll/Numlock AlwaysOn/AlwaysOff; 4) the Input command, for which the hook is installed upon first actual use.

By contrast, the #InstallKeybdHook directive will unconditionally install the keyboard hook, which might be useful to allow KeyHistory to display the last 20 keystrokes (for debugging purposes), or to avoid the need for #HotkeyModifierTimeout.

You can determine whether a script is using the hook via the KeyHistory command or menu item. You can determine which hotkeys are using the hook via the ListHotkeys command or menu item.

This directive also makes a script persistent, meaning that ExitApp should be used to terminate it.




So it basically boils down to - There are some commands and hotkeys that won't work using the built in, Windows API function RegisterHotkey() so use #UseHook to forcefully install the more adavanced hook which will allow the commands.
The advanced Hook isn't in by default as it uses up more memory.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 10:35 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
More importantly, the keyboard hook allows the modifier keys and key-combinations to be tracked more accurately, especially during Send which normally disrupts the modifier keys.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 11:38 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
The manual?

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 7:51 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
Arlight.1 wrote:
@OceanMachine

Have you read nay of the posts in the thread?
I've created numerous scripts since my first post.
Right now I am still working on loops.


I apologise, I thought that the start of page 3 was the first post, didn't realise that there were 2 pages before that. Sorry.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, jrav and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group