scouser27 Posted March 8, 2004 Share Posted March 8, 2004 (edited) Hi there, What a great tool AUTOIT is, however I have one small question regarding running a nightly script using the W2K Scheduler. My workstation is locked and I am attempting to launch a program file. The program file launches but never gets focus and therefore my script cannot run to completion. If I run the script on schedule with the workstation open, then it works like a charm. Is there a work around ? Is it a windows problem ? I am using a Beta version of v3, but I'm not sure if an upgrade would solve this particular problem Thanks in advance - Geoff Edited March 8, 2004 by scouser27 Link to comment Share on other sites More sharing options...
Developers Jos Posted March 8, 2004 Developers Share Posted March 8, 2004 Did you try working with the control commands ? Maybe you can show the script and explain where it gets stuck ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
scriptkitty Posted March 8, 2004 Share Posted March 8, 2004 (edited) Control functions might be a better way to go, or possibly having the workstation unlock through a script, lockout user imput while running (most likely late at night anyhow) and then relocking. ( I may try to play around with this consept, but I already see a few problems with this aproach.) Typically if you try to run a program in locked mode, or remotely, most windows OS will not act kindly to these functions since there is actually no active window: WinActivate WinActive WinWaitActive WinWaitClose WinWaitNotActive edit.. many removed...not tested all of the above. I will test out a few senarios later. edit.. many windows funtions work while locked, I need to check remote functions seperately now.... Edited March 8, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scouser27 Posted March 8, 2004 Author Share Posted March 8, 2004 Thanks for the reponses ... On an unlocked machine the following script works.. ; ; Script will run Primavera and automatically log on .. via ENTER key ; Run("C:\Program Files\Primavera TeamPlay\Project Manager\TPPM.exe") WinWaitActive("Login to TeamPlay Project Manager") Send ("{ENTER}") On a locked workstation, the window does not have focus and therefore the Send - ENTER is never called. How do I send a ControlCommand in this case ? Thanks for all your help - folks !!! If anyone has a script to unlock the workstation that would be great !!! - Geoff Link to comment Share on other sites More sharing options...
scriptkitty Posted March 8, 2004 Share Posted March 8, 2004 (edited) try this: Run("C:\Program Files\Primavera TeamPlay\Project Manager\TPPM.exe") While 1 If ProcessExists ( "TPPM.exe" ) Then ExitLoop Wend sleep(2000); just incase has long load times ControlSend ("Login to TeamPlay Project Manager", "", "", "{enter}") ;WinWaitActive("Login to TeamPlay Project Manager") ;Send ("{ENTER}") These commands work, but check task manager to make sure of process name. edit... It would be best to actually have the field that you hit enter in or button, with AutoIt Window Spy, but this should work. ControlSend and ControlClick work fine on my Win2k machines while locked. Some programs need the classnameNN, ex: ; Open windows explorer to hiddensoft.com and run this ControlSend("HiddenSoft","","","{pgup}"); will not work sleep(1000) ControlSend("HiddenSoft","","Internet Explorer_Server1","{pgdn}");Works fine Edited March 8, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scouser27 Posted March 8, 2004 Author Share Posted March 8, 2004 Thanks for your help ScriptKitty, That code still left me in the same position as before, without focus on the login prompt. Is there a way I can find out a classnameNN for an application or is this a variable that I can assign ? I'm still unsure of what the controls are actually supposed to do Thanks again Link to comment Share on other sites More sharing options...
scriptkitty Posted March 8, 2004 Share Posted March 8, 2004 (edited) Use the included AutoIt Window Spy that installs with all AutoIt3 instalations. Move mouse over the part you want in focus, and look at the words under: >>>>>>>>( Last Control Under Mouse )<<<<<<< Class: MozillaWindowClass7 Text: In this case, the control is:MozillaWindowClass7 In this case it would be done like this: ControlSend ("Login to TeamPlay Project Manager", "", "MozillaWindowClass7", "{enter}") Quite nice after you get the hang of it, and you also use this for clicking and such. edit... I'm still unsure of what the controls are actually supposed to doThink of a control as anything windows reacts with, a box, a button, an edit field, a titlebar display, etc. First time you use controls they sound complicated. Edited March 8, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scouser27 Posted March 8, 2004 Author Share Posted March 8, 2004 ScriptKitty, you are a STAR !!! That worked !! One last question if I may be so bold. What would the equivalent of WinWaitActive using controls ? If I can solve this one then I think I will be able to convert my whole script. Thanks so much !!! - Geoff Link to comment Share on other sites More sharing options...
Developers Jos Posted March 8, 2004 Developers Share Posted March 8, 2004 What would the equivalent of WinWaitActive using controls ? All you need to do is wait til the window exists . the winwaitactive will wait until the window has the focus. So just a WinWait ( "title" [, "text" [, timeout]] ) should be enough... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
scouser27 Posted March 8, 2004 Author Share Posted March 8, 2004 (edited) Thanks JdeB..I found that I was more successful by putting a ControlFocus in a loopControlFocus("WinName", "", "TCUltraButton5")While @error = 1 sleep(2000) ControlFocus("WinName", "", "TCUltraButton5")WendThe WinWait did not work as I expected, do I have to use WinWait in conjunction with ControlFocus ?Thanks again- Geoff Edited March 8, 2004 by scouser27 Link to comment Share on other sites More sharing options...
scriptkitty Posted March 8, 2004 Share Posted March 8, 2004 I will doublecheck to see if winexist() works when locked, that is why I coded like: While 1 If ProcessExists ( "TPPM.exe" ) Then ExitLoop Wend Winwait may work when locked, I will check after I eat lunch. Test winwait out and see if you like. Run("C:\Program Files\Primavera TeamPlay\Project Manager\TPPM.exe") WinWait("Login to TeamPlay Project Manager") ControlSend ("Login to TeamPlay Project Manager", "", "MozillaWindowClass7", "{enter}") AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Valik Posted March 8, 2004 Share Posted March 8, 2004 (edited) Just sleep for a bit. The window only has to exist, it doesn't have to be visible or active for a control function to work. Stick some arbitrary high number in a sleep call and you should be okay. Edited March 8, 2004 by Valik Link to comment Share on other sites More sharing options...
scriptkitty Posted March 8, 2004 Share Posted March 8, 2004 I tested a locked win2k workstation, and these commands worked normally: WinClose WinExists WinKill WinMove WinSetState WinSetTitle WinWait I didn't have time to test them all. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scouser27 Posted March 9, 2004 Author Share Posted March 9, 2004 scriptkitty / Jdeb / Valik, Thanks for all your help ... Link to comment Share on other sites More sharing options...
scouser27 Posted March 10, 2004 Author Share Posted March 10, 2004 (edited) Hi Guys, I decided to upgrade to the 3.0.100 release and found that with my scripts unchanged, that the ControlFocus and / or ControlSend are not working as expected. The code appears to be selecting different controls on the screen. In autoIT Spy I noticed that the Mouse Under Control was a little more verbose, do I need to do something different with these commands between release 3.0.91 and 3.0.100. I wanted to upgrade to 3.0.100 because of the bug fixes to ControlSend. ControlSend acts a little strange when the PC is locked - only send chars lower case for example I can never send a colon, and the special chars such as {DOWN}, may or may not work :- works fine when machine is not locked. Thanks again in advance. - Geoff Edited March 10, 2004 by scouser27 Link to comment Share on other sites More sharing options...
weasel Posted November 16, 2004 Share Posted November 16, 2004 (edited) Hi, i've tested your code and it works very well for unlocked PCs. here the important part: <start> IF WinWait("PC-Duo","wants to connect")THEN ControlFocus ( "PC-Duo", "", "Button1" ) ControlClick ( "PC-Duo", "", "Button1") EndIF <end> Now my problem: It doesn't work at a locked workstation. I tried your solutions written down in this thread but it doesn't work. Aut Spy gives me following feedback: <start> Windows Title >>> PC-Duo ( classname=#32770 ) Last Control Under Mouse >>> Class: Button1 Text: &Accept Visible Window Text >>> Administrator@PDCCORE (<no Available>) wants to connect &Accept &Reject This dialog will be closed automatically in XXX seconds <end> Do i have to put "&Accept" anywhere? The "&Reject"-Button has the class: Button2 Like i said the program works fine (accept the connection via pushing the button1 in unlocked window-mode) but not if windows is locked. Can anyone help me? Ask if you need further informations. mfG me Edited November 16, 2004 by weasel Link to comment Share on other sites More sharing options...
JSThePatriot Posted November 16, 2004 Share Posted November 16, 2004 I see no need for the ControlFocus() if you are just going to click on it. ControlFocus() is so you can ControlSend() something to that control (text box, check box, button). If you are going to be using ControlClick() then try the following and let me know how it works out for you. If WinWait("PC-Duo","wants to connect") Then ControlClick ( "PC-Duo", "&Accept", "Button1") EndIf Hope this helps, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
weasel Posted November 16, 2004 Share Posted November 16, 2004 No it doesn't work when the PC is locked. When the PC is unlocked that script works good. thanks for trying out Link to comment Share on other sites More sharing options...
this-is-me Posted November 16, 2004 Share Posted November 16, 2004 (edited) You have to run your script in the "Desktop" of the program you are trying to click. The program you see is on the "winlogon desktop". Therefore, you will have to run the script as a system service. Try this: http://www.pirmasoft.com/runassvc.php Edited November 16, 2004 by this-is-me Who else would I be? 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