Ganesh2VL

Unable to run script remotely using task schedular

4 posts in this topic

Dear All, Good Day

I have created an Autoit script which runs perfectly on local machine,but when i call the same script from a remote machine it failed (window in disable mode, every time when i click manually the screen the script will work). Even i tried mouseclick but failed, please advise. 

 

Note: My ultimate aim is to automate the task using a automation scheduler which installed on a separate system.

Please check my below script

Run("C:\Program Files (x86)\ITProgararm\prgm.exe")
Send("{ALTDOWN}{ESC}{ALTUP}")
WinWaitActive("Log into Database Server")

Send("username{TAB}password{ENTER}")
WinWaitActive("Error","")
Send("{ENTER}")
WinWaitActive("ITProgararm - Program Monitor","")
Send("{CTRLDOWN}f{CTRLUP}")
MouseClick("left",135,944,1)
WinWaitActive("ITProgararm - Program Monitor - [Authorizers]","")
MouseClick("left",40,109,2)
WinWaitActive("ITProgararm - Program Monitor - [Authorizer VASA Information]","")
MouseClick("left",176,95,1)
MouseClick("left",87,941,1)
MouseClick("left",1266,8,1)
 

 

Thanks in advance

 

VL.Ganesh

Share this post


Link to post
Share on other sites



Hi Ganesh,

To clarify what you're saying so we're on the same page. Yes if your application relies on GUI elements, such as sending keys to a visible window (can be hidden as well) then it will not work when the session is entirely in the background. For example, an executable that relies on task manager to execute it when the user is no longer logged on will not work. 

 

There are several ways around this that I've found.

  1. Make the application not rely on GUI elements, programs usually have some sort of command line console that you can work with, websites and webforms have the invoke web request with powershell which AutoIT has a version of.
  2. Leave your session logged in. This may or may not work depending on your application, but leaving your profile logged in in the lock position will allow some GUI dependent executables to run without a problem. As for disconnecting, I have not had any success with it, although I am open to the possibility.
  3. Get a virtual machine involved.

Also, instead of simply using the send function. I would recommend that you use the ControlSend function. In fact I recommend trying this out first. This is a sample from a working IE script I am using:

 

Local $hWnd = _IEPropertyGet($oIE, "hwnd")
    _IEAction($oSubmit, "focus")
    ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

ControlSend sends the keys directly to the control itself and doesn't rely on an application being in focus so that perhaps might help you in a combination of the above possibilities.

If you are intent on using control send, you could always use the AU3Info tool under Tools in SciTE to better scout out the controls.

 

Share this post


Link to post
Share on other sites

ControlClick, and ControlSetText...and keep this in mind:

https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F

If you are actually working on a desktop...then instead of waiting for a window to become active (winwaitactive), you can wait for it to exist, or loop until wingethandle returns a handle, and then winactivate it.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks, it worked with ControlSend and ControlClick

Dear BananaFish and JDELANEY,

Have A Good Day

Thanks for your comments.

I have modified the script using ControlSend and ControlClick functionality instead Send and MouseClick respectively now things are workig as expected.

Happy Coding

Thanks & Regards

VL.ganesh

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

  • Similar Content

    • Command3r
      Using 2 prog. languages?
      By Command3r
      Hello, is there anyway to make a gui with autoit and put it in another programming language??

      I want make a program with visual basic but in the same time i want to get some functions and GUIs from autoit.

      All helps and ideas are appreciated.