Jump to content

Help with ControlClick please?


Recommended Posts

Hi everyone,

Can anyone help me with ControlClick please?  I'm trying to click an X/Y position within a control, and nothing is appearing to happen.

Here's the code I'm using:

ControlClick("Report Viewer", "Crystal Controls", "[NAME:crystalBar]", "left", 1, 413, 11)

And this is the output from AU3 Window Info:

>>>> Window <<<<
Title:  Report Viewer
Class:  WindowsForms10.Window.8.app.0.2bf8098_r13_ad1
Position:   418, 36
Size:   880, 692
Style:  0x16CF0000
ExStyle:    0x00050100
Handle: 0x000E0232

>>>> Control <<<<
Class:  WindowsForms10.Window.8.app.0.2bf8098_r13_ad1
Instance:   13
ClassnameNN:    WindowsForms10.Window.8.app.0.2bf8098_r13_ad113
Name:   crystalBar
Advanced (Class):   [NAME:crystalBar]
ID: 1245760
Text:   Crystal Controls
Position:   0, 0
Size:   428, 25
ControlClick Coords:    413, 11
Style:  0x56000000
ExStyle:    0x00000000
Handle: 0x00130240

Any anyone offer any advice please?  Many thanks.

Link to comment
Share on other sites

Can you explain why you need to click at a specific X/Y position?

Yes, the Control has a series of buttons on it, and I wish to push one of the buttons (the Print button, see attached screenshot).  I think the Window Info tool is telling me that the button is indistinguishable from the rest of the control as far as it's concerned, therefore I believe I need to use the X/Y position to click the button.

Does it work if you call the function in it's simplest form

Nothing appears to happen using your suggested code.

The attached screenshot shows me using the Window Info tool and hovering over the Print button, which is the one I wish to push.  You can see the entire control is highlighted, rather than just the button.  I can't use screen X/Y positions because the Report Viewer window appears in a different location each time it is opened.  It doesn't appear to have any keyboard shortcut nor can the menu be activated or navigated using the keyboard.  The ID number of the control also seems to change every time it's opened.

I really appreciate your assistance in this matter.  Many thanks.

screenshot1.png

Link to comment
Share on other sites

I think maybe that is like a bar control menu. maybe using ControlCommand you get it. use some  windows Message Spy and send it with AutoIt.

Saludos

Link to comment
Share on other sites

I think maybe that is like a bar control menu. maybe using ControlCommand you get it. use some  windows Message Spy and send it with AutoIt.

Saludos

Along these lines, if you copied and pasted the full text of the autoit spy tool, we would see if there are any commands that are openly accessible.

Don't send us a screenshot, instead grab all the text and paste it back here...also grab the toolbar tabs output.

 

Try this out...if this returns a value>0, then you can use the other functions to get the command_ids to send:

#include <GuiToolbar.au3>

$hBar = ControlGetHandle("Report Viewer", "", "[NAME:crystalBar]")
ConsoleWrite("$hBar=[" & $hBar & "]" & @CRLF)
$iCount = _GUICtrlToolbar_ButtonCount($hBar)
ConsoleWrite("$iCount=[" & $iCount & "]" & @CRLF)

post back the output.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Along these lines, if you copied and pasted the full text of the autoit spy tool, we would see if there are any commands that are openly accessible.

Don't send us a screenshot, instead grab all the text and paste it back here...also grab the toolbar tabs output.

I thought I'd done that in my initial post?  The 'ToolBar' tab window remains empty.  Here's the full summary:

>>>> Window <<<<
Title:  Report Viewer
Class:  WindowsForms10.Window.8.app.0.2bf8098_r13_ad1
Position:   864, 37
Size:   1009, 713
Style:  0x16CF0000
ExStyle:    0x00050100
Handle: 0x001904F6

>>>> Control <<<<
Class:  WindowsForms10.Window.8.app.0.2bf8098_r13_ad1
Instance:   13
ClassnameNN:    WindowsForms10.Window.8.app.0.2bf8098_r13_ad113
Name:   crystalBar
Advanced (Class):   [NAME:crystalBar]
ID: 525390
Text:   Crystal Controls
Position:   0, 0
Size:   428, 25
ControlClick Coords:    418, 13
Style:  0x56000000
ExStyle:    0x00000000
Handle: 0x0008044E

>>>> Mouse <<<<
Position:   1290, 80
Cursor ID:  0
Color:  0x9999CC

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Main Report
Current Page No.: 1
Crystal Controls
1

>>>> Hidden Text <<<<

 

Try this out...if this returns a value>0, then you can use the other functions to get the command_ids to send:

#include <GuiToolbar.au3>

$hBar = ControlGetHandle("Report Viewer", "", "[NAME:crystalBar]")
ConsoleWrite("$hBar=[" & $hBar & "]" & @CRLF)
$iCount = _GUICtrlToolbar_ButtonCount($hBar)
ConsoleWrite("$iCount=[" & $iCount & "]" & @CRLF)

post back the output.

This is the output in the console window:

$hBar=[0x0008044E]
$iCount=[0]

I'm sorry but I'm not sure what to do with that information.

 

Link to comment
Share on other sites

Give this a read:

 

Hi Shrapnel,

Many thanks for your suggestion.  I was able to use the simplespy.au3 script and the resulting code snippet to successfully automate pressing the Print button.

This is the code it generated:

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Report Viewer;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.2bf8098_r13_ad1", $treescope_children)
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.2bf8098_r13_ad1", $treescope_children)
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Crystal Controls;controltype:=UIA_ToolBarControlTypeId;class:=WindowsForms10.Window.8.app.0.2bf8098_r13_ad1", $treescope_children)
_UIA_Action($oP0,"setfocus")
;~ First find the object in the parent before you can do something
;~$oUIElement=_UIA_getObjectByFindAll("Print.mainwindow", "title:=Print;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Print;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
_UIA_action($oUIElement,"click")

Many thanks!

Edited by toastmonster
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...