S4nder Posted February 29, 2008 Share Posted February 29, 2008 (edited) Hello,I'am new to AutoIt and trying to make a script that backups employees certificates when the startup.This can be done by the "cipher /x" command.I want to use AutoIt to press enter at this screen: and after that press 2 times enter in the dos/command screen: Sometimes the script works perfect but sometimes i experience a problem.The window got pushed to the background (not active anymore) because other programs are starting as well and the right window wont activate anymore and .Is there some kind of trick to keep activating a window until ok/enter is pressed?This is what i got now:Run ("cipher /x C:\efsbackup\personal") WinWaitActive ("[CLASS:#32770]", "") Send ("{ENTER}") WinWaitActive ("[CLASS:ConsoleWindowClass]", "") Send ("{ENTER}") Send ("{ENTER}")I also tried to do it this way but no results:Run ("cipher /x C:\efsbackup\personal") Sleep (100) If WinExists("[CLASS:#32770]", "") Then If WinActive("[CLASS:#32770]", "") <> 0 Then WinActivate("[CLASS:#32770]", "") EndIf WinWaitActive ("[CLASS:#32770]", "") Send ("{ENTER}") If WinActive("[CLASS:ConsoleWindowClass]", "") <> 0 Then WinActivate("[CLASS:ConsoleWindowClass]", "") EndIf WinWaitActive ("[CLASS:ConsoleWindowClass]", "") Send ("{ENTER}") Send ("{ENTER}") EndifI tried the normal names of the windows but didnt select them, selecting by class works for me.I also tried it with a While...WEnd and Do...Until but didnt work.If there is any missing information or ideas please let me know I've searched this forum with no luck. Edited February 29, 2008 by S4nder Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted February 29, 2008 Share Posted February 29, 2008 Maybe ControlSend()? Not sure if it works with command prompts. -CMR Link to comment Share on other sites More sharing options...
S4nder Posted February 29, 2008 Author Share Posted February 29, 2008 (edited) yes i tried that before and also works, but the problem is it deactivates the first "ok"-"cancel" window so i dont even get to the dos prompt. With deactivating i mean its gray in the taskbar/ not active I think the solution is some kind of loop which keep activating the popup (see picture above) and pressing enter untillit doesnt exists anymore Edited February 29, 2008 by S4nder Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted February 29, 2008 Share Posted February 29, 2008 ControlSend should work even if the window isn't active. Otherwise, just use WinActivate("title","text") before each command sent. Kinda ugly, but it would work. 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