Help needed - Script is not running in Windows XP
Moderators: Dorian (MJT support), JRL
Help needed - Script is not running in Windows XP
Hello,
My scripts work well in Windows Vista. I am using a dual monitor where I have Mjtnet open in one window and my windows application running in other. I have a windows XP machine where I want these scripts to run. Its a single monitor and I am having issues here.
Please help!
Thanks.
My scripts work well in Windows Vista. I am using a dual monitor where I have Mjtnet open in one window and my windows application running in other. I have a windows XP machine where I want these scripts to run. Its a single monitor and I am having issues here.
Please help!
Thanks.
The message I see is
Error in : Script name
Line: - Specified Window Not Present
Any Subsequent Key Sends In Scripts may cause Exceptions.
I believe it fails to recognize the Setfocus commands. Since my application does not get highlighted, the further commands I pass from scripts is not being recognized.
For example, my script will do something like
SetFocus>Set focus in mainform
Send commands to open a child window or place cursor in the mainform to send some text
Since Setfocus is not working, any commands sent later do not work as well. However the same script works well in Windows Vista (dual monitor not sure if that has any impact).
Thanks for any help/suggestions with this.
Error in : Script name
Line: - Specified Window Not Present
Any Subsequent Key Sends In Scripts may cause Exceptions.
I believe it fails to recognize the Setfocus commands. Since my application does not get highlighted, the further commands I pass from scripts is not being recognized.
For example, my script will do something like
SetFocus>Set focus in mainform
Send commands to open a child window or place cursor in the mainform to send some text
Since Setfocus is not working, any commands sent later do not work as well. However the same script works well in Windows Vista (dual monitor not sure if that has any impact).
Thanks for any help/suggestions with this.
In all cases where I have seen this, the message was correct - i.e. The window REALLY WASN'T OPEN. So of course the SetFocus command cannot focus a window that doesn't exist.Line: - Specified Window Not Present
I suspect there are enough differences in your two machines that timing issues are coming into play. I.e. the dual monitor machine may be more powerful and things are happening faster.
Do you have a WaitWindowOpen command to check to see if the window you *think* is opening is truly opening? Always check after using window commands for a failure like this:
Code: Select all
//Set a timeout for how long to wait for windows to open/close
Let>WW_TIMEOUT=10
WaitWindowOpen>Notepad*
//If the window didn't open in *timeout* seconds, goto a label
IF>WW_RESULT=FALSE,WindowNotFound
Wait>0.5
SetFocus>Notepad*
Another possibility might be that the window name is not exactly the same on the two machines.
A wild card character (*) can be used when window names might be close but not identical. For example, when opening a text file in Notepad the file name displays as part of the Notepad window name. But the word "Notepad" always displays in a Notepad window. You can SetFocus> to any Notepad window regardless of the file name by restricting the name to a partial, leaving out the file name portion and using the wild card character.
SetFocus>Notepad*
A wild card character (*) can be used when window names might be close but not identical. For example, when opening a text file in Notepad the file name displays as part of the Notepad window name. But the word "Notepad" always displays in a Notepad window. You can SetFocus> to any Notepad window regardless of the file name by restricting the name to a partial, leaving out the file name portion and using the wild card character.
SetFocus>Notepad*
I run the scripts after opening the main screen. I manually open the application main window and run the scripts to open child windows in this application.
Before passing a command to open a child window, I check whether the main window is open. (I can see the window is open since I manually opened it. It is minimized). My problem is that the setfocus>mainscreen does not work. Hence the subsequent commands to open child window does not work.
I included the test script from your last comment. Even if the main window is open, the script always returns WindowNotFound.
I did a quick test outside my application:
IfWindowOpen>notepad*,doNotePad
Wait>3
Label>doNotePad
MessageModal>WindowFound
Even if notepad is not open, this script returns WindowFound. I am so confused. I am not sure how to proceed.
Before passing a command to open a child window, I check whether the main window is open. (I can see the window is open since I manually opened it. It is minimized). My problem is that the setfocus>mainscreen does not work. Hence the subsequent commands to open child window does not work.
I included the test script from your last comment. Even if the main window is open, the script always returns WindowNotFound.
I did a quick test outside my application:
IfWindowOpen>notepad*,doNotePad
Wait>3
Label>doNotePad
MessageModal>WindowFound
Even if notepad is not open, this script returns WindowFound. I am so confused. I am not sure how to proceed.
Thanks for your reply. I am using the wildcard to setfocus. However that does not work. I've tried to include more details in my comment. I would appreciate any help!
JRL wrote:Another possibility might be that the window name is not exactly the same on the two machines.
A wild card character (*) can be used when window names might be close but not identical. For example, when opening a text file in Notepad the file name displays as part of the Notepad window name. But the word "Notepad" always displays in a Notepad window. You can SetFocus> to any Notepad window regardless of the file name by restricting the name to a partial, leaving out the file name portion and using the wild card character.
SetFocus>Notepad*
The way your code is written, yes it would. If the "IfWindowOpen" command returns "FALSE" then it simply continues executing commands, so it does the Wait>3 and then it does the MessageModal>IfWindowOpen>notepad*,doNotePad
Wait>3
Label>doNotePad
MessageModal>WindowFound
Even if notepad is not open, this script returns WindowFound
You would need to write it this way:
Code: Select all
IfWindowOpen>Notepad*
MessageModal>WindowFound
Else
MessageModal>Window NOT Found
Endif
Use the Tools -->View System Windows utility from within Macro Scheduler when your main application is running. Then you can cut/paste the actual window title. And as always, using the asterisk wildcard is usually recommended.
Thanks again.
Here's a portion of my code:
Let>username=[email protected]
Let>passwd=test
Change Directory>C:\Go to Directory path where application is installed
ExecuteFile>Test.exe , Key
Wait>2.0
//The code below passes a user credential to the Authentication (Login page)
IfWindowOpen>Authentication*
SetFocus>Authentication*
Press Shift
Press tab
Release Shift
Wait>0.2
Press Delete
Wait>1.0
Send>username
Wait>1.0
Press Tab
Wait>1.0
Send>passwd
Wait>1.0
Press Alt
Send>L
Release Alt
Else
MessageModal>>Authentication Window Not Found
EndIF
//Once Login successful, the main form of the application opens.
Wait>2.0
IfWindowOpen>MainForm*
Wait>15
SetFocus>MainForm*
Wait>2
Press Alt
Send>n
Release Alt (Alt +N is to open a child window to test something)
Else
MessageModal>Mainform Not Found
EndIf
Authentication window works fine. However the last part (Alt +N) to the main window never opens the child window. IfWindowOpen succeeds and there is a pause for 15 seconds for the main form to load, then the focus goes away. SetFocus>MainForm* does not work. I've verified the names are specified correct. At this stage, MainForm Not found does not pop up since it succeeded before.
I hope my explanation is understandable. please ask me if there are any other questions.
Update: I ran the same script in Vista and it appears to be working fine.
Here's a portion of my code:
Let>username=[email protected]
Let>passwd=test
Change Directory>C:\Go to Directory path where application is installed
ExecuteFile>Test.exe , Key
Wait>2.0
//The code below passes a user credential to the Authentication (Login page)
IfWindowOpen>Authentication*
SetFocus>Authentication*
Press Shift
Press tab
Release Shift
Wait>0.2
Press Delete
Wait>1.0
Send>username
Wait>1.0
Press Tab
Wait>1.0
Send>passwd
Wait>1.0
Press Alt
Send>L
Release Alt
Else
MessageModal>>Authentication Window Not Found
EndIF
//Once Login successful, the main form of the application opens.
Wait>2.0
IfWindowOpen>MainForm*
Wait>15
SetFocus>MainForm*
Wait>2
Press Alt
Send>n
Release Alt (Alt +N is to open a child window to test something)
Else
MessageModal>Mainform Not Found
EndIf
Authentication window works fine. However the last part (Alt +N) to the main window never opens the child window. IfWindowOpen succeeds and there is a pause for 15 seconds for the main form to load, then the focus goes away. SetFocus>MainForm* does not work. I've verified the names are specified correct. At this stage, MainForm Not found does not pop up since it succeeded before.
I hope my explanation is understandable. please ask me if there are any other questions.
Update: I ran the same script in Vista and it appears to be working fine.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Sounds like there is another window on the system somewhere (possibly hidden) with the word "mainform" in it.
Try to be more specific with the window title. Also try setting WF_TYPE to visible windows or non-child windows only. Or use RegEx for a more specific match. If possible specify the entire title for an exact match without using the asterisk.
See the section "Be Specific" in:
http://www.mjtnet.com/blog/2008/10/27/t ... le-macros/
Try to be more specific with the window title. Also try setting WF_TYPE to visible windows or non-child windows only. Or use RegEx for a more specific match. If possible specify the entire title for an exact match without using the asterisk.
See the section "Be Specific" in:
http://www.mjtnet.com/blog/2008/10/27/t ... le-macros/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?