Jump to content
Sign in to follow this  
Suppir

How to set hotkeys to work only in AutoIt GUI?

Recommended Posts

Suppir

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?

Share this post


Link to post
Share on other sites
Yashied
ProgAndy

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

Share this post


Link to post
Share on other sites
Suppir

Oh, very thanks! Now I understand, that I was trying to use accelerators in wrong way. The problem is completely solved!

Edited by Suppir

Share this post


Link to post
Share on other sites
Yashied

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

Share this post


Link to post
Share on other sites
Suppir

Another way.

Thank's a lot, Yashied. I will try it.

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  

×