Autoit hotkeyset Function

Source: Internet
Author: User

Hotkeyset ("hotkey" [, "function name"])

Parameters

Hotkey The hotkey to be set,The key format is the same as that used by the send () function.
Function Name [Optional parameter] Name of the function to be called after pressing the hot key. If this parameter is left blank, the previously set Hot Key is revoked.

Return Value

Successful: The return value is 1.
Failed: The return value is 0.

Note:

Each scriptProgramUp to 64 hotkeys can be registered simultaneously.

If two autoit scripts have the same hotkeys, you should avoid running these two script programs at the same time (otherwise the second script will not be able to capture the hotkeys, except that the first script stops running or the conflicting Hot Key is revoked before the Second Script sets the hot key ).

After you press the hot key, * normally * the currently running autoit function/statement is interrupted, and the user function associated with the hot key is run until the operation is completed or interrupted. Of course there will be some exceptions:
1) if the current (running) function is a "blocking" function, the key-click action will be buffered and will not continue until the blocking function completes the operation. Msgbox and fileselectfolder are typical blocking functions. You can try the hotkey shift-alt-D defined in the following example script.
2) if you select the pause script on the autoit tray menu, any hot keys that are pressed during the pause will be ignored.

Hot keys that cannot be set:

CTRL + ALT + Delete Reserved by Windows
F12 It is also retained by windows and involves APIs.
Enter on the keypad Use {enter} to capture both the primary key and the Enter key on the keypad.
Win + B, D, E, F, L, M, R, U; and win + Shift + m These are built-in windows shortcut keys. Note: Windows + B and Windows + L are reserved only for Windows XP and later systems.
ALT, Ctrl, shift, win These are auxiliary buttons!
Others Any global hotkeys defined by third-party software, any hotkeys consisting of two or more "base keys" (for example, '{F1} {F2 }'), any type such as '{lalt}' or '{altdown.

After a hot key is set, autoit will try to capture the specified key event but will not pass it to the activation program, but there is also an exception: press the lock key (including numlock, capslock, and scrolllock) to switch its status at any time! If you want to send the captured hotkey event to the activation program, you must cancel the hotkey before callingSendOrControlsendFunction:

; Capture and pass button events
Hotkeyset ("{ESC}", "captureesc ")
Func captureesc ()
;... Various tasks can be defined here
Hotkeyset ("{ESC }")
Send ("{ESC }")
Hotkeyset ("{ESC}", "captureesc ")
Endfunc

Related

Send, controlsend

Example

Press ESC to terminate the script, and press pause/break to pause"

global $ paused
hotkeyset ( " {pause} " , "togglepause" )
hotkeyset (< /Span> " {ESC} " , "Terminate" )
hotkeyset ( "+! D " , "showmessage" ) ; shift-alt-D

; Here is the Program subject ;;;;
While 1
Sleep(100)
Wend
;;;;;;;;

Func Togglepause ()
$ Paused = Not $ Paused
While $ Paused
Sleep ( 100 )
Tooltip ( 'The script has been paused "' , 0 , 0 )
Wend
Tooltip ( "" )
Endfunc

FuncTerminate()
Exit 0
Endfunc

FuncShowmessage()
Msgbox(4096,"","This is a dialog box. ")
Endfunc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.