Eexecutable does not work properly but code when run from Winbatch Studio Works!

Started by pguild, February 08, 2023, 04:13:42 PM

Previous topic - Next topic

pguild

A program I wrote works great from Winbatch Studio, but when I run it as an .exe it does not seem to issue a Right Click properly.  The goal of my Winbatch program is to bring up a dialog box where I can enter a comment that will be placed on the chart.

The application I am right clicking on does not respond with a Menu as it should.  The application my program is trying to interact with is ThinkorSwim -- a Chart is preselected manually and a chart for a specific symbol is displayed.

This code works great when run from Winbatch Studio, but not when the .exe program is activated.

;Add comment to chart.
MousePlay("725 171",  "Main@thinkorswim [build 1977]", "",@MPLAYRCLK,1) ;right click on chart to bring up menu.
MousePlay("755 370",  "Main@thinkorswim [build 1977]", "",@MPLAYLCLK,3)
MouseMove(905, 363, "", "")
MousePlay("905 410",  "Main@thinkorswim [build 1977]", "",@MPLAYLCLK,3)
RETURN

Any ideas to make it work from the .exe ?

ChuckC

Are there differences in the UAC elevation level that WinBatch Studio and your compiled script's EXE file are running at, especially in comparison to the UAC elevation level of the app you are trying to automate?

Also, is there any chance that the coordinate positions are somehow different at runtime such that WinBatch Studio executes the WBT file and automates the application successfully but the compiled script's EXE doesn't?

Have you investigated other more reliable forms of automation?  Sending simulated mouse events and keystrokes is the most rudimentary type of automation and is fraught with all kinds of perils in terms of unreliability.  The first thing I'd recommend is checking out the Control Manager extender and its functions along with the companion script that utilizes it to help generate WIL script code to automate an application in a more reliable manner.

kdmoyers

My decades of winbatch experience tell me that Chuck is right:
QuoteHave you investigated other more reliable forms of automation?  Sending simulated mouse events and keystrokes is the most rudimentary type of automation and is fraught with all kinds of perils in terms of unreliability.  The first thing I'd recommend is checking out the Control Manager extender and its functions along with the companion script that utilizes it to help generate WIL script code to automate an application in a more reliable manner.

Doing mouse and keyboard is sometimes the answer, but it is the LAST thing you try, not the first, because it is the most painful.
The mind is everything; What you think, you become.

td

Mostly already covered but here are the three most common causes of differences in behavior between script execution methods.

  • Manifest settings for the compiled script differ from the WinBatch.exe executable's settings.
  • Launch location of the compiled script is different than the uncompiled script.
  • The compiler and WinBatch.exe are from different versions of WinBatch.

More info on manifests can be found here:

https://docs.winbatch.com/mergedProjects/WinBatch/Manifests.htm

and here:

https://docs.winbatch.com/mergedProjects/WinBatch/WINBATCH_S__005.htm
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade