Jump to content

HotKeySet


Recommended Posts

Why I cannot use enter key if I use it as hotkey in my script?

For example if I run this script and then I select a file from my desktop and I press ENTER, the file is not open.

HotKeySet("{ENTER}","Message")

While 1
    Sleep(20)
WEnd

Func Message()
    MsgBox(0,"","MESSAGE")
EndFunc

Can I solve this inconvenient someway?

When the words fail... music speaks.

Link to comment
Share on other sites

Why I cannot use enter key if I use it as hotkey in my script?

For example if I run this script and then I select a file from my desktop and I press ENTER, the file is not open.

HotKeySet("{ENTER}","Message")

While 1
    Sleep(20)
WEnd

Func Message()
    MsgBox(0,"","MESSAGE")
EndFunc

Can I solve this inconvenient someway?

Help

When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application

Link to comment
Share on other sites

Andreik

Solution:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

;HotKeySet("{ENTER}","Message")

Global $Active = False

$hGUI = GUICreate("My GUI", 300, 200)

GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    $Active = Not $Active
    
    If $Active Then
        HotKeySet("{ENTER}","Message")
    Else
        HotKeySet("{ENTER}")
    EndIf
    
    Return $GUI_RUNDEFMSG
EndFunc

Func Message()
    MsgBox(0,"","MESSAGE")
EndFunc
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...