dvshnk Posted May 6, 2008 Share Posted May 6, 2008 Ok, I got a weird one here, I am hoping someone can give me some advice on how to fix or work around. My goal is to load and exit out of the game "Oblivion IV" multiple times (Stress test). My script is pretty straight forward, it loads the game, clicks on the splash screen, then uses keyboard Send commands to navigate the menu to load the game, sleep for a bit, and then uses Send commands to exit. The first time it runs through, the game starts and exits with no problems, but on the second loop the game will launch, load the save game, and it ignores the send {esc} call to bring up the exit menu. (after the WinActivte check) My first thought was a simple focus issue. However, WinList shows the main window of the game is titled "Oblivion" and WinActivate shows that it is in focus (logs "1" for both loops). Any thoughts why this is happening? ------------ Script $FILENAME_LOG = "C:\AutoItScripts\log.txt" For $Looptemp = 1 to 2 RunOblivion() Next Func RunOblivion() ShellExecute ("C:\GoldenGames2007\Oblivion\OblivionLauncher.exe") sleep (10000) ; wait for Option/Intro screen, click Play MouseMove(611, 241) MouseDown("left") MouseUp("left") sleep (70000) ; Wait for intro movie to complete send ("{RIGHT}") ;Activate Load Game from menu and select first save point. sleep (2000) send ("{RIGHT}") sleep (2000) send ("{RIGHT}") sleep (2000) send ("{ENTER}") sleep (2000) send ("{ENTER}") sleep (2000) send ("{ENTER}") sleep (60000) ; Loads game and waits $OblActive = WinActivate ("Oblivion") LogToFile ("") LogToFile ($OblActive) send("{ESC}") ; Activate Menu and select Exit game sleep (2000) send ("{UP}") sleep (2000) Send ("{ENTER}") sleep (2000) send ("{DOWN}") sleep (2000) send ("{DOWN}") sleep (2000) send ("{ENTER}") sleep (60000) ; wait for game to unload EndFunc Func LogToFile($LogText) $FileLog = FileOpen( $FILENAME_LOG, 1) FileWriteLine( $FileLog, $LogText) FileClose($FileLog) EndFunc Link to comment Share on other sites More sharing options...
Triblade Posted May 6, 2008 Share Posted May 6, 2008 Why not a ControlSend ( "title", "text", controlID, "string" [, flag] ) Help on that: ControlSend works in a similar way to Send but it can send key strokes directly to a window/control, rather than just to the active window. ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send - and yes it does send shift, ctrl, alt etc. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) 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