kalabal Posted August 22, 2016 Share Posted August 22, 2016 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 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 More sharing options...
Bert Posted August 22, 2016 Share Posted August 22, 2016 what happens when you comment out the line before the control click? WinWaitActive("AVEVA Instrumentation Engineer") ; activate back the main window The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
kalabal Posted August 22, 2016 Author Share Posted August 22, 2016 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 More sharing options...
l3ill Posted August 22, 2016 Share Posted August 22, 2016 (edited) 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 August 22, 2016 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
kalabal Posted August 23, 2016 Author Share Posted August 23, 2016 You really saved my day l3ill. I never thought that program has shortcuts but "Alt" button showed them all. Now I can open edit window with Alt+I+E combination. Big thanks to you Link to comment Share on other sites More sharing options...
l3ill Posted August 23, 2016 Share Posted August 23, 2016 Glad to help ! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example 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