Jump to content
Sign in to follow this  
Paedric

Copy files once an active window is closed

Recommended Posts

Paedric

Hello,

I have a script that starts a program with several options possible, and in one of those options, files are copied before launching the program.

However, I'd like to copy files over those files I copied before, but only once the program has been closed by the user, which may be hours latter.

I tried using WinWaitNotActive, but either it doesn't work, or I couldn't manage to get it to work since I'm new to this.

Thanks in advance to anyone who would like to try to help me.

Share this post


Link to post
Share on other sites
happy2help

Hi and Welcome!

Post your script so far and we will take a look for you.

Share this post


Link to post
Share on other sites
Paedric

Here is the relevant part, the whole script is about a thousand lines long, and I'm not the one that have done it, I'm just editing it. It is the end that I'm trying to change.

Func _Factionselected()
    
    global $MultiplayerUsed = 0
    
    If $Factionselected = "" Then
    ;   MsgBox(4096, "RS II - message", "default", 12)
        If $EngineSelected = "RomeTW-BI.exe" Then
            $Factionselected = "-mod: "
        ElseIf $EngineSelected = "RomeTW-ALX.exe" Then
            $Factionselected = "-mod: "
        Else
            $Factionselected = ""
        EndIf
        
    ElseIf $Factionselected = "Select a faction" Then
    ;   MsgBox(4096, "RS II - message", "Greek", 12)
        If $EngineSelected = "RomeTW-BI.exe" Then
            $Factionselected = "-mod: "
        ElseIf $EngineSelected = "RomeTW-ALX.exe" Then
            $Factionselected = "-mod: "
        Else
            $Factionselected = ""
        EndIf
        
    ElseIf $Factionselected = "Battles Only" Then
    ;   MsgBox(4096, "RS II - message", "Others", 12)
        If $EngineSelected = "RomeTW-BI.exe" Then
            $Factionselected = "-mod: "
        ElseIf $EngineSelected = "RomeTW-ALX.exe" Then
            $Factionselected = "-mod: "
        Else
            $Factionselected = ""
        EndIf
        
    ElseIf $Factionselected = "One-turn Campaigns" Then
    ;   MsgBox(4096, "RS II - message", "Rome", 12)
        $Factionselected = "-mod:play_one_turn "
        
    ElseIf $Factionselected = "Rome" Then
    ;   MsgBox(4096, "RS II - message", "Rome", 12)
        $Factionselected = "-mod:play_rome "
        
    ElseIf $Factionselected = "Carthage" Then
    ;   MsgBox(4096, "RS II - message", "Carthage", 12)
        $Factionselected = "-mod:play_carthage "
        
    ElseIf $Factionselected = "Gallaeci" Then
    ;   MsgBox(4096, "RS II - message", "Gallaeci", 12)
        $Factionselected = "-mod:play_gallaeci "
        
    ElseIf $Factionselected = "Seleucid" Then
    ;   MsgBox(4096, "RS II - message", "Seleucid", 12)
        $Factionselected = "-mod:play_seleucid "
        
    ElseIf $Factionselected = "Greek City-States" Then
    ;   MsgBox(4096, "RS II - message", "Greek", 12)
        $Factionselected = "-mod:play_greeks "
        
    ElseIf $Factionselected = "Macedon" Then
    ;   MsgBox(4096, "RS II - message", "Macedon", 12)
        $Factionselected = "-mod:play_macedon "
        
    ElseIf $Factionselected = "Ptolemaic Empire" Then
    ;   MsgBox(4096, "RS II - message", "Ptolemaic Empire", 12)
        $Factionselected = "-mod:play_ptolemaic_empire "
        
    ElseIf $Factionselected = "Pergamon" Then
    ;   MsgBox(4096, "RS II - message", "Pergamon", 12)
        $Factionselected = "-mod:play_pergamon "
        
    ElseIf $Factionselected = "Sparta" Then
    ;   MsgBox(4096, "RS II - message", "Sparta", 12)
        $Factionselected = "-mod:play_sparta "
        
    ElseIf $Factionselected = "Boii" Then
    ;   MsgBox(4096, "RS II - message", "Boii", 12)
        $Factionselected = "-mod:play_boii "
        
    ElseIf $Factionselected = "Parthia" Then
    ;   MsgBox(4096, "RS II - message", "Parthia", 12)
        $Factionselected = "-mod:play_parthia "
    
    ElseIf $Factionselected = "Pontus" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_pontus "
    
    ElseIf $Factionselected = "Arverni" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_arverni "
    
    ElseIf $Factionselected = "Dacia" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_dacia "
    
    ElseIf $Factionselected = "Armenia" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_armenia "
    
    ElseIf $Factionselected = "Belgae" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_belgae "
    
    ElseIf $Factionselected = "Cimbri" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_cimbri "
    
    ElseIf $Factionselected = "Sarmatia" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_sarmatia "
    
    ElseIf $Factionselected = "Scythia" Then
    ;   MsgBox(4096, "RS II - message", "Pontus", 12)
        $Factionselected = "-mod:play_scythia "
        
    ElseIf $Factionselected = "Test Campaign" Then
    ;   MsgBox(4096, "RS II - message", "Test", 12)
        $Factionselected = "-mod:play_test "
        
    ElseIf $Factionselected = "Multiplayer" Then
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Multiplayer\export_descr_unit.txt", @ScriptDir & "\..\data\export_descr_unit.txt", 1 ) 
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Default_DMB\default\descr_model_battle.txt", @ScriptDir & "\..\data\descr_model_battle.txt", 1 )
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Post_Marian_Roman_General\descr_character.txt", @ScriptDir & "\..\data\descr_character.txt", 1 )
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Multiplayer\Rome.lnt", @ScriptDir & "\..\data\menu\Rome.lnt", 1 )
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Multiplayer\menu_english.txt", @ScriptDir & "\..\data\text\menu_english.txt", 1 )
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Multiplayer\descr_rebel_factions.txt", @ScriptDir & "\..\data\descr_rebel_factions.txt", 1 )
        FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Multiplayer\descr_mount.txt", @ScriptDir & "\..\data\descr_mount.txt", 1 )
        Msgbox(4096, "Mutiplayer", "Please be aware that you are using the multiplayer option. All of the options are set to default to make sure to have compatible data. Don't forget to re-change them after playing.", 12)
    ;   MsgBox(4096, "RS II - message", "Multiplayer", 12)
        $Factionselected = "-mod: "
        If winwaitnotactive("RomeTW-BI.exe") = true Then
            FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Single_Player\export_descr_unit.txt", @ScriptDir & "\..\data\export_descr_unit.txt", 1 )
            FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Single_Player\Rome.lnt", @ScriptDir & "\..\data\menu\Rome.lnt", 1 )
            FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Single_Player\menu_english.txt", @ScriptDir & "\..\data\text\menu_english.txt", 1 )
            FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Single_Player\descr_rebel_factions.txt", @ScriptDir & "\..\data\descr_rebel_factions.txt", 1 )
            FileCopy( @ScriptDir & "\..\data\_IMPORTANT_STUFF\Single_Player\descr_mount.txt", @ScriptDir & "\..\data\descr_mount.txt", 1 )
            EndIf
    EndIf
    
EndFunc

Share this post


Link to post
Share on other sites
happy2help

Instead of

If winwaitnotactive("RomeTW-BI.exe") = true Then

try

Processwaitclose("RomeTW-BI.exe") Then

Share this post


Link to post
Share on other sites
Paedric

Thanks, I've managed to do it in another totally different way.

But thanks nonetheless!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.