toastmonster Posted December 2, 2015 Share Posted December 2, 2015 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: 0x00130240Any anyone offer any advice please? Many thanks. Link to comment Share on other sites More sharing options...
Danp2 Posted December 2, 2015 Share Posted December 2, 2015 Can you explain why you need to click at a specific X/Y position? Does it work if you call the function in it's simplest form, ie:ControlClick("Report Viewer", "", "[NAME:crystalBar]") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
toastmonster Posted December 2, 2015 Author Share Posted December 2, 2015 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 formNothing 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. Link to comment Share on other sites More sharing options...
Kovacic Posted December 2, 2015 Share Posted December 2, 2015 What if you just have the report screen selected, then use a Send Ctrl + P, will that work for you? most applications use Ctrl+P to kick off printing. C0d3 is P0etry( ͡° ͜ʖ ͡°) Link to comment Share on other sites More sharing options...
toastmonster Posted December 2, 2015 Author Share Posted December 2, 2015 Hi Kovacic, I wish it really were that easy! Of course that was the first thing I tried, but it doesn't respond to any keyboard shortcuts, not CTRL-P, nor ALT+anything. Link to comment Share on other sites More sharing options...
Danp2 Posted December 2, 2015 Share Posted December 2, 2015 Did you try it like this?ControlClick("Report Viewer", "", "[NAME:crystalBar]", "left", 1, 413, 11) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danyfirex Posted December 2, 2015 Share Posted December 2, 2015 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 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Shrapnel Posted December 3, 2015 Share Posted December 3, 2015 Give this a read: Link to comment Share on other sites More sharing options...
jdelaney Posted December 3, 2015 Share Posted December 3, 2015 (edited) 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.SaludosAlong 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 December 3, 2015 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 More sharing options...
toastmonster Posted December 3, 2015 Author Share Posted December 3, 2015 Did you try it like this?ControlClick("Report Viewer", "", "[NAME:crystalBar]", "left", 1, 413, 11)Yes, it doesn't press the button. Link to comment Share on other sites More sharing options...
toastmonster Posted December 3, 2015 Author Share Posted December 3, 2015 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:expandcollapse popup>>>> 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 More sharing options...
toastmonster Posted December 3, 2015 Author Share Posted December 3, 2015 (edited) 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 December 3, 2015 by toastmonster 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