Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to continue the execution of a perl script if the user session gets locked while running it.

by dasgar (Deacon)
on Feb 04, 2014 at 06:40 UTC ( #1073313=note: print w/ replies, xml ) Need Help??


in reply to How to continue the execution of a perl script if the user session gets locked while running it.

That's one of the gotcha's about Windows that I ran into. I don't know all of the technical stuff, but here's some things that I learned a few years ago from trying to automate a GUI program (with and without Perl).

  • If no user is logged in at the local console or remotely via remote desktop, there is no GUI environment. That means no program windows are available to be automated.
  • If the user is logged in via remote desktop and the connection is disconnected, the GUI environment goes away.
  • If the user locks the session (or screensaver kicks in and requires login), the GUI environment goes away.
  • If the user is logged in via remote desktop and does not have the remote desktop window as the active window, the GUI environment goes away.

The above may not be 100% accurate, but that's what I remember encountering in my attempts at automating GUI programs from a few years ago. Also, in the scenarios above where I said the "GUI goes away", any programs that were running continue to run. Windows just isn't using a GUI environment until the user is logged back in and actively using the desktop.


Comment on Re: How to continue the execution of a perl script if the user session gets locked while running it.
Re^2: How to continue the execution of a perl script if the user session gets locked while running it.
by pradeep,krishna (Scribe) on Feb 04, 2014 at 06:52 UTC

    Thanks buddy... but the thing i am asking is about locked user session not for user who is logged off..

        No buddy. I don't want any user to interact after the system is locked. I just want my automation to continue if the user locks the session in the middle of execution.

      but the thing i am asking is about locked user session not for user who is logged off..

      That's the same thing as the 3rd scenario that I listed. In that scenario, all running programs (including GUI-based applications) will continue to run. However, Windows does away with the GUI environment until the user logs back in. With no GUI environment, there is no way (as far as I can tell) to automate interactions with a GUI-based application.

      This is something that drove me crazy when I ran into it a few years ago. I ran out of time with what I was working on, so I just accepted that this was a limitation that I had to live with.

      marto does have a good point. I had not thought of the situation from that perspective, but it does make sense when I look at it from that view point.

      Guess I learned something new.

      A few years ago when I was looking at automating a GUI application, I got lost with the documentation of Win32::GuiTest. Doing some Google searching, I came across AutoIt gave that a shot. Then I hit the issue that you're hitting. So I tried looking into Win32::GuiTest again. The docs made more sense, but I still hit the same issue with using Win32::GuiTest.

      Anyways, I thought I would hit AutoIt's web site to see if they had any information about this type of scenario and found the following in their FAQ: Why doesn't my script work on a locked workstation?

      They provide more information about what is happening and offer some alternatives. I tried looking into the documentation of Win32::GuiTest to see if I can find the equivalent functions. I'm not sure if Win32::GuiTest exposes those functions or not.

      On one hand, if the information in the AutoIt FAQ is correct, there is a glimmer of hope for what you are wanting to do. On the other hand, I'm not sure I know how to advise you to apply those alternatives from that FAQ in your Perl script using Win32::GuiTest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073313]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (16)
As of 2014-10-23 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (128 votes), past polls