Excel
(1)
WshScriptExec
(1)
FindWindow
(1)
SendKeys
(1)
StdIn
(1)
Sanseen
(1)
Windows
(1)
Saneen
(1)

Alternate to Send keys on a locked machine

Asked By Ajay
20-Dec-09 05:39 PM
I have a Shell script to run macros from an excel sheet and these
macros from the excel sheet inturn prompt message boxes at each start
and completion. Now my problem is that i have a script to do all these
but when my system is locked i am not able to execute these scripts
using a scheduler because my pc locks after a specified idle time. I
do not have an option to disable the autolock feature of the pc as it
is a corporate policy. The scripts failed to execute because in
certain parts of the script i have the send keys sending "TAB" and
locked when the pc is locked. My question is there any other way i can
achieve this by keeping the PC locked. I have tried the "FindWindow"
option but somehow dont seem to get it work in Shell Scripts. One
possible solution i can think of is to unlock PC using the Shell
script only during the script execution. But i am not able to achieve
this as well because i would not able to install any 3rd party
applications in my corporate PC. Any help is appreciated by the
members. Thanks in Advance. Cheers, Saneen

Your problem is that you use the SendKeys method.

Pegasus [MVP] replied to Ajay
19-Dec-09 12:16 PM
Your problem is that you use the SendKeys method. Not only will it fail when
the machine is locked but it is also inherently fragile because it gets
tripped up by lots of things such as unexpected pop-up boxes, virus scanner
updates, Windows automatic updates, tasks taking much longer than
anticipated (e.g. because of some resource-heavy background activity). To
make your application robust you should use methods other than SendKeys. As
a fringe benefit you will then solve your current problem. There is a
further fringe benefit: Your Excel stuff will run much faster.

Ajay wrote:hi Sanseen,The script is running under the scheduler, and your pcis

mr_unreliable replied to Ajay
19-Dec-09 09:45 PM
hi Sanseen,

The script is running under the scheduler, and your pc
is locked due to inactivity, so I am guessing that you
are not around.

If you are not around but expecting to use sendkeys,
then the answers to the dialogs must already be built
into your script.

If you can change the XL macro code, then you could
write your info/data into a temporary file, and then
have the XL macro read the file rather than use a
dialog to get the info/data.   Or an even more direct
solution would be to enter your data into an unused
area of the worksheet and have the macro pick it up
from there (and then clear those cells when you are
done).

If you can _not_ change the XL macro, then I think you
are SOOL.

Er well, on second thought maybe there is another
possibility.  It may be possible to "pipe in" your
input via the "StdIn" mechanism.  Take a look at the
conjunction with an XL dialog (or any other dialog),
but it may be worth a shot.

cheers, jw
Post Question To EggHeadCafe