Jump to content

Two Questions


Recommended Posts

I have two (hopefully) quick questions:

1: Is it possible to have the SplashTextOn display a variable? (See code below)

2: Is it possible to send keys to an application if the windows session is locked via ctrl-alt-del, 'lock computer'?

Here is my code (this is only my second day w/ scripting so forgive the crude code):

;AutoIt Script to log users off of TMS

AutoItSetOption("WinTitleMatchMode", 2)

;How many times to hit 'Escape' if TMS is open
$esctry = 10
;How many minutes until logoff procedure begins
$time = 10

Do
    
If  WinActivate("TMS_WS", "") Then
        SplashTextOn ( "CTMS Logout", "You will be logged out of TMS in %$time% minutes; please log off now!!!!!")
        sleep (5000)
        SplashOff ( ) 
    Else
        MsgBox(0, "Thank You,", "Thank you for logging off of TMS!" )
        Exit
    EndIf
    
    Sleep (55000)
    
    $time = $time - 1
    
Until $time = 0

SplashTextOn ( "CTMS Logout", "You are now being logged out of CTMS.  Do not use your computer at this time.")

Do
    If  WinActivate("TMS_WS", "") Then
        sleep (200)
        ControlSend ( "TMS_WS", "", "", "{esc}" )
        sleep (1000)
    Else
            SplashOff ( )
            MsgBox (0, "Logged Off", "You have been logged off of TMS by the system" )
            Exit
    EndIf
        
    $esctry = $esctry + 1  
    
Until $esctry = 0

SplashOff ( )
Exit
Link to comment
Share on other sites

1) SplashTextOn ( "CTMS Logout", "You will be logged out of TMS in " & $time & " minutes; please log off now!!!!!")

The same trick works virtually on any AutoIT function.

2) Haven't tested it, but you may if you like. It's not difficult.

Link to comment
Share on other sites

Thanks the & $time & worked great!

As far as my second question, what I meant to say was that the 'ControlSend' doesn't seem to work properly when the computer is locked by the user. At least the way I have it setup, currently. Are there any other options for sending key strokes to an application while the desktop is locked?

Thanks again,

Edited by mjg
Link to comment
Share on other sites

I don't think so. Actually the only way of sending something is via Send(), ControlSend() etc.

I don't have the time to test your code ATM; maybe someone else can help you with this.

Link to comment
Share on other sites

Or if there is even a better solution for doing this. Basically it goes through the first part of the script fine, then it pauses to send the key strokes until the computer is unlocked. Once it is unlocked, it finishes the script fine.

-mjg

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...