Jump to content

Why Do Until do not break?


Recommended Posts

HotKeySet("^!x", "MyExit")
Func MyExit()
    Exit
EndFunc
Opt("MouseCoordMode",1)
Do
Sleep(100)
MouseMove(1097,760)
MouseClick("left")
Sleep(100)
Do
$i = PixelGetColor(1015,760)
Until $i = 10846764

MouseClick("left")







Until @error

i have sometning like this, in place 1015,760 is other color than this then do/until dont want to break... i know some c++ and for me it is ok... what i am doing wrong?

Edited by Taumantis
Link to comment
Share on other sites

First @error will get set to success since MouseClick isn't likely to fail. Then what instruction do you expect to break the inner Do loop, since you yourself say the color picked will never equal the constant you use?

In AutoIt like C--, C, C++ or any other language, Do <whatever> Until <condition never met> loops until the Sun goes nova.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

well loop should do:

1. get color from cordination

2. if color is not 10846764 then loop end

3. go to the mouse click ...

do until work like do while ? f.e

do

{

int i;

cin >> i;

}while(i==1)

if i will put 0 for i ,loop break and scrip go to the next line...

sorry if my english is bad :D

Link to comment
Share on other sites

  • Moderators

Taumantis,

Welcome the the AutoIt forum. :rip:

The problem you have is that the Until @error will never fire as @error at that point has been set to 0 by the preceding MouseClick line:

HotKeySet("^!x", "MyExit")
Func MyExit()
    Exit
EndFunc   ;==>MyExit

Opt("MouseCoordMode", 1)

Do
    
    Sleep(100)
    MouseMove(1097, 760)
    MouseClick("left")
    Sleep(100)
    
    Do
        $i = PixelGetColor(1015, 760)
        Sleep(10) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<< Important to reduce the load on the CPU                      
    Until $i = 10846764

    MouseClick("left")

Until @error ; <<<<<<<<<<  But error at this point is set by the MouseClick and so will always be 0

What error do you want to act as the trigger for leaving the loop? :D

M23

Edit: Just seen your post. Why do you have 2 loops in that case? :oops:

HotKeySet("^!x", "MyExit")
Func MyExit()
    Exit
EndFunc   ;==>MyExit

Opt("MouseCoordMode", 1)

While 1
    
    Sleep(100)
    MouseMove(1097, 760)
    MouseClick("left")
    Sleep(100)
    
    If PixelGetColor(1015, 760) = 10846764 Then
        ExitLoop ; This will take you to...

    MouseClick("left")

WEnd

; ...here!

Is that what you want? :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

yes, but second one is too i thinl. i want first do until is for working program until i put x ;p second one is to do what i want... stop and w8 for reaction... if reactions is good then go to the next step and if all is ok repeat ... :D

and my second question how to Opt("MouseClickDownDelay", ) with pixel? i mean mouse lick is down if color at the x y is xxxxxxxxxx and relase if yyyyyyyyyy

Edited by Taumantis
Link to comment
Share on other sites

  • Moderators

Taumantis,

So I understand that you want an outer loop which waits until you "put x" and then an inner loop to wait for a reaction. :oops:

What exactly is "put x"? Is it a key? A coordinate? A colour? :D

A lot depends on how you intend to interact with the script. :rip:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

i want to hold the click button to the moment if on the cordinate x,y color change from color 1 to color 2, and then leave this relased to the moment if on the cordinate 2 x,y color change from color 1 to color 2 :D and then put it again. this loop have to broke if on the cordinate 3 x,y color change from color 3 to color 4. ;p

algorithm look something like this.

step1: click and hold, if on the cordinates (2) color change from color 3 to color 4 end the algorithm else: go step 2

step2: if color on the coordinates (x,y) change from color 1 to color 2 relase button and go to the step 3.

step3: if color on the coordinates (x,y) change from color 1 to color 2 go to step1: (there is not other option)

Edited by Taumantis
Link to comment
Share on other sites

  • Moderators

Taumantis,

Is this getting closer: :oops:

HotKeySet("^!x", "MyExit")

Func MyExit()
    Exit
EndFunc

Opt("MouseCoordMode",1)

; Start an infinite loop
While 1
    
    ; Wait here until "cordinate x,y color change from color 1 to color 2"
    While 1
        If PixelGetColor(x, y) = $iColor2 Then
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
    
    ; Move the mouse to these coordinates
    MouseMove(1097,760)
    ; Mouse button down
    MouseDown("left")
    Sleep(100)
    
    ; Now wait here until "cordinate 2 x,y color change from color 1 to color 2"
    While 1
        If PixelGetColor(x2, y2) = $iColor2 Then
            ExitLoop
        EndIf
        Sleep(10)
    WEnd

    ; And raise the mouse button
    MouseUp("left")

    ; And start again
    
WEnd

A question: Do you not want a timeout on the 2 PixelColor loops? If you do not have one then if the colour does not change you will stay in them forever. :D

Can you give some idea of what you are trying to do? There might be an easier way to do it. :rip:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

bo be onest i want to write bot for facebook go fishing game only for my educational purpose ^^ there u have to click to set lure, w8 until color of the button change from brown to the green, then put the button nad hold it until mark change color from blue to light blue and then relase, relase to moment when blue change to ligh blue again and hold to the blue > ligh blue again... and repeat alll the time until on the coordinates on the middle screen change to to orange with "you catch the fish" :oops: but your post is helping me aout undestand the lagunage of autoit :D this is very helpfull

Edited by Taumantis
Link to comment
Share on other sites

  • Moderators

Taumantis,

So I have been wasting my time on code for a game! :oops:

Go and read the Forum Rules. You have broken the No 1 rule here and that is why you will get no more help from me or anyone else and this thread will soon be locked. :D

And do not try to PM me about it either. :rip:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

u didnt wasted your time, i read somewhere that i should write easy bot script for some game to undestand that autoit etc. i dont play this ;p game but this game was the best choice to learn and it was very good example. And btw i didnt ask for writing bot i just wanted to help me with pixels. sorry if somethegin gone wrong

Link to comment
Share on other sites

  • Developers

u didnt wasted your time, i read somewhere that i should write easy bot script for some game to undestand that autoit etc. i dont play this ;p game but this game was the best choice to learn and it was very good example. And btw i didnt ask for writing bot i just wanted to help me with pixels. sorry if somethegin gone wrong

Read the rules and stick to it.

Topic closed!

oh, and it is not for you to judge whether you wasted somebodies time .... I can only agree that you are wasting peoples time in this forum.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...