Jump to content
Sign in to follow this  
Vikramjeet

Run 2 scripts in sequence or combine

Recommended Posts

I have 2 scripts which must be run one after the other since the second script gets a value due to the action of first script, the second script must not start till the first is complete. Can I combine the 2 scripts so second does not start till first is complete

;;;;Script 1

#include <MsgBoxConstants.au3>

WinActivate("Application")
WinWaitActive("Application")

Send("S*L/USER01/16AUG/US")
Sleep(2000)
Send("{ENTER}")
Sleep(3000)
Send("MB")
Sleep(3000)
Send("{ENTER}")
Sleep(4000)

;;;;;;End Script 1

;;;;;;Script 2

#include <MsgBoxConstants.au3>

$file = @ScriptDir & "\T.log"

$iNum = StringRegExp(FileRead($file), "(?sm).*^\h*(\d{1,3})", 1)[0]
ConsoleWrite($iNum & @CRLF)

WinActivate("Application")
Local $hWnd = WinWaitActive("Application", "", 5)

If $hWnd Then
    For $i = 1 To $iNum
        Send("SEQUENCE" & $i & "{ENTER}")
        Sleep(2000)
    Next
Else
    MsgBox(0, "", '"Application" window not found.')
EndIf

;;;;;;;;;End Script 2

 

Share this post


Link to post
Share on other sites

@Vikramjeet

Sure you can :)

Just split them in two different files ( .au3 obviousely ), and call the second script in the last line of your first script.

I think that you should check the success of the first script, disposing a boolean/integer variable or some If...Else...EndIf, in order to see is everything has gone as you were expecting in the first script.

Look at Run() and ShellExecute() functions.

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

It did not work because the log file which Script2 looks at is empty at the time script1 starts. Script2 must not be called till script1 is complete. I prefer to have 1 script which performs Script1 (Does not even look at Script2) and then start Script2 once Script1 is complete

;;;;Script 1

#include <MsgBoxConstants.au3>
Script2()

WinActivate("Application")
WinWaitActive("Application")

Send("S*L/USER01/16AUG/US")
Sleep(2000)
Send("{ENTER}")
Sleep(3000)
Send("MB")
Sleep(3000)
Send("{ENTER}")
Sleep(4000)

Func Script2()
    Local $iPID = Run("APP2.exe")
EndFunc
;;;;;;End Script 1

 

Share this post


Link to post
Share on other sites
2 hours ago, Vikramjeet said:

Script2 must not be called till script1 is complete.

What tells to Script2 that Script1 has done his job correctly?


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
;;;;Script 1

#include <MsgBoxConstants.au3>

;Script2() <<< I shouldn't be here, but in the end of script 1

WinActivate("Application")
WinWaitActive("Application")

Send("S*L/USER01/16AUG/US")
Sleep(2000)
Send("{ENTER}")
Sleep(3000)
Send("MB")
Sleep(3000)
Send("{ENTER}")
Sleep(4000)

Local $iPID = Run("APP2.exe") ;Start 2 only at the end of 1. 

;;;;;;End Script 1
Quote

Script2 must not be called till script1 is complete.

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...