Jump to content

Compound Select Case


 Share

Recommended Posts

This isn't giving me a message box, at all. Im using ...

Do

   $msg = GUIGetMsg(1)
    Select 

Case $msg[0] = $PFStartButton Or $msg[0] = $PFMenuStart And $msg[1] = $PFGUI
            If not @error Then
            MsgBox(1, "", "1")
            Else
            MsgBox(1, "", "0")
            Endif

            
    EndSelect       
    
    Until $msg[0] = $GUI_EVENT_CLOSE

Its for a MUCH larger script, and I was able to narrow it down to this as the problem. Any help would be greatly appreciated! =)

Edited by inline853
Link to comment
Share on other sites

I have no idea what you are trying to do.. but apparently you are working with multiple GUI's.

This is what I guessed you are doing:

#include <GUIConstants.au3>

$PFGUI = GUICreate("Gui", 230, 267, 200,200)

$PFMenuStart= GUICtrlCreateButton("MenuStart", 16, 64, 193, 57, 0)
$PFStartButton = GUICtrlCreateButton("Start", 16, 136, 193, 57, 0)
GUISetState(@SW_SHOW)
$PFGUI_1 = GUICreate("Gui - child", 230, 267, -1, -1,-1,-1,$PFGUI)
$PFMenuStart_1= GUICtrlCreateButton("MenuStart", 16, 64, 193, 57, 0)
$PFStartButton_1 = GUICtrlCreateButton("Start", 16, 136, 193, 57, 0)
GUISetState(@SW_SHOW)
Do
$msg = GUIGetMsg(1)
    Select 
        Case ($msg[0] = $PFStartButton Or $msg[0]=$PFMenuStart) And $msg[1] = $PFGUI
            If not @error Then
            MsgBox(1, "", "1")
            Else
            MsgBox(1, "", "0")
            Endif
    EndSelect     
Until $msg[0] = $GUI_EVENT_CLOSE

This shows you the message boxes. Maybe you are using the same variable for the buttons in the GUI's... but as I said, I don't know what you are trying to do. You should post the rest of the code.

Link to comment
Share on other sites

im just frusterated becaus eI have an almost identical portion of the script that works flawlessly. except when i post the whole thing everyone getss angry, i understand why, but its a catch 22 for me.

I would suggest a very thorough look at your two parts of code then... compare every word to see what's different and you might figure out why one works and one doesn't.
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

You also need to look at your order of operations with this line:

Case $msg[0] = $PFStartButton Or $msg[0] = $PFMenuStart And $msg[1] = $PFGUI

Use parentheses to enforce this.

Do you want:

Case ($msg[0] = $PFStartButton Or $msg[0] = $PFMenuStart) And $msg[1] = $PFGUI

- OR -

Case $msg[0] = $PFStartButton Or ($msg[0] = $PFMenuStart And $msg[1] = $PFGUI)

Link to comment
Share on other sites

that didn't change anything.

but I'm going to broaden the search. If anyone can find anything with this function, then you are a god.

#Region ;POWER FISHER FUNCTIONS
Func POWERFISHER()
    Do
        WinSetOnTop($PFGUI, "", 1)

        HotKeySet("^z", "PFStart")
        HotKeySet("^x", "PFStop")
        HotKeySet("^a", "PFMove")
        HotKeySet("^q", "PFSmallMove")
        HotKeySet("^w", "PFHideBoth")
        HotKeySet("^s", "PFShowBoth")
        HotKeySet("!^x", "Abort")

        $PFdata = PixelSearch($PFsmallx, $PFsmally, $PFsmallx + $PFSmallScanWidth, $PFsmally + $PFSmallScanHeight, $PFDropColor, $PFSens)
        If $PFdata <> 1 Then
            PFDrop()
        EndIf

        $msg = GUIGetMsg(1)
        Select

            Case $msg[0] = $PFStartButton Or $msg[0] = $PFMenuStart Or $msg[0] = $PFMenuHotKeyStart And $msg[1] = $PFGUI
                PFStart()

            Case $msg[0] = $PFStopButton Or $msg[0] = $PFMenuStop Or $msg[0] = $PFMenuHotKeyStop
                PFStop()

            Case $msg[0] = $PFSelection And $msg[1] = $PFGUI
                PFHideBoth()
                GUISetState(@SW_HIDE, $PFGUI)
                GUISetState(@SW_SHOW, $SELECTGUI)
                Selection()

            Case $msg[0] = $PFMenuExit And $msg[1] = $PFGUI
                $Exitbox = MsgBox(36, "Would you like to quit?", "Select 'Yes' to quit, otherwise click 'No'")
                If $Exitbox = 6 Then
                    Exit
                EndIf

            Case $msg[0] = $PFMenuMoveFishFinder And $msg[1] = $PFGUI
                PFMove()

            Case $msg[0] = $PFMenuMoveDropFinder And $msg[1] = $PFGUI
                PFSmallMove()

            Case $msg[0] = $PFMenuHotKeySmallMove And $msg[1] = $PFGUI
                PFSmallMove()

            Case $msg[0] = $PFMenuResizeFishFinder And $msg[1] = $PFGUI
                PFResize()
                PFHide()

            Case $msg[0] = $PFMenuHideFishFinder And $msg[1] = $PFGUI
                PFHide()

            Case $msg[0] = $PFMenuHideDropFinder And $msg[1] = $PFGUI
                PFSmallHide()

            Case $msg[0] = $PFMenuHotKeyHide And $msg[1] = $PFGUI
                PFHideBoth()

            Case $msg[0] = $PFMenuHotKeyShow And $msg[1] = $PFGUI
                PFShowBoth()

            Case $msg[0] = $PFMenuChooseColorsFishByColor And $msg[1] = $PFGUI
                PFFishFindChooseColor()

            Case $msg[0] = $PFMenuChooseColorsDropByColor And $msg[1] = $PFGUI
                PFDropFindChooseColor()

            Case $msg[0] = $PFT1[0] And $msg[1] = $PFGUI
                $PFSleepCheck = 200
            Case $msg[0] = $PFT1[1] And $msg[1] = $PFGUI
                $PFSleepCheck = 500
            Case $msg[0] = $PFT1[2] And $msg[1] = $PFGUI
                $PFSleepCheck = 1000
            Case $msg[0] = $PFT1[3] And $msg[1] = $PFGUI
                $PFSleepCheck = 2000
            Case $msg[0] = $PFT1[4] And $msg[1] = $PFGUI
                $Input = Number(InputBox("Custom Checking Time", "How many ms do you want to wait? (1000ms = 1sec)", $PFSleepCheck, "", 200, 162, $PFx + 111, $PFy))
                If (Not @error) And (IsNumber($Input)) And ($Input <> 0) Then
                    $PFSleepCheck = Round($Input)
                Else
                    $PFSleepCheck = 500
                EndIf
            Case $msg[0] = $PFT2[0] And $msg[1] = $PFGUI
                $PFSleepMine = 1000
            Case $msg[0] = $PFT2[1] And $msg[1] = $PFGUI
                $PFSleepMine = 2000
            Case $msg[0] = $PFT2[2] And $msg[1] = $PFGUI
                $PFSleepMine = 4000
            Case $msg[0] = $PFT2[3] And $msg[1] = $PFGUI
                $PFSleepMine = 6000
            Case $msg[0] = $PFT2[4] And $msg[1] = $PFGUI
                $Input = Number(InputBox("Custom Mining Time", "How many ms do you want to wait? (1000ms = 1sec)", $PFSleepMine, "", 200, 162, $PFx + 111, $PFy))
                If (Not @error) And (IsNumber($Input)) And ($Input <> 0) Then
                    $PFSleepMine = Round($Input)
                Else
                    $PFSleepMine = 4000
                EndIf

            Case $msg[0] = $PFMenuInstructions And $msg[1] = $PFGUI
                $var = FileExists("ReadMe.txt")
                If $var = 1 Then
                    ShellExecuteWait("ReadMe.txt")
                Else
                    SplashTextOn("Error:", "File Not Found! You must have deleted it!", 200, 300)
                EndIf
            Case $msg[0] = $PFDropColorDisplay And $msg[1] = $PFGUI
                PFDropFindChooseColor()
            Case $msg[0] = $PFCurrentColorDisplay And $msg[1] = $PFGUI
                PFFishFindChooseColor()

        EndSelect

    Until $msg[0] = $GUI_EVENT_CLOSE

EndFunc   ;==>POWERCUTTER
;
;
;
;

Func PFStart()
    PFShowBoth()
    PFCheck()
    PFSetBothColor()

EndFunc   ;==>PFStart

Func PFStop()
    PFHideBoth()
    PFReSetColor()
    AdlibDisable()
    GUICtrlSetData($PFLabelStatus, "Stopped")

EndFunc   ;==>PFStop

Func PFCheck()

    Sleep(Random(0, 500, 1))

    $PFPixel = PixelSearch($PFx + 2, $PFy, $PFx + 2 + $PFScanWidth, $PFy + $PFScanHeight, $PFCurrentColor, $PFSens)

    If Not @error Then

        MouseClick("Left", $PFPixel[0], $PFPixel[1], 1, 2)
        GUICtrlSetData($PFLabelStatus, "Mining")
        $PFIdle = 0
        AdlibEnable("PFCheck", $PFSleepMine)

    Else

        GUICtrlSetData($PFLabelStatus, "Checking")
        $PFIdle += $PFSleepCheck
        If $PFIdle >= 60000 Then
            MouseClick("Left")
            $PFIdle = 0
        EndIf

        AdlibEnable("PFCheck", $PFSleepCheck)
    EndIf

    GUICtrlSetData($PFLabelCheckInterval, "" & $PFSleepCheck / 1000 & " Seconds")
    GUICtrlSetData($PFLableFishInterval, "" & $PFSleepMine / 1000 & " Seconds")


EndFunc   ;==>PFCheck

Func PFSetColor()
    GUICtrlSetBkColor($PFCurrentColorDisplay, $PFCurrentColor)
EndFunc   ;==>PFSetColor

Func PFSetDropColor()
    GUICtrlSetBkColor($PFDropColorDisplay, $PFCurrentDropColor)
EndFunc   ;==>PFSetDropColor

Func PFSetBothColor()
    GUICtrlSetBkColor($PFCurrentColorDisplay, $PFCurrentColor)
    GUICtrlSetBkColor($PFDropColorDisplay, $PFCurrentDropColor)
EndFunc   ;==>PFSetBothColor

Func PFReSetColor()
    GUICtrlSetBkColor($PFCurrentColorDisplay, 0x000000)
    GUICtrlSetBkColor($PFDropColorDisplay, 0x000000)
EndFunc   ;==>PFReSetColor

Func PFDrop()
    $PFdata = PixelSearch($PFsmallx, $PFsmally, $PFsmallx + $PFSmallScanWidth, $PFsmally + $PFSmallScanHeight, $PFDropColor, $PFSens)
    GUICtrlSetData($PFLabelStatus, "Droping Fishs")
    $PFIdle = 0


    ;Searches the Inventory for the Drop Color
    $PFpos = PixelSearch(810, 350, 990, 570, $PFDropColor, $PFSens)
    ;Makes $pos an Array
    If IsArray($PFpos) Then
        ;Moves Mouse to the Fish that was detected
        MouseMove($PFpos[0], $PFpos[1])
        ;Right Clicks the Fish
        MouseClick("right", $PFpos[0], $PFpos[1])
        ;Left Clicks the D
        ;Moves the Mouse Down to the Drop Option
        MouseMove($PFpos[0], $PFpos[1] + 45)
        ;Left Clicks the Drop Option
        MouseClick("left", $PFpos[0], $PFpos[1] + 45)
        ;Left Clicks the D
    EndIf

    AdlibEnable("PFCheck", $PFSleepDrop)

EndFunc   ;==>PFDrop

Func PFMove()

    PFShow()

    ;Loops while user moves the Scan Screen.
    While 1
        ;Sets a Variable equal to the Mouse Position
        $PFMousePos = MouseGetPos()

        ;Moves the Sides of the Scan Screen to the Mouse Position
        WinMove($PFTop, "", $PFMousePos[0], $PFMousePos[1])
        WinMove($PFLeft, "", $PFMousePos[0], $PFMousePos[1])
        WinMove($PFRight, "", $PFMousePos[0] + $PFScanWidth - 2, $PFMousePos[1])
        WinMove($PFBottom, "", $PFMousePos[0], $PFMousePos[1] + $PFScanHeight)

        ;Sets the scan Screens Current Position to its New Position
        $PFx = $PFMousePos[0]
        $PFy = $PFMousePos[1]

        ;When the Left Mouse Button is released the Loop ends.
        If _IsPressed(01) Then
            ;Deletes the Box around the Scan Screen
            Sleep(1000)
            PFHide()
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>PFMove

Func PFSmallMove()

    PFSmallShow()

    ;Loops while user moves the Scan Screen.
    While 1
        ;Sets a Variable equal to the Mouse Position
        $PFMousePos = MouseGetPos()

        ;Moves the Sides of the Scan Screen to the Mouse Position
        WinMove($PFsmallTop, "", $PFMousePos[0], $PFMousePos[1])
        WinMove($PFsmallLeft, "", $PFMousePos[0], $PFMousePos[1])
        WinMove($PFsmallRight, "", $PFMousePos[0] + $PFSmallScanWidth - 2, $PFMousePos[1])
        WinMove($PFsmallBottom, "", $PFMousePos[0], $PFMousePos[1] + $PFSmallScanHeight)

        ;Sets the scan Screens Current Position to its New Position
        $PFsmallx = $PFMousePos[0]
        $PFsmally = $PFMousePos[1]

        ;When the Left Mouse Button is released the Loop ends.
        If _IsPressed(01) Then
            ;Deletes the Box around the Scan Screen
            Sleep(1000)
            PFSmallHide()
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>PFSmallMove

Func PFHide()

    Sleep(1000)
    GUISetState(@SW_HIDE, $PFTop)
    GUISetState(@SW_HIDE, $PFBottom)
    GUISetState(@SW_HIDE, $PFLeft)
    GUISetState(@SW_HIDE, $PFRight)

EndFunc   ;==>PFHide

Func PFSmallHide()

    Sleep(1000)
    GUISetState(@SW_HIDE, $PFsmallTop)
    GUISetState(@SW_HIDE, $PFsmallBottom)
    GUISetState(@SW_HIDE, $PFsmallLeft)
    GUISetState(@SW_HIDE, $PFsmallRight)

EndFunc   ;==>PFSmallHide

Func PFHideBoth()

    Sleep(1000)
    GUISetState(@SW_HIDE, $PFTop)
    GUISetState(@SW_HIDE, $PFBottom)
    GUISetState(@SW_HIDE, $PFLeft)
    GUISetState(@SW_HIDE, $PFRight)

    GUISetState(@SW_HIDE, $PFsmallTop)
    GUISetState(@SW_HIDE, $PFsmallBottom)
    GUISetState(@SW_HIDE, $PFsmallLeft)
    GUISetState(@SW_HIDE, $PFsmallRight)

EndFunc   ;==>PFHideBoth

Func PFShow()

    GUISetState(@SW_SHOW, $PFTop)
    GUISetState(@SW_SHOW, $PFBottom)
    GUISetState(@SW_SHOW, $PFLeft)
    GUISetState(@SW_SHOW, $PFRight)

EndFunc   ;==>PFShow

Func PFSmallShow()

    GUISetState(@SW_SHOW, $PFsmallTop)
    GUISetState(@SW_SHOW, $PFsmallBottom)
    GUISetState(@SW_SHOW, $PFsmallLeft)
    GUISetState(@SW_SHOW, $PFsmallRight)

EndFunc   ;==>PFSmallShow

Func PFShowBoth()

    GUISetState(@SW_SHOW, $PFTop)
    GUISetState(@SW_SHOW, $PFBottom)
    GUISetState(@SW_SHOW, $PFLeft)
    GUISetState(@SW_SHOW, $PFRight)

    GUISetState(@SW_SHOW, $PFsmallTop)
    GUISetState(@SW_SHOW, $PFsmallBottom)
    GUISetState(@SW_SHOW, $PFsmallLeft)
    GUISetState(@SW_SHOW, $PFsmallRight)

EndFunc   ;==>PFShowBoth

Func PFResize()
    PFStop()
    $PFMoveMode = True

    PFShow()

    While 1

        $PFMousePos = MouseGetPos()

        WinMove($PFTop, "", $PFx, $PFy, $PFScanWidth, 2)
        WinMove($PFLeft, "", $PFx, $PFy, 2, $PFScanHeight)
        WinMove($PFRight, "", $PFx + $PFScanWidth - 2, $y, 2, $PFScanHeight)
        WinMove($PFBottom, "", $PFx, $PFy + $PFScanHeight, $PFScanWidth, 2)

        If Not (($PFMousePos[0] - $PFx + 1) <= 40) Then
            $PFScanWidth = $PFMousePos[0] - $PFx + 1
        EndIf
        If Not (($PFMousePos[1] - $PFy - 39) <= 40) Then
            $PFScanHeight = $PFMousePos[1] - $PFy - 39
        EndIf

        If _IsPressed(01) Then
            Sleep(1000)
            PFHide()
            ExitLoop
        EndIf
    WEnd
EndFunc   ;==>PFResize

Func PFFishFindChooseColor()
    $PFNewColor = 0
    While 1
        $PFMousePos = MouseGetPos()
        If Not @error Then
            $PFNewColor = PixelGetColor($PFMousePos[0], $PFMousePos[1])
            GUICtrlSetBkColor($PFCurrentColorDisplay, $PFNewColor)
        EndIf

        Sleep(150)

        If _IsPressed(01) Then

            If $PFNewColor <> -1 Then
                $PFCurrentColor = $PFNewColor
            EndIf

            PFSetColor()

            ExitLoop
        EndIf

    WEnd
EndFunc   ;==>PFFishFindChooseColor

Func PFDropFindChooseColor()
    $PFDropColor = 0
    While 1
        $PFMousePos = MouseGetPos()
        If Not @error Then
            $PFDropColor = PixelGetColor($PFMousePos[0], $PFMousePos[1])
            GUICtrlSetBkColor($PFDropColorDisplay, $PFDropColor)
        EndIf

        Sleep(150)

        If _IsPressed(01) Then

            If $PFDropColor <> -1 Then
                $PFCurrentDropColor = $PFDropColor
            EndIf

            PFSetDropColor()

            ExitLoop
        EndIf

    WEnd
EndFunc   ;==>PFDropFindChooseColor

#EndRegion
Link to comment
Share on other sites

Yes. $PFStartButton works fine, but not the $PFMenuStart

Let me know if I'm wrong in any assumptions I make here.

This works when you press $PFStartbutton and it doesn't work when you press $PFMenuStart. (I'm guessing this is part your having problems with)

Case $msg[0] = $PFStartButton Or $msg[0] = $PFMenuStart Or $msg[0] = $PFMenuHotKeyStart And $msg[1] = $PFGUI
PFStart()

My only guess would be that $PFMenuStart is a tray item. If that's the case you need to use TrayGetMsg() for tray messages.

Another suggestion I have is to break this part into two different Case statements. Maybe you'll notice something that's wrong...

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

This isn't giving me a message box, at all. Im using ...

Do

   $msg = GUIGetMsg(1)
    Select 

Case $msg[0] = $PFStartButton Or $msg[0] = $PFMenuStart And $msg[1] = $PFGUI
            If not @error Then
            MsgBox(1, "", "1")
            Else
            MsgBox(1, "", "0")
            Endif

            
    EndSelect       
    
    Until $msg[0] = $GUI_EVENT_CLOSE

Its for a MUCH larger script, and I was able to narrow it down to this as the problem. Any help would be greatly appreciated! =)

#include <GUIConstants.au3>

$Form1 = GUICreate("AForm1", 361, 58, 56, 162)
$PFStartButton = GUICtrlCreateButton("PFStartButton", 16, 8, 105, 33, 0)

GUISetState(@SW_SHOW)
Do

   $msg = GUIGetMsg(1)
Select 
Case $msg[0] = $PFStartButton 
MsgBox(1, "$PFStartButton", $PFStartButton )
MsgBox(1, "$msg[0]", $msg[0])
MsgBox(1, "$HandleForm1", WinGetHandle ( "AForm1" ))
MsgBox(1, "$msg[1]", $msg[1])
EndSelect     
    
    Until $msg[0] = $GUI_EVENT_CLOSE
Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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