Jump to content

Recommended Posts

Posted
Func checkboxes()
    if GUICtrlRead($VIP) = 1 and GUICtrlRead($Boxes) = 1 Then
        MsgBox(1,"test","test VIP",0)
    Else if GUICtrlRead($VIP) = 0 and GUICtrlRead ($Boxes) = 1 Then 
        MouseMove($pxstwo[0],$pxstwo[1],25)
        MouseClick("left")
        EndIf
    EndIf
EndFunc

i get a syntax error telling me it can't be just a statement     Else if GUICtrlRead($VIP) = 0 and GUICtrlRead ($Boxes) = 1 Then 

Posted

Please provide a working miniscript with GUI and checkboxes, not just a standalone function.

The following Example is therefore just a dummy.

Global $iVIP, $iBoxes

$iVIP   = 1
$iBoxes = 1
ConsoleWrite(@CRLF)
ConsoleWrite("> >>> Call Func _CheckValues with $iVIP = 1 And $iBoxes = 1" & @CRLF)
_CheckValues()

$iVIP   = 0
$iBoxes = 1
ConsoleWrite(@CRLF)
ConsoleWrite("> >>> Call Func _CheckValues with $iVIP = 0 And $iBoxes = 1" & @CRLF)
_CheckValues()

Func _CheckValues()
    If $iVIP = 1 And $iBoxes = 1 Then
        ConsoleWrite("+ >>>>> Setting : $iVIP = 1 And $iBoxes = 1" & @CRLF)
    Else
        If $iVIP = 0 And $iBoxes = 1 Then
            ConsoleWrite("+ >>>>> Setting : $iVIP = 0 And $iBoxes = 1" & @CRLF)
            ConsoleWrite("+ >>>>> DO : MouseMove >>> MouseClick" & @CRLF & @CRLF)
        EndIf
    EndIf
EndFunc

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
  On 12/29/2019 at 8:10 AM, Musashi said:

Please provide a working miniscript with GUI and checkboxes, not just a standalone function.

The following Example is therefore just a dummy.

Global $iVIP, $iBoxes

$iVIP   = 1
$iBoxes = 1
ConsoleWrite(@CRLF)
ConsoleWrite("> >>> Call Func _CheckValues with $iVIP = 1 And $iBoxes = 1" & @CRLF)
_CheckValues()

$iVIP   = 0
$iBoxes = 1
ConsoleWrite(@CRLF)
ConsoleWrite("> >>> Call Func _CheckValues with $iVIP = 0 And $iBoxes = 1" & @CRLF)
_CheckValues()

Func _CheckValues()
    If $iVIP = 1 And $iBoxes = 1 Then
        ConsoleWrite("+ >>>>> Setting : $iVIP = 1 And $iBoxes = 1" & @CRLF)
    Else
        If $iVIP = 0 And $iBoxes = 1 Then
            ConsoleWrite("+ >>>>> Setting : $iVIP = 0 And $iBoxes = 1" & @CRLF)
            ConsoleWrite("+ >>>>> DO : MouseMove >>> MouseClick" & @CRLF & @CRLF)
        EndIf
    EndIf
EndFunc

 

Expand  
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\nick n rachael\desktop\simplegui.kxf
$SimpleGUI = GUICreate("COS", 237, 165, -1, -1)
GUISetBkColor(0x99B4D1)
Global $Program = GUICtrlCreateButton("Run Program", 8, 8, 75, 25)
GUICtrlSetBkColor(-1, 0xC8C8C8)
GUICtrlSetCursor (-1, 0)
Global $exit = GUICtrlCreateButton("exit", 8, 40, 75, 25)
GUICtrlSetBkColor(-1, 0xC8C8C8)
GUICtrlSetCursor (-1, 0)
Global $VIP = GUICtrlCreateCheckbox("VIP > 5", 72, 136, 97, 17)
Global $pxs = PixelSearch(1205, 870, 1221, 880, 0xFDF0B0, 20)
Global $pxstwo = PixelSearch(1205, 866, 1221, 882, 0xF3CE97, 20)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Program
            checkboxes()
        Case $exit
            Exit
    EndSwitch
WEnd

Func checkboxes()
    if GUICtrlRead($VIP) = 1 and GUICtrlRead($Boxes) = 1 Then
        MsgBox(1,"test","test VIP",0)
    Else if GUICtrlRead($VIP) = 0 and GUICtrlRead ($Boxes) = 1 Then
        MouseMove($pxstwo[0],$pxstwo[1],25)
        MouseClick("left")
        EndIf
    EndIf
EndFunc

 

Posted

-> $Boxes: undeclared global variable.

-> else if ==> followed by multiple statements is not correct

-> check if PixelSearch was successful, otherwise MouseMove($pxstwo[0],$pxstwo[1],25) will fail !

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\users\nick n rachael\desktop\simplegui.kxf
$SimpleGUI = GUICreate("COS", 237, 165, -1, -1)
GUISetBkColor(0x99B4D1)
Global $Program = GUICtrlCreateButton("Run Program", 8, 8, 75, 25)
GUICtrlSetBkColor(-1, 0xC8C8C8)
GUICtrlSetCursor (-1, 0)
Global $exit = GUICtrlCreateButton("exit", 8, 40, 75, 25)
GUICtrlSetBkColor(-1, 0xC8C8C8)
GUICtrlSetCursor (-1, 0)
Global $VIP   = GUICtrlCreateCheckbox("VIP > 5", 10, 136, 97, 17)
Global $Boxes = GUICtrlCreateCheckbox("Boxes", 100, 136, 97, 17)

Global $pxs    = PixelSearch(1205, 870, 1221, 880, 0xFDF0B0, 20)
If @error Then ConsoleWrite("! @@DEBUG >>>>> ERROR or NOTFOUND Array $pxs " & @CRLF)

Global $pxstwo = PixelSearch(1205, 866, 1221, 882, 0xF3CE97, 20)
If @error Then ConsoleWrite("! @@DEBUG >>>>> ERROR or NOTFOUND Array $pxstwo " & @CRLF)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Program
            checkboxes()
        Case $exit
            Exit
    EndSwitch
WEnd

Func checkboxes()
    ; Info : $GUI_CHECKED(1), $GUI_UNCHECKED(4)
    if GUICtrlRead($VIP) = $GUI_CHECKED  and GUICtrlRead($Boxes) = $GUI_CHECKED Then
        ConsoleWrite("+ @@DEBUG >>>>> Setting : $VIP = " & GUICtrlRead($VIP) & "  $Boxes = " & GUICtrlRead($Boxes) & @CRLF)
        MsgBox(0,"Test","Test VIP")
    Else
        if GUICtrlRead($VIP) = $GUI_UNCHECKED and GUICtrlRead ($Boxes) = $GUI_CHECKED Then
            ConsoleWrite("+ @@DEBUG >>>>> Setting : $VIP = " & GUICtrlRead($VIP) & "  $Boxes = " & GUICtrlRead($Boxes) & @CRLF)
            If IsArray($pxstwo) Then
                MouseMove($pxstwo[0],$pxstwo[1],25)
                MouseClick("left")
            Else
                ConsoleWrite("! @@DEBUG >>>>> Coords $pxstwo not found" & @CRLF)
            EndIf
        EndIf
    EndIf
EndFunc

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
  On 12/29/2019 at 8:52 AM, Musashi said:

-> $Boxes: undeclared global variable.

-> else if ==> followed by multiple statements is not correct

-> check if PixelSearch was successful, otherwise MouseMove($pxstwo[0],$pxstwo[1],25) will fail !

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\users\nick n rachael\desktop\simplegui.kxf
$SimpleGUI = GUICreate("COS", 237, 165, -1, -1)
GUISetBkColor(0x99B4D1)
Global $Program = GUICtrlCreateButton("Run Program", 8, 8, 75, 25)
GUICtrlSetBkColor(-1, 0xC8C8C8)
GUICtrlSetCursor (-1, 0)
Global $exit = GUICtrlCreateButton("exit", 8, 40, 75, 25)
GUICtrlSetBkColor(-1, 0xC8C8C8)
GUICtrlSetCursor (-1, 0)
Global $VIP   = GUICtrlCreateCheckbox("VIP > 5", 10, 136, 97, 17)
Global $Boxes = GUICtrlCreateCheckbox("Boxes", 100, 136, 97, 17)

Global $pxs    = PixelSearch(1205, 870, 1221, 880, 0xFDF0B0, 20)
If @error Then ConsoleWrite("! @@DEBUG >>>>> ERROR or NOTFOUND Array $pxs " & @CRLF)

Global $pxstwo = PixelSearch(1205, 866, 1221, 882, 0xF3CE97, 20)
If @error Then ConsoleWrite("! @@DEBUG >>>>> ERROR or NOTFOUND Array $pxstwo " & @CRLF)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Program
            checkboxes()
        Case $exit
            Exit
    EndSwitch
WEnd

Func checkboxes()
    ; Info : $GUI_CHECKED(1), $GUI_UNCHECKED(4)
    if GUICtrlRead($VIP) = $GUI_CHECKED  and GUICtrlRead($Boxes) = $GUI_CHECKED Then
        ConsoleWrite("+ @@DEBUG >>>>> Setting : $VIP = " & GUICtrlRead($VIP) & "  $Boxes = " & GUICtrlRead($Boxes) & @CRLF)
        MsgBox(0,"Test","Test VIP")
    Else
        if GUICtrlRead($VIP) = $GUI_UNCHECKED and GUICtrlRead ($Boxes) = $GUI_CHECKED Then
            ConsoleWrite("+ @@DEBUG >>>>> Setting : $VIP = " & GUICtrlRead($VIP) & "  $Boxes = " & GUICtrlRead($Boxes) & @CRLF)
            If IsArray($pxstwo) Then
                MouseMove($pxstwo[0],$pxstwo[1],25)
                MouseClick("left")
            Else
                ConsoleWrite("! @@DEBUG >>>>> Coords $pxstwo not found" & @CRLF)
            EndIf
        EndIf
    EndIf
EndFunc

 

Expand  

$Boxes is declared globally at the top?  Global $Boxes = GUICtrlCreateCheckbox("Boxes", 100, 136, 97, 17)

for the Else If statement, i can't have 2 statements, so how would i go about checking multiple scenarios at once?  i need to check if VIP box is checked and Boxes is checked,  along with another statement to check if VIP is not checked but boxes is checked.

Posted
  On 12/29/2019 at 10:26 AM, Nickolai said:

$Boxes is declared globally at the top?  Global $Boxes = GUICtrlCreateCheckbox("Boxes", 100, 136, 97, 17)

Expand  

1. Not in the script you provided ;):

ErrorBoxes.png.fc41b267f72f4b6b0aa6972689c17f1f.png

 

2. $VIP is a checkbox, so this is pointless :

if GUICtrlRead($VIP) = 0

Use $GUI_CHECKED or $GUI_UNCHECKED instead !

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
  On 12/29/2019 at 11:58 AM, Musashi said:

1. Not in the script you provided ;):

ErrorBoxes.png.fc41b267f72f4b6b0aa6972689c17f1f.png

 

2. $VIP is a checkbox, so this is pointless :

if GUICtrlRead($VIP) = 0

Use $GUI_CHECKED or $GUI_UNCHECKED instead !

Expand  

i don't understand how it doesn't make sense to you, If GUICtrlread($VIP)  = 0 ( 0 = False ) then ... statement, are you confused about my variable? 

Posted
  On 12/29/2019 at 12:05 PM, Nickolai said:

i don't understand how it doesn't make sense to you, If GUICtrlread($VIP)  = 0 ( 0 = False )

Expand  

Try :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$SimpleGUI = GUICreate("TestGUI", 237, 165, -1, -1)
Global $Program = GUICtrlCreateButton("Run Program", 8, 8, 100, 25)
Global $exit = GUICtrlCreateButton("Exit", 8, 40, 75, 25)
Global $VIP = GUICtrlCreateCheckbox("VIP", 72, 136, 97, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Program
            checkboxes()
        Case $exit
            Exit
    EndSwitch
WEnd

Func checkboxes()
    If GUICtrlRead($VIP) = 0 Then
        ConsoleWrite("+ @@DEBUG >>>>> = 0 : $VIP = " & GUICtrlRead($VIP) & @CRLF)
    EndIf

    If GUICtrlRead($VIP) = $GUI_CHECKED Then
        ConsoleWrite("+ @@DEBUG >>>>> = 1 ($GUI_CHECKED)   : $VIP = " & GUICtrlRead($VIP) & @CRLF)
    EndIf

    If GUICtrlRead($VIP) = $GUI_UNCHECKED Then
        ConsoleWrite("+ @@DEBUG >>>>> = 4 ($GUI_UNCHECKED) : $VIP = " & GUICtrlRead($VIP) & @CRLF)
    EndIf
EndFunc

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

Nickolai,

two things:

  1. Please do not quote every post when answering. We know what we have written. It just clutters the thread. Simply nter your reply into the inputfield at the end of the thread.
  2. Give meaningful titles to your posts. Everyone on this forum is looking for help/a solution ;)

Thanks :)

My UDFs and Tutorials:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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