Jump to content
Sign in to follow this  
muhmuuh

Case...Select problem

Recommended Posts

muhmuuh

Hi!

I've created a program that creates GUI with 4 buttons - start,call,pause and stop but I have some problems with it. So here is what happens when Button_1 (start) is clicked

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Terminate()
        Case $msg = $Button_1
            While 1
                ToolTip('Program is running', 0, 0)
                $msg2 = GUIGetMsg()oÝ÷ Ù8^¶%¶*l¹Ç²ÇÃhÀÛhr'ÁºÛhzZºÇ¨®az¶î¶Ú'Ç%Éuh^"¶®¶­sdbb33c¶×6s"ÓÒb33c´'WGFöåó2FVà¢uT7G&Å6WDFFb33c´'WGFöåó2ÂgV÷C·&W7VÖRgV÷C²¢FövvÆUW6R¢uT7G&Å6WDFFb33c´'WGFöåó2ÂgV÷C·W6RgV÷C²¤VæF`oÝ÷ ÚØ^­æ«zz)®åzkºÒ7öYZuÙ¨­æî¶Ú'±©Ý!Ú'¢ÜÛh©Ü"¶¶§nëpØlzWµÆ¬zʺ-zØb±«­¢+ÙM±Ð($$$$%
ÍÀÌØíµÍÈôÀÌØíU%}Y9Q}
1=M($$$$$%Qɵ¥¹Ñ ¤($$$$%
ÍÀÌØíµÍÈôÀÌØí  ÕÑѽ¹|Ì($$$$$%U%
ÑɱMÑÑ ÀÌØí    ÕÑѽ¹|Ì°ÅÕ½ÐíÉÍÕµÅÕ½Ðì¤($$$$$%Q½±AÕÍ ¤($$$$$%U%
ÑɱMÑÑ ÀÌØí    ÕÑѽ¹|Ì°ÅÕ½ÐíÁÕÍÅÕ½Ðì¤($$$$%
ÍÀÌØíµÍÈôÀÌØí  ÕÑѽ¹|Ð($$$$$%á¥Ñ1½½À($$$$%
ͱÍ($$$$$%5Í    ½à À°ÅÕ½ÐíÅÕ½Ðì°ÅÕ½Ðí9½Ñ¡¥¹¡ÁÁ¹ÅÕ½Ðì

but it always goes to the case else part, no mather how many times I click the pause button and I don't see the reason for that. Can you help me?

Thanks


I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more.

Share this post


Link to post
Share on other sites
Blue_Drache

Works for me.

#include <GUIConstants.au3>
Global $bPause = False
_GUIRun()
Func _GUIRun()
    #Region ### START Koda GUI section ### Form=
    Local $Form2 = GUICreate("Form2", 413, 305, 265, 433)
    Local $btnPause = GUICtrlCreateButton("&Pause", 104, 24, 225, 105, 0)
    Local $btnExit = GUICtrlCreateButton("E&xit", 112, 200, 193, 89, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $btnExit
                Exit
            Case $btnPause
                _Pause()
                If $bPause Then
                    GUICtrlSetData($btnPause, "&Resume")
                Else
                    GUICtrlSetData($btnPause, "&Pause")
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>_GUIRun
Func _Pause()
    $bPause = Not $bPause
EndFunc   ;==>_Pause
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
Nahuel

Your messagebox: MsgBox(0, "a", "Nothing happened") reminds me of Homer's alarm. It would sound as long as everything is fine.

Of course that it'll always go to the case else part, because when you press the start button it enters the second loop and immediately goes to case else and the messagebox pauses the execution of the script. I doubt you are fast enough to beat it and press a button first.

Share this post


Link to post
Share on other sites
Blue_Drache

*smacks forehead* Yes, of course, don't put a Case Else in your GUI testing loop.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
muhmuuh

thanks for the help but I still can't fix it (maybe I didn't understand you)

I removed the case else but it still doesn't work

Here is more of my code

GUICreate("my gui", 270, 200)
GUISetState (@SW_SHOW)
$Button_1 = GUICtrlCreateButton("start", 10, 150, 50)
$Button_2 = GUICtrlCreateButton("call", 0, -1)
$Button_3 = GUICtrlCreateButton("pause", 0, -1)
$Button_4 = GUICtrlCreateButton("stop", 0, -1)
$Button_5 = GUICtrlCreateButton("settings", 0, -1)

Global $defaultstatus = "Ready"
Global $status

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Terminate()
        Case $msg = $Button_1
            While 1
                ToolTip('Program is running', 0, 0)
                $msg2 = GUIGetMsg()
                Select
                    Case $msg2 = $GUI_EVENT_CLOSE
                        Terminate()
                    Case $msg2 = $Button_3 ;here is what I want to happen
                        GUICtrlSetData($Button_3, "resume")
                        TogglePause() ;sleeps until it is clicked again
                        GUICtrlSetData($Button_3, "pause")
                    Case $msg2 = $Button_4
                        ExitLoop
                EndSelect
                somefunc()
            WEnd
        other cases...
    EndSelect
WEndoÝ÷ Úz0j¢§íz²)­ë,²Ö«µ»­¶íëh¢[b¥ªiyªìnëmé⵩pk+jYl²~éÜjwgz÷«¥«¬zƶæ¥+(ëbë"¶®±ë"|Ú¦'eÉÉbrKay»­¶ß¢»(ëbâ½éæi×­+ºÚ"µÍÛÛ
    ÌÎNÔÙÜ[HÈ[[ÉÌÎNË
BÙÐÞ
    ][ÝØI][ÝË   ][ÝÔÜÈ]ÙHÝÉ][ÝÊBÛY
Ì
BÌÍÛÙÌHÕRQÙ]ÙÊ

to give myself 3 seconds to press pause but again it dosent pauses

What am I doing wrong?


I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more.

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.