Jump to content

Looking for a solution


Nickolai
 Share

Recommended Posts

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 

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

2 minutes ago, 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

 

#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

 

Link to comment
Share on other sites

-> $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."

Link to comment
Share on other sites

1 hour ago, 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

 

$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.

Link to comment
Share on other sites

1 hour ago, Nickolai said:

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

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."

Link to comment
Share on other sites

3 minutes ago, 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 !

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? 

Link to comment
Share on other sites

13 minutes ago, Nickolai said:

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

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."

Link to comment
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...