Jump to content
Sign in to follow this  
ryukkO

problem with checkbox

Recommended Posts

ryukkO

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ryukkO

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ryukkO

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ryukkO

can u make an example plz?

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ryukkO

im trying to learn autoIt i did that example only to make it simple. im trying to learn 1 thing at time and making a loop in a check box is somthing i simply cant figure it out =/

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ryukkO

ok then i will do and thanks a lot for the help :idiot:

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  

×