Jump to content

How to run an autoit script from another autoit script - (Moved)


Recommended Posts

1) I need the autoit script to periodically run another autoit script through VS Code to see all the logs, how to do it ?
2) If it is possible to do this, will all logs in console OUTPUT saved in VS Code or I will see only the last attempt to run?

Edited by nill
Link to comment
Share on other sites

  • nill changed the title to How to run an autoit script from another autoit script
  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Install the "Code Runner" extension in VS Code that allows you to run code snippets or scripts within VS Code itself.

Create a new AutoIt script file (for example main.au3) that will act as the entry point for running your desired script.

In main.au3, use the Run function from AutoIt to execute your target AutoIt script. For example:
 

Run("path\to\your\script.au3")

Replace "path\to\your\script.au3" with the actual path to your target AutoIt script.

Save main.au3 and open it in VS Code.
Use the keyboard shortcut Ctrl + Alt + N (or go to Code -> Run Code from the VS Code menu) to run main.au3.
The console output of your target script will be displayed in the "OUTPUT" tab in VS Code. You will be able to see the logs as the script runs.

Regarding your second question, by default, the console OUTPUT in VS Code will display the output of the current script run. If you run the script again, the previous output will be replaced by the new output. To view all logs from multiple runs, you may need to modify your script to write the logs to a file or append them to an existing log file

Also effectiveness of logging depends on how your target AutoIt script handles logging internally.

❤️

Link to comment
Share on other sites

On 6/16/2023 at 2:02 PM, 20Ice18 said:

Install the "Code Runner" extension in VS Code

After installing and creating Main_backup.au3, I try to run any autoit script press Ctrl + Alt + N writes me

[Running] autoit3 "c:\Autoit_code\Main_backup.au3"
"autoit3" �� ���� ����७��� ��� ���譥�
��������, �ᯮ��塞�� �ணࠬ��� ��� ������ 䠩���.

[Done] exited with code=1 in 0.179 seconds

1dc20-clip-59kb.png?nocache=1

my code was

ConsoleWrite("$kk=" @CRLF)
$kk=Run("NEW_BD_backup.au3")
ConsoleWrite("$kk=" & $kk & @CRLF)

Main_backup.au3 and NEW_BD_backup.au3 in the same directory

the file NEW_BD_backup.au3 definitely does not start it creates new files in the folder, and they are not there

Edited by nill
Link to comment
Share on other sites

  • Developers

The Run() command requirs an Windows executable, not a readable script!

So you either include the script at the place you like it performed or you need to run AutoIt3.exe with the script as input.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

1 hour ago, Jos said:

The Run() command requirs an Windows executable, not a readable script!

So you either include the script at the place you like it performed or you need to run AutoIt3.exe with the script as input.

Please give an example of launching what you are talking about ?

Link to comment
Share on other sites

11 minutes ago, ioa747 said:
ConsoleWrite("$kk=" & @CRLF)
;~ $kk = Run("NEW_BD_backup.au3")
$kk = Run(FileGetShortName(@AutoItExe) & " /AutoIt3ExecuteScript " & FileGetShortName("full\path\of\NEW_BD_backup.au3"))
ConsoleWrite("$kk=" & $kk & @CRLF)

 

it works!

but I cant see the log in output console for NEW_BD_backup.au3

I see only this

Quote

#85: Starting process #85
"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "c:\Autoit_code\Main_backup.au3" [PID 5552]
     +>17:57:55 Starting AutoIt3Wrapper (21.316.1639.1) from:Code.exe (1.78.2.0)  Keyboard:00000409  OS:WIN_11/2009  CPU:X64 OS:X64  Environment(Language:0419)
     >Running AU3Check (3.3.16.1)  from:C:\Program Files (x86)\AutoIt3  input:c:\Autoit_code\Main_backup.au3
     +>17:57:55 AU3Check ended.rc:0
     >Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "c:\Autoit_code\Main_backup.au3"  /errorstdout
     +>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.
     $kk=
     $kk=7424
     +>17:57:56 AutoIt3.exe ended.rc:0
     +>17:57:56 AutoIt3Wrapper Finished.
     >>Exit code 0 Time: 1.184

 

Edited by nill
Link to comment
Share on other sites

  • Developers

Ofcourse as it shells a total different program and you aren't checking for its STDOUT/STDERR and not waiting for it to finish!
Open the helpfile and look for STDOUTREAD() and look at the examples shown.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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