Jump to content

Script automation with screen saver


Recommended Posts

I developed a nice automation with autoit to run applications to export csv files on multiple computers. These scripts are started from the windows task scheduler. I also developed a GUI application to download these files to a server for data analysis and reports. It works great. So far, I see a problem with the screen saver preventing the scheduled scripts to complete after it starts. The screen saver requires login by user. How would I get pass the screen saver? Thanks.

Dr SherlockAlways a way

Link to comment
Share on other sites

You need to have the script running as a service. Also, you may need to have it so you do not use any type of keyboard or mouse action to conduct what you need, for the screensaver would prevent what you want to do. Did you look into useing ExcelCOM by Randell?

Link to comment
Share on other sites

Thanks for that Excelcom info. That would be something I believe I would need to massage the csv files assuming I can use it for MS Office xp Pro (2002). I saw other post when ExcelCOM only works with 2003 version. Can you verify.

I need to add more info I guess. Sorry. To get the csv files, I have to use keyboard and mouse actions since the two programs are not standard programs like Office. It is a POS software. Screen saver is the only current blocker. So, I would have a service to log into the screen to get the desktop. Would that be the solution? Thanks again.

Dr SherlockAlways a way

Link to comment
Share on other sites

Hmmm. I will try this for the data management script. Still need to do scripts with mouse and kb actions when windows screen saver is running requiring user to login. Thanks

Dr SherlockAlways a way

Link to comment
Share on other sites

OK. No matter what I cannot use services while I still have some mouse and keyboard controls. The application I am working with have report dialogs that has listboxes, comboboxes, checkboxes, and buttons. The listboxes and comboboxes are controlled by mouseclicks which works fine. But which screen saver, if fails as expected. I used the following commands to simply select item in listbox:

If Not WinActive("Sales Report","") Then WinActivate("Sales Report","")

$hlistbox = ControlGetHandle("Sales Report","","ListBox1")

ControlCommand("Sales Report","",$hlistbox,"SetCurrentSelection",4)

This did not work. AutoIt Window Info shows the listbox as ListBox1, so I should be able to do the item selection. What is wrong here?

Dr SherlockAlways a way

Link to comment
Share on other sites

Hmmm. I will try this for the data management script. Still need to do scripts with mouse and kb actions when windows screen saver is running requiring user to login. Thanks

Maybe in your background script try instantly simulate mouse movement (0 pix and only when computer is idle) to prevent screensaver to run...

Link to comment
Share on other sites

Solve the problem below:

If Not WinActive("Sales Report","") Then WinActivate("Sales Report","")

$hlistbox = ControlGetHandle("Sales Report","","ListBox1")

ControlCommand("Sales Report","",$hlistbox,"SetCurrentSelection",4)

Needs to be from the Beta side:

If Not WinActive("Sales Report","") Then WinActivate("Sales Report","")

$hlistbox = ControlGetHandle("Sales Report","","ListBox1")

$ret = _GUICtrlListSetSel($hlistbox, 1, 1)

Now a couple question:

I am almost done replacing the mouse/KB actions to ControlCommand by first getting the handle on each GUI control object. I still have a couple of ControlClick left. Is ControlClick consider mouse action?

No matter I am replacing everything for no mouse/KB actions. Still, what is 'mut' in the last reply. Final question - now I need to work on making a script run as a service. I saw and reviewed the not tested script. Make sense. Script from Mega below

Func _SrvAny($service, $fullpath, $hidden = 0)

; Adds a program, as a windows service.

; Requires $instsrv and $srvany to be assigned, full paths.

; e.g. _SrvAny ( 'ServiceName', 'FullPath_to_the_program' )

Local $instsrv = @WindowsDir & '\System32\Instsrv.exe'

Local $srvany = @WindowsDir & '\System32\SrvAny.exe'

If FileExists($instsrv) And FileExists($srvany) Then

RunWait($instsrv & ' ' & $service & ' "' & $srvany & '"', '', @SW_HIDE)

Local $key = 'HKLM\SYSTEM\CurrentControlSet\Services\' & $service

If RegRead($key, 'DisplayName') Then

If $hidden Then RegWrite($key & '\Parameters', 'AppParameters', 'Reg_sz', '/hidden')

Return RegWrite($key & '\Parameters', 'Application', 'Reg_sz', $fullpath)

EndIf

EndIf

EndFunc

Do I run this function with each script then cleanup by removing the service or should I leave it there for the next day? Almost there and thanks for the help.

Dr SherlockAlways a way

Link to comment
Share on other sites

Using any of the Control*() functions should be fine.

With _SrvAny(), that will setup a permanent service.

If you want to stop, delete etc. the service, then consider using SC.exe to do that, which would be in (WinXP or above, not sure of W2k) system directory. Just use SC /? at a command prompt for switches available.

:D

Link to comment
Share on other sites

OK. The SC.exe has a create command. If one can delete the service with sc.exe then can't one use the sc.exe support. The sc.exe is supported in XP and W2k (it is in the W2k resource kit which I downloaded). So, _SrvAny() is supported for XP and W2k? I have three systems on the network to automate - 1 is a Win XP Pro and the other two are Win 2000 Pro. I did play and automate with SC.exe in creating and delete in XP. Creation was fine but could not start the service. I am sure I did something wrong. Thanks.

Dr SherlockAlways a way

Link to comment
Share on other sites

Yes. I did the net start and sc start and both gave the errors

C:\Documents and Settings\ws4sadc>sc start test

[sC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.

C:\Documents and Settings\ws4sadc>net start test

The service is not responding to the control function.

More help is available by typing NET HELPMSG 2186.

The error occurs after about 30 seconds. My research so far is telling that there is a bug in the NET Framework. I need to get the NET Framework 1.1 version patch. Check this link out and tell me what you think -- http://support.microsoft.com/kb/839174/.

Getting the updates now and will check back.

Dr SherlockAlways a way

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...