Commands in MsgBox not working Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
RestartNub
Posts: 2
Joined: 22 Jan 2021, 10:21

Commands in MsgBox not working

Post by RestartNub » 22 Jan 2021, 10:40

Code: Select all

#!l::
{
    MsgBox 0x4, Always Top, Would you like to set window to AlwaysTop? 
        IfMsgBox Yes, {WinSet, AlwaysOnTop, On
        } Else IfMsgBox No, {WinSet, AlwaysOnTop, Off
}}
Whenever I press yes/no in msgbox the command doesn't run, this happens with any command in the msgbox. Anyone know a fix?
I just started using AutoHotkey like a week ago so I don't know that much about it.
User avatar
mikeyww
Posts: 5104
Joined: 09 Sep 2014, 18:38

Re: Commands in MsgBox not working  Topic is solved

Post by mikeyww » 22 Jan 2021, 10:53

Code: Select all

#!l::
WinGetActiveTitle, this
MsgBox, 262148, %this%, Would you like to set window to AlwaysOnTop?
IfMsgBox, Yes
 WinSet, AlwaysOnTop, On, A
Else WinSet, AlwaysOnTop, Off, A
Return
RestartNub
Posts: 2
Joined: 22 Jan 2021, 10:21

Re: Commands in MsgBox not working

Post by RestartNub » 22 Jan 2021, 10:59

ty the code works :D
User avatar
RaptorX
Posts: 71
Joined: 06 Dec 2014, 14:27
Facebook: e2c52f
GitHub: RaptorX
Contact:

Re: Commands in MsgBox not working

Post by RaptorX » 22 Jan 2021, 16:12

For future reference, and other people potentially having the same issue:

The reason the code was not working is because he didn't specify a window title on the winset command.
When you don't specify anything, the command will try to act on the "Last Found" Window which is tricky and in this example there was no last found window.

In the fixed code he added the "A" parameter which tells the command to be used on the active window.

Code: Select all

WinSet, AlwaysOnTop, On, A
Post Reply

Return to “Ask For Help”