Jump to content
Sign in to follow this  
Andreik

HotKeySet

Recommended Posts

Andreik

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
Andreik

Thanks rasim! I read now in help file and I saw that the Lock keys isn't captures. Is any way to create exceptions for other keys?


When the words fail... music speaks

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
Andreik

Work fine! Thank you very much. ;)


When the words fail... music speaks

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.