Jump to content

How to set hotkeys to work only in AutoIt GUI?


Suppir
 Share

Recommended Posts

I have created hotkeys for my AutoIt application. These hotkeys run some functions. But if I activate another application (notepad), my AutoIt hotkeys working in this Notepad (causes some problems). How to restrict Autoit hotkey to set them working only if AutoIt application is active?

Link to comment
Share on other sites

use GUICtrlCreateDummy and associate the function with the Dummy-Control :)

#include <GUIConstants.au3>

#region - GUI Create
GUICreate('test')
GUICtrlCreateLabel("Press ALT-A", 10, 10, 100, 30)
$iDummy = GUICtrlCreateDummy()

Dim $aAccel[1][2] = [ ["!a", $iDummy ]]
GUISetAccelerators($aAccel)
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $iDummy
            MsgBox(0, '', "Accelerator pressed")
    EndSelect
WEnd
#endregion

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Another way.

$hForm = GUICreate('MyGUI')
HotKeySet('^a', '_MyHotKeyFunc')
GUISetState()

Do
Until GUIGetMsg() = -3

Func _MyHotKeyFunc()
    If BitAND(WinGetState($hForm), 8) Then
        MsgBox(0, '', 'CTRL-A is pressed!')
        Return
    EndIf
    HotKeySet('^a')
    Send('^a')
    HotKeySet('^a', '_MyHotKeyFunc')
EndFunc   ;==>_MyHotKeyFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...