cmb99 Posted September 1, 2005 Share Posted September 1, 2005 (edited) [sorry initially posted in the wrong forum] Having trouble with this script. The first block runs well. The second block is an exact duplicate of the first, but once the dialog comes up "New Login", ControlSend quits, and no text is sent. I can't figure out why the first block would work and not the second. As a test, I deleted the first block, now the second block works, but not the third. It's as if I only get one chance with ControlSend. ; Block 1 Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") If WinWait("New Login") Then ControlSend("New Login", "", "", "XXXX{TAB}XXXX{ENTER}", 0) EndIf If WinWait("Universal Account UXXX") Then WinSetState("Universal Account UXXXX", "", @SW_MINIMIZE) EndIf ; Block 2 Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") If WinWait("New Login") Then ControlSend("New Login", "", "", "XXXX{TAB}XXXX{ENTER}", 0) EndIf If WinWait("Universal Account UXXX") Then WinSetState("Universal Account UXXX", "", @SW_MINIMIZE) EndIf ; Block 3 Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") If WinWait("New Login") Then ControlSend("New Login", "", "", "XXXX{TAB}XXXX{ENTER}", 0) EndIf If WinWait("Universal Account UXXX") Then WinSetState("Universal Account UXXX", "", @SW_MINIMIZE) EndIf Exit Edited September 1, 2005 by cmb99 Link to comment Share on other sites More sharing options...
MHz Posted September 1, 2005 Share Posted September 1, 2005 As to launching 3 exact same blocks of code, to the same program. You may need to use WinWaitActive and possibly Send to deal with the active window, else AutoIt maybe torn between the 3? Another alternative, could be to rename each window to make them distinct. You can continue to use them reliably with Control*() functions then. Link to comment Share on other sites More sharing options...
cmb99 Posted September 1, 2005 Author Share Posted September 1, 2005 As to launching 3 exact same blocks of code, to the same program. You may need to...Close, it is actually running the same program three times, multiple instances. I don't see why they should interfere. The minimize command after the first block works, BTW, so I think it si successful. Link to comment Share on other sites More sharing options...
cmb99 Posted September 1, 2005 Author Share Posted September 1, 2005 (edited) In fact, this code works. IT is only because, I am attempting to ultimately (haven't tried it yet) get this script to work when the PC is locked, that I am experimenting with ControlSend. Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") WinWaitActive("New Login") Send("XXXX") Send("{TAB}", 0) Send("XXXX") Send("{ENTER}",0) WinWaitActive("Universal Account UXXX") WinSetState("Universal Account UXXX", "", @SW_MINIMIZE) Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") WinWaitActive("New Login") Send("XXXX") Send("{TAB}", 0) Send("XXXX") Send("{ENTER}",0) WinWaitActive("Universal Account UXXX") WinSetState("Universal Account UXXX", "", @SW_MINIMIZE) Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") WinWaitActive("New Login") Send("XXXX") Send("{TAB}", 0) Send("XXXX") Send("{ENTER}",0) WinWaitActive("Universal Account UXXX") WinSetState("Universal Account UXXX", "", @SW_MINIMIZE) Edited September 1, 2005 by cmb99 Link to comment Share on other sites More sharing options...
MHz Posted September 1, 2005 Share Posted September 1, 2005 As active windows does work, then the concept of renaming the windows with WinSetTitle() will allow the distinction between them should allow Control*() functions to work correctly. WinGetHandle() could be another idea to use? Link to comment Share on other sites More sharing options...
cmb99 Posted September 1, 2005 Author Share Posted September 1, 2005 As active windows does work, then the concept of renaming the windows with WinSetTitle() will allow the distinction between them should allow Control*() functions to work correctly. WinGetHandle() could be another idea to use?<{POST_SNAPBACK}>I didn't know I could use WinSetTitle on a program created by someone else. Will try. How fo I get WinGetHandle for Java objects? Window Spy only gives me a title and a class (which does not work on its own BTW). Link to comment Share on other sites More sharing options...
cmb99 Posted September 1, 2005 Author Share Posted September 1, 2005 Ok WinSetTitle does not work. But, interestingly, if I use: ;Second block Run("C:\Program Files\Java\jre1.5.0\bin\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\PROGRA~1\Jts", "C:\PROGRA~1\Jts") If WinWait("New Login") Then MsgBox(1, "Test", "Got Here!") ; <==== ControlSend("New Login", "", "", "XXXX{TAB}XXXX{ENTER}", 0) EndIf If WinWait("Universal Account UXXX") Then WinSetState("Universal Account UXXX", "", @SW_MINIMIZE) EndIf as the second block, and I hit CANCEL at the MsgBox, script execution resumes normally, until the third block. Seems like a bug? Link to comment Share on other sites More sharing options...
MHz Posted September 1, 2005 Share Posted September 1, 2005 You could replace the msgbox with a Sleep(). It does not mean it is a bug. It could mean that the window is not prepared to handle the input at that time. Another option is to increase the WinWaitDelay. This options allow for a fine tune of operation. Normally it is set at 250. You can increase to add more reliability. Opt("WinWaitDelay", 250) Automation sometimes is not a straight forward concept. I believe java applications are alittle slow. So AutoIt may need to be slowed a bit to respond to it? It is good that you found the problem. You can also use ControlSendText() to send text to the control and also for the sake of checking, use ControlGetText(). Yep, it's all good fun. 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