Sign in to follow this  
Followers 0
abhi

Autoit Script as Service, Interacting with Desktop

8 posts in this topic

All,

I have a script that is launched from a service. The script interacts with the desktop to launch and manage a GUI.

I was able to achieve that by running the service as Local system Account(Allowing the service to Interact with desktop)

This technique works only if some user is logged on to that box. In the event that nobody is logged on, the script doesn't behave as expected.

Can somebody throw some light on how to handle such a scenario ? I am using Windows 2000 server.

Thanks

Share this post


Link to post
Share on other sites

Are you using Win"Active" commands, etc? Because no window can be Active when no one is logged on. What does your script actually do?


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

My script(launched by a service) launches a batch file which may or may not throw a dialog. If it does throw a dialog, my script sends an appropriate key stroke in response to the dialog. I was hoping it did that even when no one was logged into the system.

Yes my script does use WinWaitActive() method.

Thanks

Share this post


Link to post
Share on other sites

Thanks lod3N for your suggestion. It helped.

However, when nobody is logged on to the machine where I am testing my script, my scripts efforts to send events like Enter key or mouse click are failing. Following is the snippet of code I have used. The code generates the file but neither Send("{ENTER}") nor the MouseClick() call are working.

Any help would be appreciated. Point to be considered is I am launching the script on a machine where nobody is logged in.

if WinExists("xyz") Then

$file = FileOpen("C:\Tmp\winlist.txt", 1)

FileWrite($file, "Title=xyz" & @LF & "Handle=" & WinGetHandle("xyz") & @CRLF)

$text = WinGetText("xyz","")

FileWrite($file, "Error=" & $text)

FileClose($file)

Send("{ENTER}")

;ControlSend("xyz",$text,2,"{ENTER}")

;$pos = ControlGetText("xyz",$text,2)

;$pos = ControlGetPos("xyz",$text,"OK")

MouseClick("primary",505,424,1)

EndIf

Share this post


Link to post
Share on other sites

ControlClick worked.

Thanks

Share this post


Link to post
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
Sign in to follow this  
Followers 0