> > Edited: Notice for other newbies (like me):
> > Please note that my script showed below is a nonsense!
> > #If cannot be used in such a way!
In this demo code an action should be started by click on a gui called Cover.
If this is coded with an #If WinActive("Cover") line, the action is started correctly, of course, by clicking on Cover.
However, if there is another gui defined in this script - Other -, the same action is started by clicking on Other!!!
For me as newbie a surpising behavior.
In this demo script clicking on Cover starts a sound and a tooltip with information on active window, clicking on Other only should display a tooltip (but ...).
WinGet, IdExplorer, ID, ahk_class CabinetWClass Gui Cover: New, +HwndIdCover Gui Cover: +Owner%IdExplorer% Gui Cover: -dpiscale ;-Caption 0x400000 Gui Cover: Color, green Gui Cover: Show, x100 y100 w400 h400, Cover WinSet, Transparent, 220, ahk_id %IdCover% Gui Other: Add, Text, x0 y0 w350 h50 gOther Gui Other: Show, x700 y100 w350 h50, Other OnMessage(0x202, "OnClickUp") RETURN Other: WinGetTitle, Window, A ToolTip Other clicked & no sound!`r`nCurrently active: `r`nWindow: %Window% return OnClickUp() { global #If WinActive("Cover") WinGetTitle, Window, A ToolTip Cover clicked & sound!!!`r`nCurrently active: `r`nWindow: %Window% SoundPlay, *48 SetTimer, RemoveToolTip, 1500 #If } RemoveToolTip: ToolTip SetTimer, RemoveToolTip, Off return
Can somebody explain the reason for this behavior?
(If I replace the #If method by If WinActive("Cover") { ... }, there is no more this surprising effect.)