Jump to content

ControlClick will not click button


wzc0014
 Share

Go to solution Solved by wzc0014,

Recommended Posts

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
Link to comment
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, "", "")
Link to comment
Share on other sites

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.

Link to comment
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. 

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...