Jason786 Posted June 9, 2010 Share Posted June 9, 2010 Hey, the first MouseClick works when it is finding the square position but after that it doesn't hold down the mouse on the next pixel I want it to click the pixel and hold down the mouse basically, I'm not sure if this is completely wrong or I need to add in a mouse move? Global $Active = 0 While 1 If $Active = 1 Then $SquarePosition = PixelSearch(0, 0, 1696, 1036, 0x941616, 3) If IsArray($SquarePosition) Then MouseClick("left", $SquarePosition[0], $SquarePosition[1], 1, 0) $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then AutoItSetOption("MouseClickDownDelay", 2000) EndIf Sleep(10) EndIf EndIf WEnd Link to comment Share on other sites More sharing options...
norax Posted June 9, 2010 Share Posted June 9, 2010 Global $Active = 0 While 1 If $Active = 1 Then $SquarePosition = PixelSearch(0, 0, 1696, 1036, 0x941616, 3) If IsArray($SquarePosition) Then MouseClick("left", $SquarePosition[0], $SquarePosition[1], 1, 0) $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then MouseMove($SquarePosition[0], $SquarePosition[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") EndIf Sleep(10) EndIf EndIf WEnd Link to comment Share on other sites More sharing options...
Jason786 Posted June 9, 2010 Author Share Posted June 9, 2010 I have this now, but it failed to compile expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** HotKeySet("{a}", "_Start") HotKeySet("{s}", "_Pause") HotKeySet("{d}", "_Exit") Global $Active = 0 While 1 If $Active = 1 Then $SquarePosition = PixelSearch(0, 0, 1696, 1036, 0x941616, 3) If IsArray($SquarePosition) Then MouseClick("left", $SquarePosition[0], $SquarePosition[1], 1, 0) $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then MouseMove($SquarePosition[0], $SquarePosition[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") EndIf Sleep(10) EndIf EndIf ;### Tidy Error: next line creates a negative tablevel. ;### Tidy Error: next line creates a negative tablevel for the line after it. WEnd Func _Start() $Active = 1 EndFunc ;==>_Start Func _Pause() $Active = 0 EndFunc ;==>_Pause Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
norax Posted June 9, 2010 Share Posted June 9, 2010 (edited) show me the error code maybe i misstyped something Edited June 9, 2010 by norax Link to comment Share on other sites More sharing options...
Yoriz Posted June 9, 2010 Share Posted June 9, 2010 This line looks suspect Global $Active = 0 While 1 try changing to Global $Active = 0 While 1 GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Jason786 Posted June 9, 2010 Author Share Posted June 9, 2010 Ah, yeah of course, sorry that was my fault But when I run the script, it doesn't move the mouse, after it clicks the SquarePosition, it should go to Start and hold down the mouse right? But it only does the square positions Global $Active = 0 While 1 If $Active = 1 Then $SquarePosition = PixelSearch(0, 0, 1696, 1036, 0x941616, 3) If IsArray($SquarePosition) Then MouseClick("left", $SquarePosition[0], $SquarePosition[1], 1, 0) $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then MouseMove($Start[0], $Start[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") EndIf Sleep(10) EndIf EndIf WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 9, 2010 Share Posted June 9, 2010 Then your second PixelSearch() must be failing. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Jason786 Posted June 9, 2010 Author Share Posted June 9, 2010 Then your second PixelSearch() must be failing.The pixel I set appears on the screen so I know it's there, and I double checked the hex :S Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 9, 2010 Share Posted June 9, 2010 So what happens if you test it by itself? $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then ToolTip("PixelSearch() [0] = " & $Start[0] & "; [1] = " & $Start[1]) MouseMove($Start[0], $Start[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") Else ToolTip("PixelSearch() failed") EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Jason786 Posted June 9, 2010 Author Share Posted June 9, 2010 So what happens if you test it by itself? $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then ToolTip("PixelSearch() [0] = " & $Start[0] & "; [1] = " & $Start[1]) MouseMove($Start[0], $Start[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") Else ToolTip("PixelSearch() failed") EndIf that works, it clicks the pixel and holds the mouse for two seconds Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 9, 2010 Share Posted June 9, 2010 (edited) **edit** Finally getting frustrated enough with not seeing anything wrong with the code, I opened up a photo editor started a new project, placed 2 dots (1 of each color) and used this code and it worked as expected... something is wrong with your colors or window that you are trying to interact with. OPT("TrayIconDebug",1) Sleep(100) Global $Active = 1 While 1 If $Active = 1 Then $SquarePosition = PixelSearch(0, 0, 1696, 1036, 0x941616, 3) If IsArray($SquarePosition) Then MouseClick("left", $SquarePosition[0], $SquarePosition[1], 1, 0) $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then MouseMove($Start[0], $Start[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") EndIf Sleep(10) EndIf EndIf WEnd Edited June 9, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Jason786 Posted June 9, 2010 Author Share Posted June 9, 2010 Is it possible that it's looping trying to find the squareposition and not moving onto the move mouse to the start position? When I tested it individually it worked fine, only when it's together it doesn't work :S expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** HotKeySet("{a}", "_Start") HotKeySet("{s}", "_Pause") HotKeySet("{d}", "_Exit") Global $Active = 0 While 1 If $Active = 1 Then $SquarePosition = PixelSearch(0, 0, 1696, 1036, 0x941616, 3) If IsArray($SquarePosition) Then MouseClick("left", $SquarePosition[0], $SquarePosition[1], 1, 0) $Start = PixelSearch(0, 0, 1696, 1036, 0x53DF0A) If IsArray($Start) Then MouseMove($Start[0], $Start[1], 0) MouseDown("left") Sleep(2000) MouseUp("left") EndIf Sleep(10) EndIf EndIf WEnd Func _Start() $Active = 1 EndFunc ;==>_Start Func _Pause() $Active = 0 EndFunc ;==>_Pause Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 9, 2010 Share Posted June 9, 2010 I have no problems with your code, it all works fine here. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Jason786 Posted June 10, 2010 Author Share Posted June 10, 2010 I have no problems with your code, it all works fine here.Thanks for the help thoughWould you know of any way to change the order of the code so that it still does the same thing? 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