Jump to content

problem with checkbox


 Share

Recommended Posts

Hi, im trying to understand how to get my scripts in GUI and im geting a problem with the checkbox, its like this:

to understand i create a simple loop i check the checkbox and the script opens a folder (the orange one, im portuguese im not shure whats the name of the folder in english) and i whant it to keep doing it until i uncheck it. when i uncheck the checkbox it does the same thing im having trouble with that i need help to make it stop when i uncheck it..

sorry for bad english and thanks in advance

#include 
#include 
#include 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 179, 49, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("open folder", 16, 16, 73, 17)
$Button1 = GUICtrlCreateButton("exit", 88, 16, 75, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

HotKeySet("p","stop")

$msg = GUIGetMsg()
if $msg = -3 then Exit
if $msg = $button1 then close()
if $msg = $Checkbox1 then open()

WEnd

func close()
Exit
EndFunc

func open()
while 1

$open = PixelSearch(187,107,600,600,0xDE843D)

if isarray($open) Then
MouseClick("left",$open[0],$open[1],2,2)
EndIf
WEnd
EndFunc

Func stop()
Exit
EndFunc
Edited by ryukkO
Link to comment
Share on other sites

When the Checkbox has been selected you have to read the status of the CheckBox.

#include <GUIConstantsEx.au3>
$Form1 = GUICreate("Form1", 179, 49, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("open folder", 16, 16, 73, 17)
$Button1 = GUICtrlCreateButton("exit", 88, 16, 75, 17)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    If $msg = -3 Or $msg = $Button1 Then Exit
    If $msg = $Checkbox1 Then
        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then MsgBox(0, "", "Checkbox selected")
    EndIf
WEnd

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

so i did that but it goes like this: I check and it does the thing is ment to do over and over again but when i uncheck it does not stop it does the same thing like when its checked.

what i need to do is. check -> loop exmpl.(open a folder when it fund the pixel over and over again)

uncheck -> sleep (do nothing just w8 until i check it again)

#include 
#include 
#include 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 179, 49, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("open folder", 16, 16, 73, 17)
$Button1 = GUICtrlCreateButton("exit", 88, 16, 75, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

HotKeySet("p","stop")

$msg = GUIGetMsg()
If $msg = -3 Or $msg = $Button1 Then Exit
If $msg = $Checkbox1 Then
If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then open()
EndIf

WEnd

func stop()
Exit
EndFunc

func open()
while 1

$open = PixelSearch(187,107,600,600,0xDE843D)

if isarray($open) Then
MouseClick("left",$open[0],$open[1],2,2)
EndIf
WEnd
EndFunc
Link to comment
Share on other sites

Because you never exit the Wile/WEnd loop.

Should look like:

func open()
    while 1
         $open = PixelSearch(187,107,600,600,0xDE843D)
        if isarray($open) Then
            MouseClick("left",$open[0],$open[1],2,2)
            ExitLoop
        EndIf
    WEnd
EndFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

i did that and its not what i whant, i only whant to stop the loop when i uncheck the checkbox.

sorry if im explaining worn or its my bad english.

example: i check the box and the mouse goes to all folders and opens them, over and over again. i uncheck and it stops does nothing

what i deed whas: i check the box and the mouse goes to all folders and opens them, over and over again.i uncheck it and it does the same thing it does not stop.

i cant see were is the error if its the windows while or the func. if i exit loop it only does 1 time the func and stops with the box checked

Link to comment
Share on other sites

Then you have to use the GuiOnEvent mode. Because you have to check for user input (uncheck the box) in the While/WEnd loop in function open().

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Can you please explain why you have to use PixelSearch and "FolderOpen" in one script? What do you try to achieve? Is it a real problem you want to solve or do you just try to learn AutoIt?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

To learn AutoIt I would suggest to use a real life problem. If you create one yourself you often make it overly complex.

Have a look at the wiki where you can find a lot of tutorials with a lot of example code. Take one of this examples and adopt them to your environment.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Glad to be of service :D

I hope I can help you with the next question.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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...