Search code examples
shellautomationmacrosautohotkeywine

How to invoke WinWait for silent installation of wizard to support multiple languages?


I'm using winetricks to perform silent install of wizard and I've got the following code which works fine (based on previous version of installer):

w_ahk_do "
    Run, ${file1}
    WinWait, MetaTrader 5 Setup
    ControlClick, Button1
    Sleep 100
    ControlClick, Button3
    WinWait, MetaTrader 5 Setup, Installation successfully completed
    ControlClick, Button4
    Process, Wait, terminal.exe
    Process, Close, terminal.exe
"

However the problem is that it doesn't work when locale is different.

So then I've to adjust the code accordingly to the language, for example the Polish version would look like:

w_ahk_do "
    Run, ${file1}
    WinWait, MetaTrader 5 Ustawienia
    ControlClick, Button1
    Sleep 100
    ControlClick, Button3
    WinWait, MetaTrader 5 Ustawienia, Instalacja ukończona
    ControlClick, Button4
    Process, Wait, terminal.exe
    Process, Close, terminal.exe
"

and so on.

Is there any method to prevent implementing many different codes for each language (using WinWait or similar function)?


Solution

  •     ; auto-execute section:
    ; GroupAdd, GroupName, WinTitle, WinText, Label, ExcludeTitle, ExcludeText
    
    GroupAdd, MetaTrader_Setup_Group, MetaTrader 5 Setup,,,, Installation successfully completed
    GroupAdd, MetaTrader_Setup_Group, MetaTrader 5 Ustawienia,,,, Instalacja ukończona
    
    GroupAdd, MetaTrader_Setup_successfull_Group, MetaTrader 5 Setup, Installation successfully completed
    GroupAdd, MetaTrader_Setup_successfull_Group, MetaTrader 5 Ustawienia, Instalacja ukończona
    
            Return  ; ênd of the auto-execute section
    
    ; All windowing commands can operate upon a window group by specifying ahk_group GroupName
    
    w_ahk_do "
        Run, ${file1}
        WinWait, ahk_group MetaTrader_Setup_Group
        ControlClick, Button1
        Sleep 100
        ControlClick, Button3
        WinWait, ahk_group MetaTrader_Setup_successfull_Group
        ControlClick, Button4
        Process, Wait, terminal.exe
        Process, Close, terminal.exe
    "
    

    https://autohotkey.com/docs/commands/GroupAdd.htm