xkazz Posted July 19, 2021 Share Posted July 19, 2021 Hey guys, I am learning autoit and I want my script to open IDM from desktop and it worked. But when I want it to click on a certain pixel (the synchronized queue) using ControlClick it doesn't. ControlClick("Internet Download Manager 6.36","", "", "left" ,1 ,56,316) the mouseclick function works properly: MouseClick("left", 56,316) Where is the syntax error in my controlclick funtion ? I'm using the Syntax Check and it shows no error And what is the difference between ControlClick and MouseClick ? Link to comment Share on other sites More sharing options...
xkazz Posted July 19, 2021 Author Share Posted July 19, 2021 I don't know how to edit the post, I think I can't use ControlClick because I'm not using controlID ? Text seems the most reliable ID but I can't find it in the few times I used the window info. Is this normal ? Also, what controlID I should use in the future ? https://prnt.sc/1d5smnm https://prnt.sc/1d5t9vh Link to comment Share on other sites More sharing options...
Nine Posted July 19, 2021 Share Posted July 19, 2021 (edited) Your position is not right, as you can see by yourself, controlClick use window position where as MouseClick use by default absolute screen coords. You should not use position when you know the control id as you have. Try something like this (I always recommend using handle as you can verify with Au3info.exe tool if they match) #include <Constants.au3> Local $hWnd = WinGetHandle("Internet Download Manager 6.36") If Not $hWnd Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error on win title") ConsoleWrite($hWnd & @CRLF) Local $hCtrl = ControlGetHandle($hWnd, "", "Button2") If Not $hCtrl Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error on button2") ConsoleWrite($hCtrl & @CRLF) Local $iRet = ControlClick($hWnd, "", $hCtrl) ConsoleWrite($iRet & @CRLF) When you post code, use <> as shown Edited July 19, 2021 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted July 19, 2021 Share Posted July 19, 2021 Try like this -- ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
xkazz Posted July 19, 2021 Author Share Posted July 19, 2021 2 hours ago, Danp2 said: Try like this -- ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") Didn't work Does " /ErrorStdOut" count as an error ? anyway here is my simple script: $variable1= TimerInit() $checkWin = WinExists("Internet Download Manager 6.36") Sleep(2000) If $checkWin = 0 Then ShellExecute("Internet Download Manager" , "", @DesktopDir) Sleep(8000) ElseIf $checkWin = 1 Then sleep(3000) ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") EndIf $variable2= TimerDiff($variable1) MsgBox(0, "lesson 3", "beinning time: " & $variable1 & @CRLF & "total bot time: " & $variable2) Link to comment Share on other sites More sharing options...
xkazz Posted July 19, 2021 Author Share Posted July 19, 2021 2 hours ago, Nine said: Your position is not right, as you can see by yourself, controlClick use window position where as MouseClick use by default absolute screen coords. You should not use position when you know the control id as you have. Try something like this (I always recommend using handle as you can verify with Au3info.exe tool if they match) #include <Constants.au3> Local $hWnd = WinGetHandle("Internet Download Manager 6.36") If Not $hWnd Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error on win title") ConsoleWrite($hWnd & @CRLF) Local $hCtrl = ControlGetHandle($hWnd, "", "Button2") If Not $hCtrl Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error on button2") ConsoleWrite($hCtrl & @CRLF) Local $iRet = ControlClick($hWnd, "", $hCtrl) ConsoleWrite($iRet & @CRLF) When you post code, use <> as shown It'll take me some time to grasp this because I'm only few lessons in and I don't know all these commands. But thanks for the help this will push me to learn faster. Link to comment Share on other sites More sharing options...
Nine Posted July 19, 2021 Share Posted July 19, 2021 13 minutes ago, xkazz said: Does " /ErrorStdOut" count as an error ? No it is a standard message from Scite... “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted July 19, 2021 Share Posted July 19, 2021 1 hour ago, xkazz said: Didn't work There are numerous reasons why that could be. Try checking to see what value is returned by the function call. Also, is the target app running under the same user or as an Admin? You could try adding #RequireAdmin to the beginning of your script to see if that has any effect. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
xkazz Posted July 23, 2021 Author Share Posted July 23, 2021 On 7/19/2021 at 10:02 PM, Danp2 said: There are numerous reasons why that could be. Try checking to see what value is returned by the function call. Also, is the target app running under the same user or as an Admin? You could try adding #RequireAdmin to the beginning of your script to see if that has any effect. I only have one user in my pc. Sleep(2000) ;~ ControlClick("Internet Download Manager 6.36", "", "[ControlClick Coords:49,211]", ) ;~ ControlClick ("Internet Download Manager 6.36", "", [ID:1280],left ,1 ,11,10) ;~ ControlClick("Internet Download Manager 6.36", "", 1280) ;~ ControlClick("Internet Download Manager 6.36", "", "[CLASS:Button; INSTANCE:2]", "left" , 1, 49 , 211) here I typed all what I could find about this subject I used them all one by one and nothing changed. And I think ControlClick is a more stable version of MouseClick since changing the window position will ruin the execution of MouseClick Link to comment Share on other sites More sharing options...
Danp2 Posted July 23, 2021 Share Posted July 23, 2021 24 minutes ago, xkazz said: I only have one user in my pc. Not sure how that matters. Did you even look up #RequireAdmin in the help file? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
xkazz Posted July 23, 2021 Author Share Posted July 23, 2021 1 minute ago, Danp2 said: Not sure how that matters. Did you even look up #RequireAdmin in the help file? I didhttps://prnt.sc/1ev7juw Link to comment Share on other sites More sharing options...
Danp2 Posted July 23, 2021 Share Posted July 23, 2021 Ok... so did you try adding this one line to the top of your script and then running it? If so, did the ControlClick work? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
xkazz Posted July 23, 2021 Author Share Posted July 23, 2021 3 minutes ago, Danp2 said: Ok... so did you try adding this one line to the top of your script and then running it? If so, did the ControlClick work? I did with all the 5 possible lines one by one. It showed the "script is running as admin" in all of them except the 1st one because I somehow typed it wrong. Still didn't click where I want it to. Link to comment Share on other sites More sharing options...
Danp2 Posted July 23, 2021 Share Posted July 23, 2021 With the IDM app already loaded, please run each of the following code snippets and post the results from the Scite output window -- $iResult = ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") ConsoleWrite("Non-admin result = " & $iResult & @crlf) #RequireAdmin $iResult = ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") ConsoleWrite("Admin result = " & $iResult & @crlf) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
xkazz Posted July 23, 2021 Author Share Posted July 23, 2021 2 minutes ago, Danp2 said: With the IDM app already loaded, please run each of the following code snippets and post the results from the Scite output window -- $iResult = ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") ConsoleWrite("Non-admin result = " & $iResult & @crlf) #RequireAdmin $iResult = ControlClick("Internet Download Manager","", "[CLASS:Button; INSTANCE:2]") ConsoleWrite("Admin result = " & $iResult & @crlf) Thanks again for your efforts. >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Zak\Documents\test333 l3.au3" Non-admin result = 1 >Exit code: 0 Time: 1.306 >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Zak\Documents\test333 l3.au3" Admin result = 1 >Exit code: 0 Time: 1.306 I think I'll just avoid this command from now on. I'll use mouseclick mousemove winsetstate and winmove. Do you think they are enough? 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