computergroove Posted March 2, 2013 Posted March 2, 2013 (edited) I have a loop that I need to perform an action when a pixel changes color on my screen. I think I should make another separate function and call it but I am unclear when this is appropriate to do (and I dont know what the code looks like). Here's what I have now. While 1 MouseClick ("left",882,525,1) Call("GetColor") MouseClick ("left",1075,563) sleep (1000) MouseClick ("left",1075,563) sleep (1000) wend Func GetColor() While 1 x = PixelGetColor(821,306) Sleep(1000) If x = 0xFFFFFF Then MouseClick("Left",821,306,1) Else Call(GetColor) EndIf Wend I know Im close. Any help is appreciated. Thanks Edited March 2, 2013 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
stormbreaker Posted March 2, 2013 Posted March 2, 2013 Global $COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) While 1 Sleep(100) If NOT PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) = $COLOR then _DoSomething() $COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) EndIf WEnd Func _DoSomething() msgbox(64, 'Hurray', 'Color changed at the pixel') EndFunc Perhaps, this is what you want? ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
computergroove Posted March 6, 2013 Author Posted March 6, 2013 (edited) On 3/2/2013 at 6:51 AM, 'MKISH said: Global $COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) While 1 Sleep(100) If NOT PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) = $COLOR then _DoSomething() $COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) EndIf WEnd Func _DoSomething() msgbox(64, 'Hurray', 'Color changed at the pixel') EndFunc Perhaps, this is what you want? I dont want to mold the function around this action but rather add this in a loop in the existing look. Here is what I came up with - that doesn't work. MouseClick ("left",1080,374) sleep (4000) MouseClick ("left",882,525,1) While 1 sleep(100) If NOT PixelGetColor(821,306) = $color then $color = PixelGetColor(821,306) EndIf WEnd MouseClick ("left",821,306) sleep (1000) I am pretty sure that it is bad practice to put a while 1 loop in another loop. I think I want to make a function and call the function from within the other loop. Edited March 6, 2013 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
ileandros Posted March 6, 2013 Posted March 6, 2013 On 3/6/2013 at 4:18 AM, 'computergroove said: I am pretty sure that it is bad practice to put a while 1 loop in another loop. I think I want to make a function and call the function from within the other loop.It is not but I am not understanding what you are trying to loop??? I feel nothing.It feels great.
water Posted March 6, 2013 Posted March 6, 2013 What do you want to achieve with your script? Wait for a button to change color or ....? Maybe there is an easier way to do what you want. My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
computergroove Posted March 6, 2013 Author Posted March 6, 2013 On 3/6/2013 at 2:02 PM, 'water said: What do you want to achieve with your script? Wait for a button to change color or ....? Maybe there is an easier way to do what you want.I have an old Iphone that I have jailbroken and installed both veency (it's the hackers version of VNC) and an app that gives me points for watching videos. When I get enough points then I get an amazon or itunes gift card. I have setup a script that is working right now to automatically gather points all day and night. I want to make my script more efficient. By being able to click on a specific pixel when it changes to the color I want, I shave off 30 seconds per video and almost double my efficiency. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
ileandros Posted March 7, 2013 Posted March 7, 2013 (edited) There you go $x = PixelGetColor(821,306) While (True) Sleep(100) $move = MouseMove(882,525) While (True) Sleep(100) If $x = 0xFFFFFFThen MouseClick("Left",821,306,1) MsgBox(0,"Succed", "Pixel exists") ;Delete MsgBox it is only to explain ExitLoop Else MsgBox(0,"Error", "Pixel doesn't exists") ;Delete MsgBox it is only to explain ExitLoop EndIf WEnd WEnd Hope it is what you're looking for Edited March 7, 2013 by ileandros I feel nothing.It feels great.
computergroove Posted March 7, 2013 Author Posted March 7, 2013 (edited) This is my final product. I was not aware I could place while loops within the main loop. <snip> Edited March 7, 2013 by Melba23 Code removed Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Moderators Melba23 Posted March 7, 2013 Moderators Posted March 7, 2013 computergroove,Having looked at what "App Trailers" is, I have decided that "fast hacking" it is not something we wish to support - wear out your own fingers if you want to earn "free money". Code deleted and thread closed. Do not ask any further questions on this. 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: Reveal hidden contents 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
Recommended Posts