Jump to content

ControlClick doesn't work at the end of the script


Recommended Posts

Hi everyone,

I need your help on a strange issue. I'm trying to write a script that will read selected shape's "Tag No" which is a string from Microsoft Visio and search for that string in an application called "Aveva Instrumentation Engineer" and open the Edit dialogue window. Please see the script below that works until the last line which presses the Edit button on the Toolbar.

#include <AutoItConstants.au3>
Global $oVisio = ObjGet("", "Visio.Application")
Global $oVSD = $oVisio.ActiveWindow
Global $oShp = $oVSD.Selection.PrimaryItem
Global $Copy = $oShp.Cells("User.AssignedTag").ResultStr("") ; Copy the shape's Tag No
Local $hWnd = "AVEVA Instrumentation Engineer"
WinActivate($hWnd) ; Activate the main window
Send("^f") ; Open the Find dialog with ctrl^f
$hWnd = WinWait("Find and Replace")
WinActivate($hWnd) ;activate the find dialogue
ControlSetText("Find and Replace", "", "[CLASS:Edit; INSTANCE:1]", "") ; empty the text box
ControlSetText("Find and Replace", "", "[CLASS:Edit; INSTANCE:1]", $Copy) ; Paste the shape's Tag No to the textbox
ControlClick("Find and Replace", "", "[CLASS:WindowsForms10.BUTTON.app.0.2bf8098_r14_ad1; INSTANCE:1]") ; Press "Find Next" button and item with specified Tag No will be highlighted in the datagrid
ControlClick("Find and Replace", "", "[CLASS:WindowsForms10.BUTTON.app.0.2bf8098_r14_ad1; INSTANCE:2]") ; Press Close button to close Find dialogue
WinWaitActive("AVEVA Instrumentation Engineer") ; activate back the main window
ControlClick("AVEVA Instrumentation Engineer","","[CLASSNN:WindowsForms10.Window.8.app.0.2bf8098_r14_ad117]","left",1,280,91) ; Press the Edit button on the Toolbar to open Edit dialogue

ControlClick Issue.png

When the script runs, it finds the related row in the grid but does not press the edit button on the toolbar. In order to see if the issue is with the ControlClick command, I made another script with a single line which is the last line of the script above

ControlClick("AVEVA Instrumentation Engineer","","[CLASSNN:WindowsForms10.Window.8.app.0.2bf8098_r14_ad117]","left",1,280,91)

When this script runs while a row is selected on the grid, it opens the Edit dialogue box without a problem. But when I use the same command in my main script it doesn't work. I put sleep(2000) before the last line but nothing changed. I dont know what I'm doing wrong.

Any kind of help is appreciated.

Regards

Emre

Link to comment
Share on other sites

Nothing changed Bert. When I close the Find dialogue with ControlClick instance:2, main window becomes active automatically. So the line that you highlighted is not needed actually but I added to make sure that main application window is the active window.

It seems that things are happening too fast in the script and target program does not respond in the same speed but putting a sleep function before the last line didnt work.

Link to comment
Share on other sites

From what I glean from your post the ROW has to be selected for the EDIT button to work (which you do by hand in your test successfully).

Is this row being selected somehow before firing your last ControlClick ?

Your code says it moves there but is it selected?

I have fixed problems like this (where ControlClick doesn't work) sometimes by resorting to using Send TAB to get the "cursor"/"selection" to move to where I need it.

You will then have to test to see what selects it highlights it; ENTER, SPACEBAR etc...

 

Good luck !

Bill

p.s. are you sure there are no keyboard shortcuts for "Edit" for instance?

Sometime clicking the ALT button will show the keyboard shortcuts...

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