dougb1 Posted October 12, 2010 Report Share Posted October 12, 2010 Hi All, Scenario. Program A puts a bit of data onto the clipboard and displays a window. When the user sees the window created by Program A, they press F9 to activate the MacroExpress macro. ME macro gets data off clipboard and parses out what it needs. It then uses Activate Window followed by Wait For Window Title to ensure that Application B has focus. It then sends some keystrokes via Text Type to activate a search dialog from the menus in Application B which has a title of "Input". The macro then uses Activate Window "Input" and Wait for Window Title "Input" before sending keystrokes to the window to perform the search from the clipboard data. Problem: On occasion, the Input window isn't detected. This tells me that either the keystrokes to Program B didn't get there to activate the window or because of a timing issue, not all the keystrokes made it to Program B. I added debugging to a log file as well as added LogErrors at the top of the macro. The macro is aborting stating 'The window "Input" did not appear within the specified time.'. I have a message written to the debug log file immediately after I do the Wait For Window Title of Program B so I'm pretty confident that Program B had/has focus immediately before sending the text to bring up the search dialog "Input". Questions: 1. Is Wait for Window Title the best way to know that a particular window has focus and is ready to accept keystrokes? We had only Activate Window before and I added Wait for Window Title to ensure the app was available to accept keystrokes. I've got the max wait time set to 8 seconds (up from 5) with no change. We used to have the default of 10 minutes and still experienced the problem so I don't think it's the wait length. 2. I tried using GetControl as follows to avoid sending keystrokes to activate the Input window. The control is a general search box always on the screen that does the same thing as the Input box I have to send keystrokes to in order to display: Activate Window: "FACS Workstation (BDEBT)" Get Control %C8% (FACS Workstation (BDEBT): WindowsForms10.EDIT.app3) Set Focus to %C8% Text Type: Text<ENTER> This fails on the Set Focus line stating "The specified control could not be found". I used the Get control utility to detect the control. This would be the preferred way to send the information to Program B. Am I missing something in order to send keystrokes to the control? Regarding #1, I've added in a hard Wait of 75MS before sending the keystrokes and slowed down the keystrokes to 50 MS but the problem is still happening (perhaps a little better but not foolproof). I've also added new code to write all the visible windows to the debug file - I'm curious if Input really does exist or not. I would expect to NOT see Input in the list of window titles. Thanks, Doug Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.