Chuuy Posted March 30, 2009 Share Posted March 30, 2009 Something seems to be wrong with my code here: Sleep (5000) $i = 0 While $i = 0 Sleep (8000) If PixelGetColor (880, 200) = 0x507391 And PixelGetColor (795, 362) = 0xC7E2E2 Then MouseClick (795, 362, 10) If PixelGetColor (880, 200) = 0x782F3A And PixelGetColor (795, 441) = 0xC7E2E2 Then MouseClick (795, 441, 10) If PixelGetColor (880, 200) = 0x782F3A And PixelGetColor (795, 491) = 0xC7E2E2 Then MouseClick (795, 491, 10) If PixelGetColor (880, 200) = 0x782F3A And PixelGetColor (795, 427) = 0xC7E2E2 Then MouseClick (795, 427, 10) WEnd To create some simple loop I just made $i = 0 forever because I want this to keep looping forever. Then I just stop the process by going to Task Manager and ending the process. When I'm running this, the Mouse just seems to go to the top of the screen, click, and move right, then wait 8 seconds, then move left and click in the exact same spot, then move right, etc. I'm not sure why. Would there be something wrong with me use 'And' like that? Or is PixelGetColor not accurate enough to read pixel color pixel by pixel? I have double checked all the values and they all work. Link to comment Share on other sites More sharing options...
BrettF Posted March 30, 2009 Share Posted March 30, 2009 (edited) Hi there! Welcome! Have you tried to add a small sleep in? Also add some error checking, like Consolewrite for each case. Also try adding parenthesis for each condition. i.e If ($condition = True) And ($condition2 = True) Then .... Cheers, Brett Edited March 30, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Chuuy Posted March 30, 2009 Author Share Posted March 30, 2009 Hi there! Welcome! Have you tried to add a small sleep in? Also add some error checking, like Consolewrite for each case. Also try adding parenthesis for each condition. i.e If ($condition = True) And ($condition2 = True) Then .... Cheers, BrettThe sleep in gave the same results. I don't understand Consolewrite. What do STDOUT and STDERR mean? I tried searching on google, but it didn't really explain on how it relates to anything. I tried the paranthesis as well, and the same results. This is my current code: Sleep(5000) While 1 Sleep(8000) If (PixelGetColor(880, 200) = 0x507391) And (PixelGetColor(795, 362) = 0xC7E2E2) Then MouseClick(795, 362, 10) Sleep(250) If (PixelGetColor(880, 200) = 0x782F3A)And (PixelGetColor(795, 441) = 0xC7E2E2) Then MouseClick(795, 441, 10) Sleep(250) If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 491) = 0xC7E2E2) Then MouseClick(795, 491, 10) Sleep(250) If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 427) = 0xC7E2E2) Then MouseClick(795, 427, 10) WEnd Link to comment Share on other sites More sharing options...
BrettF Posted March 30, 2009 Share Posted March 30, 2009 Use the full version of SciTE and it will make enough sense for the use. See my sig. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Chuuy Posted March 30, 2009 Author Share Posted March 30, 2009 Well this is weird. I fixed it by adding "Left", right after MouseClick and before my coordinates. Who would've known that that could screw up the script that badly. The funny part is that I had it in the beginning, then I forgot about it when I was rewriting the code. Here's the final code that works: Sleep(5000) While 1 Sleep(8000) If (PixelGetColor(880, 200) = 0x507391) And (PixelGetColor(795, 362) = 0xC7E2E2) Then MouseClick("Left", 795, 362, 10) If (PixelGetColor(880, 200) = 0x782F3A)And (PixelGetColor(795, 441) = 0xC7E2E2) Then MouseClick("Left", 795, 441, 10) If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 491) = 0xC7E2E2) Then MouseClick("Left", 795, 491, 10) If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 427) = 0xC7E2E2) Then MouseClick("Left", 795, 427, 10) WEnd Thanks for the help! Link to comment Share on other sites More sharing options...
BrettF Posted March 30, 2009 Share Posted March 30, 2009 Why didn't I see that! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
TerarinK Posted March 30, 2009 Share Posted March 30, 2009 Just to note after the remark about the parenthesis, what he was doing in right to a extent, he obeyed the rule of operation scince the equals comes before the AND. However the one thing you were missing was the "button" to click: "left", "right", "middle", "main", "menu", "primary", "secondary". Is there a rule in the UDF to allow for the parenthesis to explictly say what your doing or is there not 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
Chuuy Posted April 1, 2009 Author Share Posted April 1, 2009 Do pixel colors differ on every person's monitor? I gave this program to a friend, and ended up having to change all the color values by him sending me .bmp images of the colors I needed to see. We were both using the same browser, IE8. If that's true, then the program I created here would only work on my computer? Link to comment Share on other sites More sharing options...
BrettF Posted April 1, 2009 Share Posted April 1, 2009 I'd say no.More so it would be the locations changing. If you don't mind me asking, what are you automating?Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
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