Slaiochi Posted September 17, 2007 Share Posted September 17, 2007 Trying to make a program that reads numbers from a file, and based on these numbers picks a color and "draws" an image. It was soooo slow with the MouseClick function (Around 6-7 minutes for a 88x72 pixel picture x[) So, I made decided to use a Postmessage function I used for making game bots, the exception is that it is no longer working when I try to use Paint. expandcollapse popup#include <PostMessage_UDF.au3> HotKeySet("{PGDN}", "Terminate") Global $read, $i, $hWnd $file = FileOpen("C:\PixelInfo.txt", 0) Do $read &= FileRead($file, 1) Until @error = -1 MsgBox(0, "File Read", "Information has been parsed.") $hWnd = WinGetHandle("untitled - Paint") If @error Then MsgBox(0, "Window Not Found", "Window couldn't be found.") Exit EndIf For $yInc = 0 to 71 For $xInc = 0 to 87 $x = $xInc + 61 $y = $yInc + 43 $numRead = StringMid($read, $i, 1) _GetColor() _MouseClick ($hWnd, "left", $x, $y, 1, 1) $i = $i + 1 $prg = Int((($yInc / 71) * 100)) ToolTip("Progress: [" & $prg & "%]", -1, -1) Next Next Func _GetColor() If $numRead = 0 Then _MouseClick ($hWnd, "left", 43, 682, 1, 0) EndIf If $numRead = 1 Then _MouseClick ($hWnd, "left", 59, 682, 1, 0) EndIf If $numRead = 2 Then _MouseClick ($hWnd, "left", 75, 682, 1, 0) EndIf If $numRead = 3 Then _MouseClick ($hWnd, "left", 91, 682, 1, 0) EndIf If $numRead = 4 Then _MouseClick ($hWnd, "left", 107, 682, 1, 0) EndIf If $numRead = 5 Then _MouseClick ($hWnd, "left", 123, 682, 1, 0) EndIf If $numRead = 6 Then _MouseClick ($hWnd, "left", 139, 682, 1, 0) EndIf If $numRead = 7 Then _MouseClick ($hWnd, "left", 155, 682, 1, 0) EndIf EndFunc Func Terminate() Exit 0 EndFunc Also, the _MouseClick function: Func _MouseClick($hWnd, $button, $x, $y, $times=1, $delay=250) If $hWnd = 0 Then SetError(-1) Return EndIf Local $ix Local $lParam = _MakeLong($x, $y) Local $user32 = DllOpen("user32.dll") $button = StringLower($button) If $button = "left" Then For $ix = 1 To $times DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam) DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", $lParam) DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", $lParam) If $ix < $times Then Sleep($delay) Next ElseIf $button = "right" Then For $ix = 1 To $times DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam) DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", $lParam) DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", $lParam) If $ix < $times Then Sleep($delay) Next Else SetError(-2) If $user32 <> -1 Then DllClose($user32) Return EndIf If $user32 <> -1 Then DllClose($user32) EndFunc Any thoughts? Link to comment Share on other sites More sharing options...
Sardith Posted September 17, 2007 Share Posted September 17, 2007 You wrote this? Talk to Outshynd. lol [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
Slaiochi Posted September 18, 2007 Author Share Posted September 18, 2007 I never claimed to have written the PostMessage function, only that I had used it before and it always worked. Still not working, any help? Link to comment Share on other sites More sharing options...
Siao Posted September 18, 2007 Share Posted September 18, 2007 Use the handle of paint area control, not the handle of program window. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Slaiochi Posted September 18, 2007 Author Share Posted September 18, 2007 (edited) Tried doing that, maybe I got the wrong control name.. Giving it another try. Can't find the paint area control, need other control handles as well, as this program has to change colors. D= Edited September 18, 2007 by Slaiochi Link to comment Share on other sites More sharing options...
Siao Posted September 18, 2007 Share Posted September 18, 2007 (edited) Work area - ControlGetHandle("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]") Color toolbar - ControlGetHandle("[CLASS:MSPaintApp]", "", "[CLASS:AfxWnd42u]") Edited September 18, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Slaiochi Posted September 18, 2007 Author Share Posted September 18, 2007 It's definitely clicking in the windows now, but it's very buggy. Sometimes drags the color box around and such >_> Link to comment Share on other sites More sharing options...
Slaiochi Posted September 18, 2007 Author Share Posted September 18, 2007 Never mind, had to update coords to be relative to the control, not the window. Cheers! 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