Sign in to follow this  
Followers 0
BluhBlah

2 Pixelsearch If it finds x it will exit loop and restart

9 posts in this topic

* It will do a pixelsearch/getcolor and if it fins it then it will sleep x amount of time, And after that time it will press y , But if another pixelsearch finds z while its sleeping then it will exit this loop and keep going on like this!

Share this post


Link to post
Share on other sites



Xoriaz,

If you want someone to write it, then go to rentacoder.

You have been here long enough to know that most of us expect you to have go at it first and then post your code if it does not work. :)

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

#3 ·  Posted (edited)

Dim $stop = 0
HotKeySet("{F4}", "toggel")
HotKeySet("{F5}", "off")

While 1
    If $stop = 1 Then
    If PixelGetColor(346, 317) = 0x85744A Then
      Sleep (300000) If PixelGetColor(346, 317) = 0x85744A Then ExitLoop
      ElseIf PixelGetColor(346, 317) = 0x857440 Then Send ("!Q")
      EndIf
WEnd



Func toggel()
    If $stop = 0 Then
        $stop = 1
    Else
        $stop = 0
    EndIf
EndFunc

Func off()
    Exit
EndFunc

Error "Wend" statement with no matching "while" statement

-.-

Edited by Xoriaz

Share this post


Link to post
Share on other sites

Its not happy as you left an endif statement here

EndIf

WEnd

Try changing it to

EndIf

EndIf

WEnd

HTH

Share this post


Link to post
Share on other sites

I was wondering if this:

Sleep (300000) If PixelGetColor(346, 317) = 0x85744A Then ExitLoop [/codebox]

Does it do the PixelGetColor while it sleeps?

And thanks alot :)

Share this post


Link to post
Share on other sites

Xoriaz,

Try this and see if it does what you want. I have commented liberally, so it should be easy to understand what is going on. I have tried my best to understand what you want to do when the pixel is various colours - your written description seemed more logical than your code! :)

Dim $stop = 1

HotKeySet("{F4}", "toggle")
HotKeySet("{F5}", "off")

While 1
    If $stop = 0 Then
        ; Check if the pixel is colour One
        If PixelGetColor(346, 317) = 0x85744A Then
            ; If so, begin our waiting loop
            $iBegin = TimerInit()
            ; This loop waits for 5 minutes
            While TimerDiff($iBegin) < 300000
                ; During the loop we check to see if the pixel is colour Two and exit the loop if it is
                If PixelGetColor(346, 317) = 0x857440 Then ExitLoop
            WEnd
            ; The pixel has changed to colour Two or the loop has timed out
            ; But if the pixel is still colour One, send "Alt-Q"
            If PixelGetColor(346, 317) = 0x85744A Then Send ("!Q")
        EndIf
    Else
        ; If we are not checking anything, idle a bit to save the CPU
        Sleep(10)
    EndIf
WEnd

Func toggle()
    ; $stop is Boolean in nature, so all we need to do is toggle between 1 and 0
    $stop = Not $stop
EndFunc

Func off()
    Exit
EndFunc

Sleep (300000) If PixelGetColor(346, 317) = 0x85744A Then ExitLoop

Does it do the PixelGetColor while it sleeps?

No, it does nothing at all while it sleeps, which is why you have to use a While...WEnd loop with TimerDiff so that you can call PixelGetColor during the waiting time.

By the way, if you use Tidy within SciTE (Ctrl-T) it will help with errors like the WEnd/EndIf confusion you had above. :)

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

Thanks alot, and sorry for my terrible explaining and coding skills:rolleyes:

Also: Can i do like this instead?

While TimerDiff($iBegin) < 300000

While TimerDiff($iBegin) < $delay

Thanks again :)

Share this post


Link to post
Share on other sites

Xoriaz,

Can i do like this instead?

While TimerDiff($iBegin) < 300000

While TimerDiff($iBegin) < $delay

Of course - as long as you declare $delay beforehand. :)

sorry for my terrible explaining and coding skills

No problems - the explaining was fine and I am sure you are improving the coding as you go along. There are plenty of good examples here o the forums. :)

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

http://www.autoitscript.com/forum/index.php?showtopic=104111&st=0&p=736979&#entry736979

???

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