wzc0014

ControlClick will not click button

35 posts in this topic

#1 ·  Posted (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 

Untitled.jpg

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 by wzc0014

Share this post


Link to post
Share on other sites



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. 

Share this post


Link to post
Share on other sites

Well apparently that was a one time thing, back to not working.

Open to suggestions.

ControlClick("Plot of " & $svar, "", 3, "", 2, "", "")

Share this post


Link to post
Share on other sites

ControlClick(Window name, text, button/control class, button, # clicks, x pos, y pos)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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, "", "")

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

I tried to understand more about what you did in that code, but what is "Opt" I couldn't find any documentation on it.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

 

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. 

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now