Sign in to follow this  
Followers 0
Dgameman1

Checkbox help

14 posts in this topic

Once again I am making a new thread asking for help.

I promised I looked in the docs

I've even tried to tackle this problem and figure it out on my own for a while.

Basically, what I'm trying to accomplish that...

On my GUI, there is a checkbox and a combobox.

I used the PixelSearch command.

I believe I have set it up correctly, here is my pixelsearch line just in case.

Global $coord = PixelSearch ( 319, 760, 333, 775, 0xEA0033, 1)

That is at the top of my code right below the #includes.

This is my code for my comboboxes and checkboxes

GUICtrlCreateLabel("AutoWord", 150, 105)
$check1 = GUICtrlCreateCheckbox ( "AutoLetter", 8, 110, 75, 25)
$AL1 = GUICtrlCreateCombo("", 8, 135, 50)
GUICtrlSetData(-1, "50", "")

So that when I check the checkbox which has the name Autoletter while it has the 50 selected from the combobox, then it will perform a pixel check, and this is my While 1 code

While 1
    $msg = GUIGetMsg()
    Select
        
        Case $msg = $helpbutton
            msgbox(0, "Help", "For a fast exit, press Esc on your keyboard.")
            
                
        Case $msg = $startbutton
            $send1 = GUICtrlRead($key1)
            $sleep1 = GUICtrlRead($time1)
            $send2 = GUICtrlRead($key2)
            $sleep2 = GUICtrlRead($time2)
            $send3 = GUICtrlRead($key3)
            $sleep3 = GUICtrlRead($time3)
            $send4 = GUICtrlRead($key4)
            $sleep4 = GUICtrlRead($time4)
            
            $perc5 = GUICtrlRead($AL1)
            $box5 = GUICtrlRead($check1)

            $TimeStart1 = TimerInit()
            $TimeStart2 = TimerInit()
            $TimeStart3 = TimerInit()
            $TimeStart4 = TimerInit()
            While 1
                $TimeElapsed1 = TimerDiff($TimeStart1)
                $TimeElapsed2 = TimerDiff($TimeStart2)
                $TimeElapsed3 = TimerDiff($TimeStart3)
                $TimeElapsed4 = TimerDiff($TimeStart4)
                If $TimeElapsed1 >= $sleep1 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send1)
                    $TimeStart1 = TimerInit()
                EndIf
                If $TimeElapsed2 >= $sleep2 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send2)
                    $TimeStart2 = TimerInit()
                EndIf
                If $TimeElapsed3 >= $sleep3 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send3)
                    $TimeStart3 = TimerInit()
                EndIf
                If $TimeElapsed4 >= $sleep4 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send4)
                    $TimeStart4 = TimerInit()
                EndIf
                
                Case $msg = $check1
                    PixelSearch ( 319, 760, 333, 775, 0xEA0033, 1)
                    If not @error Then
                    ControlSend("[CLASS:Notepad]", "", "", "{END}")
                EndIf
                
            WEnd

        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            Exitloop

    EndSelect

WEnd

AND I think I changed my code but I'm not 100% sure but when I check the checkbox, and then after a while unchecked it. I got a BSOD =O

Share this post


Link to post
Share on other sites



Dgameman1,

If you want help we need the whole script, not just a few fragments. ;)

And before you reply, please read my final post in your last thread about which button to use. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

XD Alrighty, I actually just prefer to quote the user above me so that people aren't confused as to who I'm talking to, but I guess you're right in that it isn't necessary and it makes it harder to read. =D

Well this is my whole code then

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d



;
; ----------------------------------------------------------------------------
;   AutoIt Version: 3.3.6.1
;   Author: Dgameman1
; ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

 Global $coord = PixelSearch ( 319, 760, 333, 775, 0xEA0033, 1)

GUICreate("DG v1.5", 335, 200)

GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Auto Words", 270, 10)

GUICtrlCreateLabel("Word1", 8, 30)
$key1 = GUICtrlCreateCombo("", 40, 27, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time1 = GUICtrlCreateInput("Delay", 90, 27, 35)


GUICtrlCreateLabel("Word2", 8, 60)
$key2 = GUICtrlCreateCombo("", 40, 54, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time2 = GUICtrlCreateInput("Delay", 90, 54, 35)


GUICtrlCreateLabel("Word3", 140, 30)
$key3 = GUICtrlCreateCombo("", 172, 27, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time3 = GUICtrlCreateInput("Delay", 222, 27, 35)


GUICtrlCreateLabel("Word4", 140, 60)
$key4 = GUICtrlCreateCombo("", 172, 54, 45)
GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "")
$time4 = GUICtrlCreateInput("Delay", 222, 54, 35)


GUICtrlCreateLabel("___________________________________________________________", 0, 90)

GUICtrlCreateLabel("AutoWord", 150, 105)
$check1 = GUICtrlCreateCheckbox ( "AutoLetter", 8, 110, 75, 25)
$AL1 = GUICtrlCreateCombo("", 8, 135, 50)
GUICtrlSetData(-1, "50", "")


$helpbutton = GUICtrlCreateButton("Help", 267, 170, 60)
$startbutton = GUICtrlCreateButton("Start", 267, 35, 60)
$stopbutton = GUICtrlCreateButton("Stop", 267, 62, 60)

While 1
    $msg = GUIGetMsg()
    Select
        
        Case $msg = $helpbutton
            msgbox(0, "Help", "For a fast exit, press Esc on your keyboard.")
                
        Case $msg = $startbutton
            $send1 = GUICtrlRead($key1)
            $sleep1 = GUICtrlRead($time1)
            $send2 = GUICtrlRead($key2)
            $sleep2 = GUICtrlRead($time2)
            $send3 = GUICtrlRead($key3)
            $sleep3 = GUICtrlRead($time3)
            $send4 = GUICtrlRead($key4)
            $sleep4 = GUICtrlRead($time4)
            
            $perc5 = GUICtrlRead($AL1)
            $box5 = GUICtrlRead($check1)

            $TimeStart1 = TimerInit()
            $TimeStart2 = TimerInit()
            $TimeStart3 = TimerInit()
            $TimeStart4 = TimerInit()
            While 1
                $TimeElapsed1 = TimerDiff($TimeStart1)
                $TimeElapsed2 = TimerDiff($TimeStart2)
                $TimeElapsed3 = TimerDiff($TimeStart3)
                $TimeElapsed4 = TimerDiff($TimeStart4)
                If $TimeElapsed1 >= $sleep1 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send1)
                    $TimeStart1 = TimerInit()
                EndIf
                If $TimeElapsed2 >= $sleep2 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send2)
                    $TimeStart2 = TimerInit()
                EndIf
                If $TimeElapsed3 >= $sleep3 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send3)
                    $TimeStart3 = TimerInit()
                EndIf
                If $TimeElapsed4 >= $sleep4 Then
                    ControlSend("[CLASS:Notepad]", "", "", $send4)
                    $TimeStart4 = TimerInit()
                EndIf
                
                 
                 If GUIGetMsg() = $stopbutton Then ExitLoop 
                
            WEnd

        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            Exitloop

    EndSelect

WEnd


Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

Share this post


Link to post
Share on other sites

Dgameman1,

You need to check in the loop again - like this: ;)

If GUIGetMsg() = $stopbutton Then ExitLoop

    $perc5 = GUICtrlRead($AL1)
    $box5 = GUICtrlRead($check1)
    If $box5 = 1 Then ; Checkbox checked
        If $perc5 = 50 Then ; Combo set to 50
            ; Do the Pixelsearch
            $coord = PixelSearch(319, 760, 333, 775, 0xEA0033, 1)
            If Not @error Then
                ; show found pixel position
                ConsoleWrite(@CRLF & "Pixel found at: " & $coord[0] & " - " & $coord[1] & @CRLF)
            EndIf
        EndIf
    EndIf

Now if your checkbox is checked and the combo reads 50 you run PixelCheck each pass. Over to you to replace the ConsoleWrite with whatever you want to do if the search succeeds. :)

I notice you did not take my advice about the ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", $send#) lines. Makes me think that Notepad is not the app that you are trying to Send to. It would not be here, by any chance? If so, then perhaps you ought to read this. :idiot:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you oh so much =]

And I actually am just sending these to notepad. I know that sending these to notepad isn't the most innovative idea, but I need something to practice on!

And the reason my autoletterword thingy is called DG is because the first to letters of my username are DG. I didn't even know there was a game site called DG Games. =P

And I also did not take your advice about the ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", $send#) because..

1. I personally just think it's fine the way it is.

2. I'm not 100% sure I actually understand what you mean =P

QUESTION

If $box5 = 1 Then ; Checkbox checked
        If $perc5 = 50 Then ; Combo set to 50
            ; Do the Pixelsearch
            $coord = PixelSearch(319, 760, 333, 775, 0xEA0033, 1)
            If Not @error Then
                ; show found pixel position
                ConsoleWrite(@CRLF & "Pixel found at: " & $coord[0] & " - " & $coord[1] & @CRLF)
            EndIf
        EndIf
    EndIf

I understand everything except the line

ConsoleWrite(@CRLF & "Pixel found at: " & $coord[0] & " - " & $coord[1] & @CRLF)

I read the docs but I want some clarification

So, if it does find the pixel, then... Can I replace the consolewrite with a ControlSend function? Or what's the difference between the two?

And I tried changing the 50 in

If $perc = 50 then
to a word or anything other than numbers and the pinkness went away, does that mean it is incorrect if I do not use just numbers? Edited by Dgameman1

Share this post


Link to post
Share on other sites

Dgameman1,

I actually am just sending these to notepad

Then please accept my apologies for having doubted you. :)

I also did not take your advice about the ControlSend [...]

Let me explain again. When using Send you have to make sure that the window you want to receive the data is activated - otherwise the data is sent to the active window which is not the one you want. You can get round this (sometimes) by using ControlSend as you did in your script - but you had not defined the control and so AutoIt still has no idea where to send the data. It therefore defaults to the active window, so as soon as you activate your "DG v1.5" GUI to press the "Stop" button all the letters are sent to your GUI - with no effect. If you add the "[CLASS:Edit]" to define the control within the Notepad window, ControlSend will still send the data to that control even if the Notepad window is not activated. :idiot:

Try changing just one of the 4 lines and see if you can reproduce what I have just described. When I do that I get just that one letter sent to Notepad when you GUI is active. Does that make more sense now? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

OHHHH Okay, I did it, and now it does what I originally wanted. you are correct, now I can do whatever while it sends that action to notepad. Thank you sooo much <3

ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", $send1)

Successsssss =D

Ok, and for my second question, I edited the post before yours with my question =]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

UUMMM....

I selected 50 from the combo-box

I checked the checkbox

I press start

BSOD! =[[[[[[

uuummm This is currently my line of code

If $box5 = 1 Then ; Checkbox checked
        If $perc5 = 50 Then ; Combo set to 50
            ; Do the Pixelsearch
            PixelSearch(603, 768, 622, 778, 0xDD0033, 100)
            If Not @error Then
                    ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", 5)
            EndIf
        EndIf
    EndIf

It does nothing =/

Edited by Dgameman1

Share this post


Link to post
Share on other sites

Dgameman1,

BSOD!

Then you have a problem with your machine as there is nothing in the code to cause a BSOD. ;)

It does nothing

It will only do something if the PixelSearch finds a pixel of the correct colour - what are you trying to PixelSearch? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ok so, it pixelsearchs

If it finds the color, then I want it to

Send the number 5 into notepad...

It does not do that..

Share this post


Link to post
Share on other sites

Dgameman1,

Are you sure? Add some errorchecking to see what coordinates are returned:

; Do the Pixelsearch
$aCoords = PixelSearch(603, 768, 622, 778, 0xDD0033, 100)
If Not @error Then
    ConsoleWrite($aCoords[0] & " - " & $aCoords[1] & @CRLF)
Else
    ConsoleWrite("Nothing Found" & @CRLF)
EndIf

See what you get in the SciTE console. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

It works I guess..

I'm guessing that since PixelSearch is constantly checking to see if that color is there, then it is lagging my system and then it crashes...

Anyway to fix that?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I changed the code abit and it still crashes.

Although not as often. But I do rememebr you saying how sleep pauses everything else in the script.

Global $test = "{END}"

While 1
    
                $perc5 = GUICtrlRead($AL1)
                $box5 = GUICtrlRead($check1)
                
    If $box5 = 1 Then ; Checkbox checked
        If $perc5 = 50 Then ; Combo set to 50
; Do the Pixelsearch
$aCoords = PixelSearch(351, 802, 374, 819, 0x555555, 5)
If @error = 0 Then
    ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", $test)
EndIf
    EndIf
    Endif
Edited by Dgameman1

Share this post


Link to post
Share on other sites

Bumpity bump bump

Help?

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  
Followers 0