Jump to content
fub68

Issues w/ ControlSend on headless workstation

Recommended Posts

fub68

I am having difficulties running a script on a headless workstation. I understand the implications of running scripts on a locked workstation (https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F), but I still can't get this to work. Here is the code I am trying to run:

if WinExists($winName) Then
      DebugOut("exit portfolio trader")
      ControlSend($winName, "", "menuStrip1", "!fe")
      DebugOut("")

      Sleep(1000)

      DebugOut("confirm stop auto-trading")
      if WinExists("MultiCharts .NET64", "Do You want to stop portfolio strategy calculation") Then
         ControlSend("MultiCharts .NET64", "Do You want to stop portfolio strategy calculation", "", "y")
      EndIf
      DebugOut("")

      DebugOut("wait for auto-trading to stop")
      Sleep(2 * 60 * 1000)
      DebugOut("")

      DebugOut("confirm file save")
      if WinExists("MultiCharts .NET64", "Portfolio workspace has not been saved") Then
         ControlSend("MultiCharts .NET64", "Portfolio workspace has not been saved", "", "n")
      EndIf
      DebugOut("")
   EndIf

And here is what happens:

  • if I start the script with the remote desktop session open, it works just as expected
  • if I start the script with the remote desktop session closed, nothing happens

What's even more puzzling is the fact that I have a quite similar script running immediately after my workstation boots up, and that script does not have any issues. This is on Windows 10 (1803), and the latest stable AutoIt version (3.3.14.5).

What am I missing? Any pointers highly appreciated.

Thank you,
best regards,

Felix

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

×