Jump to content

MsgBox overrides HotKeySet


Go to solution Solved by bogQ,

Recommended Posts

Posted

Calling MsgBox inside the HotkeySet invokes an MsgBox right after the start of the script and no HotKey is registered, but the script can run:

HotKeySet("!y", MsgBox (0, "It's working!", "You pressed alt y"))   ; yes working
While 1
    Sleep (1000)
WEnd

I've already found the correct syntax:

HotKeySet("{ESC}", "Terminate")
Func Terminate()
        Exit
EndFunc

But still curious if it's a bug or whether is there an option to call a built-in function directly in the HotKeySet().

Posted
11 minutes ago, antai said:

no HotKey is registered, but the script can run

output console say: False--> SetHotKey Restart failed, SetHotKey Stop failed.

Βut yes the script is running!

 

I know that I know nothing

  • Solution
Posted (edited)
On 1/13/2023 at 10:33 PM, antai said:

Calling MsgBox inside the HotkeySet invokes an MsgBox right after the start of the script and no HotKey is registered, but the script can run:

HotKeySet("!y", MsgBox (0, "It's working!", "You pressed alt y"))   ; yes working
While 1
    Sleep (1000)
WEnd

I've already found the correct syntax:

HotKeySet("{ESC}", "Terminate")
Func Terminate()
        Exit
EndFunc

But still curious if it's a bug or whether is there an option to call a built-in function directly in the HotKeySet().

No due that HotKeySet second parrametar expect to be a "string" with function name in it.

MagBox dont return string but your custom funcs can return it.

HotKeySet("{F10}", testFunc()) 
While 1
    Sleep (1000)
WEnd

Func testFunc()
    return "callMsgBox"
EndFunc

Func callMsgBox()
    MsgBox (0, "It's working!", "You pressed F10")
EndFunc

but then why all the trouble when this is always easier

HotKeySet("{F10}", "testFunc") 
While 1
    Sleep (1000)
WEnd

Func testFunc()
    MsgBox (0, "It's working!", "You pressed F10")
EndFunc

 

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

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
  • Recently Browsing   0 members

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