AutoIt Hotkeyset function _autoit

Source: Internet
Author: User
Tags reserved

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

Parameters

Hotkey The hotkey to be set is the same as the key format used by the Send () function.
The name of the function [Optional parameters] The name of the function to invoke when the hotkey is pressed. Leave blank to undo the previously set hotkey.

return value

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

Attention

Each script program can register up to 64 hot keys at the same time.

If two autoit scripts have the same hotkey set, you should avoid running both scripts (otherwise the second script will not be able to capture the hotkey unless the first script terminates running or the conflicting hotkey is revoked before the second script sets the hotkey).

After the user presses the hot key, * usually * interrupts the current running AutoIt function/statement and runs the user function associated with the hotkey until it completes or is interrupted. There are, of course, some exceptions:
1 if the current (running) function is a "blocking" (blocking) function, the keystroke action is buffered and waits for the blocking function to complete the operation before continuing. MsgBox and Fileselectfolder are typical blocking functions. You can try the hotkey shift-alt-d defined in the following sample script.
2 If you select the pause script on the AutoIt tray menu, any hotkey pressed during the pause will be ignored.

Unable to set hotkey:

Ctrl+alt+delete Reserved by Windows
F12 is also reserved by Windows, involving APIs.
Enter (enter) key on keypad Use {Enter} to capture the return key on both the main keyboard and the keypad
Win+b,d,e,f,l,m,r,u; and Win+shift+m These are the shortcuts that are built into Windows. Note: Win+b and win+l are reserved only by Windows XP systems above.
Alt, Ctrl, Shift, Win These are the auxiliary buttons!
Other Any global hotkey defined by a third party software, any hotkey consisting of two or more "base keys" (such as ' {F1}{F2} '), any type such as ' {Lalt} ' or ' {Altdown} '.

When a hotkey is set, AutoIt attempts to capture the specified key event but does not pass it to the activation program, but there is one exception: pressing the Lock key (including NumLock, CapsLock, and ScrollLock) will toggle its state at all times! If you want to send the captured hotkey event to the activation program, you must first log off the hotkey and then call SendOr ControlsendFunction:

; Capturing and passing key events
Hotkeyset ("{ESC}", "Captureesc")
Func Captureesc ()
; ... Here you can define the various tasks to be done
Hotkeyset ("{ESC}")
Send ("{ESC}")
Hotkeyset ("{ESC}", "Captureesc")
Endfunc


Related

Send, Controlsend

Example


; Press ESC to terminate the script, press Pause/break to pause

Global $Paused
Hotkeyset("{PAUSE}", "Togglepause")
Hotkeyset("{ESC}", "Terminate")
Hotkeyset("+!d", "ShowMessage"); Shift-alt-d

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

FuncTogglepause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip(' The script has been paused ',0,0     wend
    tooltip (
endfunc

func Terminate ()
    exit 0
endfunc

func Showmessage Span class= "S0" >    msgbox4096,< Span class= "S7" "" ," 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.