yousefsamy Posted July 16, 2014 Posted July 16, 2014 Here is my code, i don't know why isn't it working : Do $search = PixelSearch(0,0,1023,767,0x0018C6) If $search = @error Then Sleep(100) Until $search = Not @error MouseMove($search[0],$search[1],20)
Moderators JLogan3o13 Posted July 16, 2014 Moderators Posted July 16, 2014 Explain "isn't working".Is it throwing an error, is it not moving the mouse, is the script ending prematurely, what? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
yousefsamy Posted July 16, 2014 Author Posted July 16, 2014 here is my Code , But i don't know why isn't it working : Do $search = PixelSearch(0,0,1023,767,0x0018C6) If $search = @error Then Sleep(100) Until $search = Not @error MouseMove($search[0],$search[1],20)
mLipok Posted July 16, 2014 Posted July 16, 2014 1. sugestion: Until Not ($search = @error) 2. question: how you think in the following line Until $search = Not @error @error is returned from which function ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
Moderators Melba23 Posted July 16, 2014 Moderators Posted July 16, 2014 yousefsamy,Just one thread at a time please - merged. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
mLipok Posted July 16, 2014 Posted July 16, 2014 (edited) Here is my code, i don't know why isn't it working : Do $search = PixelSearch(0,0,1023,767,0x0018C6) If $search = @error Then Sleep(100) Until $search = Not @error MouseMove($search[0],$search[1],20) after reading HelpFile I can guess: line 3 and 4 never happend EDIT line 3 never happend and line 4 always is true so the resutl is Exitloop Edited July 16, 2014 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
yousefsamy Posted July 16, 2014 Author Posted July 16, 2014 Melba23 sorry for that i have a bad connection
yousefsamy Posted July 16, 2014 Author Posted July 16, 2014 mLipok but the loop ends itself when don't find the pixel ? should do loop running until find the pixel ?
Shane0000 Posted July 16, 2014 Posted July 16, 2014 Dim $aSearch[0] Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) If Not IsArray($search) Then Sleep(100) Until IsArray($aSearch) MouseMove($aSearch[0],$aSearch[1],20) If PixelSearch succeeds it returns an Array so you can try the above If an error occurs $error is set to 1 so you could also do: Dim $aSearch[0] Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) If @error Then Sleep(100) Until Not @Error MouseMove($aSearch[0],$aSearch[1],20) if 'Not @error' doesnt work try 'Until @error < 1'
Moderators Melba23 Posted July 16, 2014 Moderators Posted July 16, 2014 yousefsamy,No problem - it happens to us all. But - and I am getting really tired of asking you this same question over and over again - have you even looked at the Help file example for the function you are trying to use? I think not, because the examples for _PixelSearch show exactly how to check for @error - and your code is nothing like it. What makes you think the return value should be the same as the @error macro? Go and look at the Help file example and try again. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jdelaney Posted July 16, 2014 Posted July 16, 2014 If an error occurs $error is set to 1 so you could also do: Dim $aSearch[0] Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) If @error Then Sleep(100) Until Not @Error MouseMove($aSearch[0],$aSearch[1],20) if 'Not @error' doesnt work try 'Until @error < 1' The sleep call will set @error = 0, so you will exit the loop unintentionally...do something like this: Local $aSearch Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) If @error Then Sleep(100) Until IsArray($aSearch) MouseMove($aSearch[0],$aSearch[1],20) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jdelaney Posted July 16, 2014 Posted July 16, 2014 Like your first option, but with a correction. You can't declare an array with 0 subscripts, syntactically. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Moderators Melba23 Posted July 16, 2014 Moderators Posted July 16, 2014 jdelaney, You can't declare an array with 0 subscripts, syntacticallyDo you mean that you cannot do this? Dim $aSearch[0]It is perfectly valid syntax - AutoIt has been able to use empty arrays since last summer, I remember rewriting the Array UDF to cope with them. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Shane0000 Posted July 16, 2014 Posted July 16, 2014 Well , I shouldnt have made an empty array if I was doing an IsArray check also soo ... :/ I didnt run any of the code, just shootin from the hip
jdelaney Posted July 16, 2014 Posted July 16, 2014 (edited) The empty array doesn't matter, since it's checked at the end of the loop, and the function will set it to a non array if it fails. Cool. I'm still on the old version, where the array needs 1 subscript or more. Edited July 16, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
yousefsamy Posted July 16, 2014 Author Posted July 16, 2014 where is the problem ,, i read the help file , but i do that with imagesearch() func ,, it works: Local $aSearch Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) If $aSearch = 1 Then Sleep(100) Until $aSearch <> 1 MouseMove($aSearch[0],$aSearch[1],20)
Solution jdelaney Posted July 16, 2014 Solution Posted July 16, 2014 (edited) PixelSearch will never return 1...it will return 0, if it doesn't find your pixel...stick with my example: Local $aSearch Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) If @error Then Sleep(100) Until IsArray($aSearch) MouseMove($aSearch[0],$aSearch[1],20) Or, you can do this: Local $aSearch, $something Do $aSearch = PixelSearch(0,0,1023,767,0x0018C6) $something = @error If $something Then Sleep(100) Until Not $something MouseMove($aSearch[0],$aSearch[1],20) Edited July 16, 2014 by jdelaney yousefsamy and 232showtime 2 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Shane0000 Posted July 16, 2014 Posted July 16, 2014 (edited) Return Values: Success: a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y). Failure: sets the @error flag to 1 if the color is not found. A failed PixelSearch will not set your variable($aSearch) to 1 it sets @error @error = 1 on a failed PixelSearch The only instance that $aSearch will be assigned a value is if your pixel is found. Edited July 16, 2014 by Shane0000
yousefsamy Posted July 17, 2014 Author Posted July 17, 2014 (edited) jdelaney why did you write this line ? Local $aSearch, $something and why if i type @error without put it in a variable didn't work ? Edited July 17, 2014 by yousefsamy
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now