Bert

Odd behavior with Switch

5 posts in this topic

Can someone check this please? According to the help file I should be able to nest an expression. However when I run this script it will run UNTIL I move my mouse then it exits. 

#include <Process.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <String.au3>
#include <TrayConstants.au3>
#include <WinAPIFiles.au3>
DIM $button1, $button2

WindowXX()
While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE or $button2
            _exit()
;~       Case $button2
;~          _exit()
      EndSwitch
WEnd


Func WindowXX()
    $hGUI = GUICreate("Launcher", 270, 190,-1,-1,-1,$WS_EX_TOPMOST )
    $button1 = GUICtrlCreateButton("Launch",195, 40, 50, 20)
    $button2 = GUICtrlCreateButton("Exit",195, 100, 50, 20)
    GUISetState(@SW_SHOW, $hGUI)
 EndFunc

func _exit()
    Exit
EndFunc

 

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

While 1
        $iMsg = GUIGetMsg() ; -> mouse move $iMsg = -11
      Switch $iMsg
          Case $GUI_EVENT_CLOSE or $button2 ; -> -3 OR 4 = True
              ConsoleWrite($iMsg & "/" & $GUI_EVENT_CLOSE & "/" & $button2 & @CRLF)
              ConsoleWrite($GUI_EVENT_CLOSE or $button2 & @CRLF)
            _exit()
;~       Case $button2
;~          _exit()
      EndSwitch
WEnd

$iMsg = -11 which is <> 0 and thus = True

Case $GUI_EVENT_CLOSE or $button2 ; -> -3 OR 4 = True

Thus it will switch into the case condition!

 

As @Danyfirex already said, the OR condition of the values is a comma ->

Case $GUI_EVENT_CLOSE, $button2

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

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