Envoi Posted October 7, 2011 Author Share Posted October 7, 2011 (edited) Try this loop and see if it works for you. $sWinTitlePW = "Enter password for" $sWinTitleIPW = "TrueCrypt" $sWinTextIPW = "Incorrect password" WinWait($sWinTitlePW) While WinExists($sWinTitlePW) Or WinExists($sWinTitleIPW, $sWinTextIPW) WinWaitClose($sWinTitlePW) WinWait($sWinTitleIPW, $sWinTextIPW, 1) WinWaitClose($sWinTitleIPW, $sWinTextIPW, 1) WEnd MsgBox(0, "Result", "Correct Password or Cancel Button Clicked.") ;For testing. ;Check to see if the drive is mounted. It checks to see if both the "Enter Password" and the "Incorrect Password" dialog boxes do not exist, then continues the script. Edit: Update Code. Adam I really appreciate your input AdamUL. However, I've got it working right now with a loop that checks for the drive to successfully mount. My issue it the flaky-ness of the looping for this sort of thing. I'm looking for a way to just get a solid response from TrueCrypt that the mounting, or authentication worked correctly. I just want this to be as solid a script as possible, but I have limited tools available to me to write it in. At this point, I've come to grips with having to poll my windows and such to get my feedback. But if you or anyone else can figure out a way for me to avoid using WinWaits / ProcessWaits and such to check for the successful mounting, I'd be ecstatic. Thanks again, though AdamUL for the time and effort you've put into this. I do appreciate it. Edited October 7, 2011 by Envoi Link to comment Share on other sites More sharing options...
AdamUL Posted October 7, 2011 Share Posted October 7, 2011 Thanks, I'm glad I can help. Ok, instead of waiting for TrueCrypt's password prompt, create your own with InputBox. Put the returned string into the Run command using /p option with your other options, or in the password parameter in your UDF, if it has one. Be sure to surround the password with quotes for the command line. InputBox is a blocking function, so the script pauses waiting for the text to be entered, and it has a "password char" parameter. This way you control the password prompt. $sPassword = InputBox("Mount TrueCrypt Volume", "Enter your password.", "", "*M", 100, 125) ;Make the password mandatory. If @error Then Exit 1 EndIf ;Mount TrueCrypt volume here. MsgBox(0, "Result", $sPassword) ;For testing. If an incorrect password is entered, you will still get the incorrect password dialog box. So you will need to watch for that and loop back to the InputBox. You can also control what the drive letter that the volume is mounted to by using DriveGetDrive with type "ALL" to see what drives are currently in use, then find the first available, after C, to use. Then use the /l option, to mount to that drive. You can check to see if the TrueCrypt drive has mounted by using the type "FIXED". If the letter that you just used to mount the drive is in the array, it is mounted. Adam 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