I'm using AutoIt to automate the handling of a proprietary Windows EHR application, and it looks like the creators of the application wrote it without adding classes, IDs, or names to any of their links or menu items inside the application. The application I'm trying to automate is PrimeSUITE by Greenway Health.
I've gotten it to work by using MouseClick
and adding coordinates, but that only works so long as the user doesn't move the Window. I'd like to use the more reliable ControlClick
method to send click commands (I don't think there's a third way to send click commands in AutoIt).
Luckily, there's a keyboard shortcut built into the application to open the menu item I want in a new window. This is how I'm currently having to access the menu item:
WinActivate(": PrimeSUITE -- #CompanyName# -- PRIMESUITETEST")
Send("{F7}")
WinActivate("Report Selection -- Webpage Dialog")
WinWaitActive("Report Selection -- Webpage Dialog")
At this point I have to rely on the window's position on the screen not moving, so that I can send MouseClick
coordinates (whose origin point begins in the top-left corner of my monitor screen, rather than the current active Window's top-left corner).
I'd like to be able to activate it somehow like:
ControlClick( ": PrimeSUITE -- #CompanyName# -- PRIMESUITETEST", "Reporting", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "left", 1, 491, 15)
So that the coordinates are relative to the active window's top-left corner rather than the monitor screen's top-left corner.
For context, this is what I see when I am hovering in the application's main window (note, the application is run from the desktop; it's not a web app accessed in IE), no matter which part, regardless of whether I'm in a blank space or hovering a link/menu item:
But as soon as I hover over a menu item and then move the cursor to a submenu item, I get this:
Here is the Tree View of what Inspect.exe found:
Am I going to be stuck with the MouseClick
method via screen coordinates, or is there a way to use ControlClick
or some other way to send clicks programmatically?
Even though it is a desktop application it is using IE objects. You can attach to it with _IEAttach and then use _IEAction to click on objects like your menu.
Here is an example of how to attach to PrimeSUITE (you may need to change the window title).
#include <IE.au3>
$hWin = WinGetHandle("PrimeSUITE")
If WinExists($hWin) Then
$oIE = _IEAttach($hWin, "embedded")
_IELoadWait($oIE)
MsgBox(262144, "", _IEBodyReadHTML($oIE))
Else
MsgBox(262144, "", "Window not found.")
EndIf
Once you are attached you can look at the HTML to see how you want to automate the program. You have a lot of IE functions besides _IEAttach that you can use. For example: _IELinkClickByText, _IELinkClickByIndex, _IEFormElementSetValue, and _IEFormElementOptionSelect.