BigLenny Posted April 20, 2020 Posted April 20, 2020 Hey, im trying to learn controlclick, this is the second post i make about this as my other one got locked because I was trying to learn it using a game i made (sorry about that, didnt know it was against the rules) So I'm trying to learn it with windows paint instead. Right now, im just trying to make a dot on the screen, but I cant get it work. Anyways, here is the code I have: WinActivate("Namnlös - Paint") Opt("MouseCoordMode", 2) ControlClick("Namnlös - Paint" , "" , "MSPaintApp1" ,"left" , 1, 850, 198) And here is a picture of the window info.
Nine Posted April 20, 2020 Posted April 20, 2020 (edited) You need to use the handle of the Control (Afx:...:81) not the handle of the Wndow. And if you try to control a game like this, you most probably have to forget it, won't work as most game doesn't have a Control to send key strokes to. Edited April 20, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BigLenny Posted April 20, 2020 Author Posted April 20, 2020 20 minutes ago, Nine said: You need to use the handle of the Control (Afx:...:81) not the handle of the Wndow. And if you try to control a game like this, you most probably have to forget it, won't work as most game doesn't have a Control to send key strokes to. Like I said, im trying to use it with paint(for learning) and I already tried Afx... and that didnt work either.
Nine Posted April 20, 2020 Posted April 20, 2020 (edited) It is working for me. Your code may be wrong. Post your script... ps. forgot to tell you, Afx control varies from 1 instance to the other ! Edited April 20, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BigLenny Posted April 20, 2020 Author Posted April 20, 2020 1 hour ago, Nine said: It is working for me. Your code may be wrong. Post your script... ps. forgot to tell you, Afx control varies from 1 instance to the other ! Here is my full code: Func StartLoop() MsgBox(0, "Starting", "Press ESC to stop") While 1 WinActivate("Namnlös - Paint") Opt("MouseCoordMode", 0) ControlClick("Namnlös - Paint", "", "MSPaintApp1","left",1, 850, 198) Sleep($interval) Sleep(50) WEnd EndFunc
Nine Posted April 20, 2020 Posted April 20, 2020 (edited) You got all wrong (sorry to say). First always use CLASS whenever possible. It is much more reliable than title. Second your control is totally off. Third you do not need to set Opt as you are trying to use ControlClick and not MouseClick (which would be pertinent then). Anyway try this : #include <WinAPIGdiDC.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <Array.au3> $hWnd = WinGetHandle("[CLASS:MSPaintApp]") If not $hWnd Then Exit MsgBox ($MB_SYSTEMMODAL,"","Paint must be started") ;WinActivate ($hWnd) ;WinWaitActive ($hWnd) $hCtrl = ControlGetHandle ($hWnd, "", "[REGEXPCLASS:Afx:.+:8]") Mousedrag(200,210,400,410) Mousedrag(400,410,600,210) Mousedrag(600,210,400,010) Mousedrag(400,010,200,210) ControlClick ($hWnd, "", $hCtrl, "left", 1, 100, 100) Func Mousedrag($x1,$y1,$x2,$y2) Local $WM_MOUSEMOVE = 0x0200 Local $MK_LBUTTON = 0x0001 Local $WM_LBUTTONDOWN = 0x0201 Local $WM_LBUTTONUP = 0x0202 _SendMessage($hCtrl, $WM_MOUSEMOVE, 0, _WinAPI_MakeLong($x1, $y1)) _SendMessage($hCtrl, $WM_LBUTTONDOWN, $MK_LBUTTON, _WinAPI_MakeLong($x1, $y1)) _SendMessage($hCtrl, $WM_MOUSEMOVE, 0, _WinAPI_MakeLong($x2, $y2)) _SendMessage($hCtrl, $WM_LBUTTONUP, $MK_LBUTTON, _WinAPI_MakeLong($x2, $y2)) EndFunc That will work even in background. If you want to see it live, just uncomment the win* function. ps. when posting code, please use this tool. Edited April 20, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BigLenny Posted April 21, 2020 Author Posted April 21, 2020 20 hours ago, Nine said: You got all wrong (sorry to say). First always use CLASS whenever possible. It is much more reliable than title. Second your control is totally off. Third you do not need to set Opt as you are trying to use ControlClick and not MouseClick (which would be pertinent then). Anyway try this : #include <WinAPIGdiDC.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <Array.au3> $hWnd = WinGetHandle("[CLASS:MSPaintApp]") If not $hWnd Then Exit MsgBox ($MB_SYSTEMMODAL,"","Paint must be started") ;WinActivate ($hWnd) ;WinWaitActive ($hWnd) $hCtrl = ControlGetHandle ($hWnd, "", "[REGEXPCLASS:Afx:.+:8]") Mousedrag(200,210,400,410) Mousedrag(400,410,600,210) Mousedrag(600,210,400,010) Mousedrag(400,010,200,210) ControlClick ($hWnd, "", $hCtrl, "left", 1, 100, 100) Func Mousedrag($x1,$y1,$x2,$y2) Local $WM_MOUSEMOVE = 0x0200 Local $MK_LBUTTON = 0x0001 Local $WM_LBUTTONDOWN = 0x0201 Local $WM_LBUTTONUP = 0x0202 _SendMessage($hCtrl, $WM_MOUSEMOVE, 0, _WinAPI_MakeLong($x1, $y1)) _SendMessage($hCtrl, $WM_LBUTTONDOWN, $MK_LBUTTON, _WinAPI_MakeLong($x1, $y1)) _SendMessage($hCtrl, $WM_MOUSEMOVE, 0, _WinAPI_MakeLong($x2, $y2)) _SendMessage($hCtrl, $WM_LBUTTONUP, $MK_LBUTTON, _WinAPI_MakeLong($x2, $y2)) EndFunc That will work even in background. If you want to see it live, just uncomment the win* function. ps. when posting code, please use this tool. wow thank you! works great!
BigLenny Posted April 22, 2020 Author Posted April 22, 2020 On 4/20/2020 at 11:15 PM, Nine said: You got all wrong (sorry to say). First always use CLASS whenever possible. It is much more reliable than title. Second your control is totally off. Third you do not need to set Opt as you are trying to use ControlClick and not MouseClick (which would be pertinent then). Anyway try this : #include <WinAPIGdiDC.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <Array.au3> $hWnd = WinGetHandle("[CLASS:MSPaintApp]") If not $hWnd Then Exit MsgBox ($MB_SYSTEMMODAL,"","Paint must be started") ;WinActivate ($hWnd) ;WinWaitActive ($hWnd) $hCtrl = ControlGetHandle ($hWnd, "", "[REGEXPCLASS:Afx:.+:8]") Mousedrag(200,210,400,410) Mousedrag(400,410,600,210) Mousedrag(600,210,400,010) Mousedrag(400,010,200,210) ControlClick ($hWnd, "", $hCtrl, "left", 1, 100, 100) Func Mousedrag($x1,$y1,$x2,$y2) Local $WM_MOUSEMOVE = 0x0200 Local $MK_LBUTTON = 0x0001 Local $WM_LBUTTONDOWN = 0x0201 Local $WM_LBUTTONUP = 0x0202 _SendMessage($hCtrl, $WM_MOUSEMOVE, 0, _WinAPI_MakeLong($x1, $y1)) _SendMessage($hCtrl, $WM_LBUTTONDOWN, $MK_LBUTTON, _WinAPI_MakeLong($x1, $y1)) _SendMessage($hCtrl, $WM_MOUSEMOVE, 0, _WinAPI_MakeLong($x2, $y2)) _SendMessage($hCtrl, $WM_LBUTTONUP, $MK_LBUTTON, _WinAPI_MakeLong($x2, $y2)) EndFunc That will work even in background. If you want to see it live, just uncomment the win* function. ps. when posting code, please use this tool. Hey! Im trying to use this with google chrome, to make it open and close tabs, right now I have it like this: #include <WinAPIGdiDC.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <Array.au3> $hWnd = WinGetHandle("[CLASS:Chrome_WidgetWin_1]") If not $hWnd Then Exit MsgBox ($MB_SYSTEMMODAL,"","Paint must be started") ;WinActivate ($hWnd) ;WinWaitActive ($hWnd) $hCtrl = ControlGetHandle ($hWnd, "", "[REGEXPCLASS:Intermediate D3D Window1]") ControlClick ($hWnd, "", $hCtrl, "left", 1, 100, 100) ControlClick ($hWnd, "", $hCtrl, "left", 1, 473, 24) I suppose I got the Class name wrong?
Nine Posted April 22, 2020 Posted April 22, 2020 Did you take a look at WebDriver ? Not sure how it would work with autopy, you can ask in thread. As for you question, do not use REGEXPCLASS if the control is static. In Paint every instance has a different class, that is why I used RegExp. But in your case, it definitely looks static, so just use it as is. Also check the content of $hCtrl to make sure you got a working handle. Again, take a timeout to look at WebDriver, cause sooner or later you will hit a wall and you will be forced to use the UDF (or UIAutomation UDF) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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