wzc0014 Posted February 12, 2015 Posted February 12, 2015 (edited) I have tried everything I can think of and I cannot get Button 3 to click, it is a button that copies values from the window. And then I switch to another window and want to paste what goes to the clipboard. The problem is that the button never clicks the button. Any suggestions? I am trying to click the "Copy" button Here is a portion of my script: For $i = 1 To $svar5 Sleep (0500) Send("^k") WinActivate("Plot of " & $svar) WinWaitActive("Plot of " & $svar) Sleep(0500) ControlClick("Plot of " & $svar, "", "[CLASS:Button; INSTANCE:3]", 1 , 29 , 1) Sleep(0500) WinActivate($svar2) WinWaitActive($svar2) Send("^v") This is the summary of the Window Info >>>> Window <<<< Title: Plot of PC_0to280 Class: SunAwtFrame Position: 48, 158 Size: 554, 341 Style: 0x16CF0000 ExStyle: 0x00000100 Handle: 0x002E06D2 >>>> Control <<<< Class: Button Instance: 3 ClassnameNN: Button3 Name: Advanced (Class): [CLASS:Button; INSTANCE:3] ID: 3 Text: Copy... Position: 110, 275 Size: 51, 23 ControlClick Coords: 32, 13 Style: 0x5400000B ExStyle: 0x00000000 Handle: 0x002C069A >>>> Mouse <<<< Position: 198, 476 Cursor ID: 0 Color: 0x606060 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< List Save... Copy... Live X=1157, Y=39.3 >>>> Hidden Text <<<< Edited February 12, 2015 by wzc0014
JohnOne Posted February 12, 2015 Posted February 12, 2015 Which mouse button does 1 represent? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted February 12, 2015 Posted February 12, 2015 Also when clicking a button, there is no need to add x,y arguments. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
wzc0014 Posted February 12, 2015 Author Posted February 12, 2015 I tried every variation to the ControlClick command that I could. I just solved it actually, I don't know why but when I had this combination in the command, and made it a double click, it worked. No idea why, but it works.
wzc0014 Posted February 12, 2015 Author Posted February 12, 2015 Well apparently that was a one time thing, back to not working. Open to suggestions. ControlClick("Plot of " & $svar, "", 3, "", 2, "", "")
JohnOne Posted February 12, 2015 Posted February 12, 2015 What is the fourth parameter of ControlClick? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
wzc0014 Posted February 12, 2015 Author Posted February 12, 2015 ControlClick(Window name, text, button/control class, button, # clicks, x pos, y pos)
JohnOne Posted February 12, 2015 Posted February 12, 2015 So which button do you want to click? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
wzc0014 Posted February 12, 2015 Author Posted February 12, 2015 Button 3. The "copy" Button. I used to do this by simply placing the mouse at the coordinates of the button when the window opened but now every time the window opens it moves slightly.
JohnOne Posted February 12, 2015 Posted February 12, 2015 The button parameter refers to which mouse button you would like to use. It's all right there in the documentation as to what to put there, left, right, middle etc... AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
wzc0014 Posted February 12, 2015 Author Posted February 12, 2015 Sorry I thought you meant which button in my window I wanted. I want to left click the copy button. This is what the doc says: ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] ) This is what I have: ControlClick("Plot of " & $svar, "", 3, "", 1, "", "")
JohnOne Posted February 12, 2015 Posted February 12, 2015 ControlClick("Plot of " & $svar, "", 3, "whatever mouse button you want to use goes here") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Cynagen Posted February 12, 2015 Posted February 12, 2015 (edited) Use WindowGetHandle to get a HWnd handle of the window rather than addressing it by name, this way you can guarantee your target. Also, the "" for X and Y positions are superfluous and are not required as they are optional inputs in the first place. Also, because you're not changing the number of clicks to simulate (default = 1), you can actually drop the "" for the button (leaving it default at "left") and clicks. Opt("WinTitleMatchMode",4) $HWnd=WindowGetHandle("[REGEXPTITLE:Plot of .*]") ControlClick($HWnd,"",3) That should do the trick providing you only have 1 copy of the window open. The way you were doing it before by specifying the title of the window, if you're not exact, you're going to fail to click. Opt("WinTitleMatchMode",4) $HWnd=WinGetHandle("[REGEXPTITLE:Plot of .*; CLASS:SunAwtFrame]") For $i = 1 To $svar5 Sleep (0500) Send("^k") WinActivate($HWnd) WinWaitActive($HWnd) Sleep(0500) ControlClick($HWnd, "", 3) Sleep(0500) WinActivate($svar2) WinWaitActive($svar2) Send("^v") Edited February 12, 2015 by Cynagen Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.
wzc0014 Posted February 12, 2015 Author Posted February 12, 2015 ControlClick("Plot of " & $svar, "", 3, "whatever mouse button you want to use goes here") Unfortunately this did not work. It did the same thing as before, just switched to my next window and pasted whatever was last on the clipboard. Use WindowGetHandle to get a HWnd handle of the window rather than addressing it by name, this way you can guarantee your target. Also, the "" for X and Y positions are superfluous and are not required as they are optional inputs in the first place. Also, because you're not changing the number of clicks to simulate (default = 1), you can actually drop the "" for the button (leaving it default at "left") and clicks. Opt("WinTitleMatchMode",4) $HWnd=WindowGetHandle("[REGEXPTITLE:Plot of .*]") ControlClick($HWnd,"",3) That should do the trick providing you only have 1 copy of the window open. The way you were doing it before by specifying the title of the window, if you're not exact, you're going to fail to click. Opt("WinTitleMatchMode",4) $HWnd=WinGetHandle("[REGEXPTITLE:Plot of .*; CLASS:SunAwtFrame]") For $i = 1 To $svar5 Sleep (0500) Send("^k") WinActivate($HWnd) WinWaitActive($HWnd) Sleep(0500) ControlClick($HWnd, "", 3) Sleep(0500) WinActivate($svar2) WinWaitActive($svar2) Send("^v") And this also did not work, it gets hung up at some point, doesn't click the button I don't think, and it also doesn't go to the next window. It just stops after it activates the $Hwnd window.
wzc0014 Posted February 13, 2015 Author Posted February 13, 2015 I tried to understand more about what you did in that code, but what is "Opt" I couldn't find any documentation on it.
Cynagen Posted February 13, 2015 Posted February 13, 2015 I tried to understand more about what you did in that code, but what is "Opt" I couldn't find any documentation on it. AutoItSetOption() Remarks You may use Opt() as an alternative to AutoItSetOption(). Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.
JohnOne Posted February 13, 2015 Posted February 13, 2015 deffoonawindup. ControlClick("Plot of " & $svar, "", "[CLASS:Button; INSTANCE:3]", "left") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
wzc0014 Posted February 13, 2015 Author Posted February 13, 2015 deffoonawindup. ControlClick("Plot of " & $svar, "", "[CLASS:Button; INSTANCE:3]", "left") I appreciate your continued effort, but no, this still does not click the button. It seems so simple and I cannot make it happen.
wzc0014 Posted February 13, 2015 Author Posted February 13, 2015 AutoItSetOption() Remarks You may use Opt() as an alternative to AutoItSetOption(). Thanks, I know I am correctly selecting the window because later in my code I close it and it closes properly.
JohnOne Posted February 13, 2015 Posted February 13, 2015 None of those open windows appear to be titled "plot of 1" or 2 or 3 ... AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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