Jump to content

How to simulate Clicks on an Inactive Window


Recommended Posts

Hello,

I managed to get a basic script working that logs into the erp system, runs a stored procedure with parameters etc and waits for the results.
Now I'm facing a problem of how to trigger the last action, which is to execute export into excel.
In the erp's gui, this is done by a dedicated toolbar, that is not accessible by any shortcut key (I did read the accompanying docs), cannot be reached by Tab etc.
I have to click the "Actions" listbox and then one of the list options (Export to Excel) = click Actions, wait, click Export to Excel option from the scroll-down.

image.png.c7e5fd1e631ff1721181bbbe955c4ae8.png

I can do it using the click commands, but they only work on active window and I need this to run on server.
I tried ControlClick with the correct windows handle and without controlId (with various x,y coordinates) without success. To minimise the risk on not providing the right x,y coordinates, I put them into double for-to loops, incrementing each 1-500 with some delays... again no result, not a single successfull click. 

Furthermore a custom function recommended elsewhere (_MouseClickPlus) also did not work.
I even tried to list ALL the window controls (cca 100) and manually send their controlId to the ControlClick method.
It clicked all aroung the gui except this very toolbar. 

This is what the info tool provides reg. the toolbar: (another "fun" thing is that the controlIDs change with each instance)
image.png.c1699ce1c93923d11bcf9f2769c6118f.png


In this situation, is there anything you would advise me to do?
Is there perhaps another function worth trying, or try autohotkey or some other scripting tool for this singular purpose?

Thank you,
Daniel

Edited by DanMeow
typo
Link to post
Share on other sites

Have you tried ControlClick with window handle and control handle with the appropriate x/y position within the control ?

Link to post
Share on other sites

I don't have any control handle that would operate this tollbar with the ControlClick (I tried all window control handles manually).
But I guess I could try another control's (completely different in the gui but working with the method) and provide the correct coordinates.
I will report back how it went. Thank you.

Link to post
Share on other sites

Here an example with Window Explorer how to use the toolbar handle to click a specific area :

;Run ("explorer")
;Sleep(500)

Local $hWnd = WinActivate("[CLASS:CabinetWClass]")
;MsgBox ($MB_SYSTEMMODAL,"",$hWnd)

Local $hCtrl = ControlGetHandle($hWnd,"","ToolbarWindow321")
;MsgBox ($MB_SYSTEMMODAL,"",$hCtrl)
Local $aPos = ControlGetPos ($hWnd, "", $hCtrl)
_ArrayDisplay ($aPos)
ControlClick ($hWnd, "", $hCtrl, "left", 1, $aPos[0]+$aPos[2]/3, $aPos[1]+$aPos[3]/2)

Use the CLASSNN to get the handle of the control

Edited by Nine
Link to post
Share on other sites

Oh man, you helped me so much!
This works for the 1st click ("Actions"):

Local $hCtrl = ControlGetHandle($hWnd,"","[NAME:_BrowseToolbar_Toolbars_Dock_Area_Top]")
ControlClick($hWnd, "", $hCtrl, "left", 1, 46, 17)

Now my challenge will be the 2nd click, where the control is not named (and ID's keep changing).
But the fact the instance of the class is 1 looks good. Maybe at least this will remain the same...


image.thumb.png.bca82ee5b3e9a7009de384585a01b2ab.png

TY again!

Link to post
Share on other sites

I believe you could do the same with the new CLASSNN.  Try it with the position (should always be the same) of the Excel export.

Link to post
Share on other sites

got it! 
... and it's a new window (class 808 vs 8, missed it completely at first) 
This works (tested while disconnected from rdc and at different gui positions and sizes)

$hWnd = WinGetHandle("prod: 200 ... [CZK] (1) - QAD Enterprise Applications")
Local $hCtrl = ControlGetHandle($hWnd,"","[NAME:_BrowseToolbar_Toolbars_Dock_Area_Top]")
ControlClick($hWnd, "", $hCtrl, "left", 1, 46, 17)
Sleep(1500)
$hWnd2 = WinGetHandle("[Class:WindowsForms10.Window.808.app.0.2004eee]")
Local $hCtrl2 = ControlGetHandle($hWnd2,"","[Classnn:WindowsForms10.Window.8.app.0.2004eee1]")
ControlClick($hWnd, "", $hCtrl2, "left", 1, 14, 86)

Perfect, TY!

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...