Skip to content

Commit

Permalink
Fixes #14 MT4/5 setup now awaits for "Finish" button to appear.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Sep 22, 2024
1 parent 0ed4fe0 commit bc5ec68
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 10 deletions.
55 changes: 51 additions & 4 deletions templates/mt4_install.verb.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,63 @@ load_mt4_install()
# No documented silent install option, unfortunately.
w_try_cd "$W_CACHE/$W_PACKAGE"
w_ahk_do "
Run, "$(echo *.exe)"
; Maximum time for setup to complete.
Timeout := 600000 ; 10 min.
; Searching for a setup's EXE file.
loop, Files, *.exe
{
ExePath := A_LoopFileFullPath
break
}
; Running setup.
Run, %ExePath%
SetTitleMatchMode, RegEx
WinWait, 4 Setup
; Awaiting for setup window to appear.
WinWait, 4 Setup,, 30
; Clicking "Next".
Send, !n
Sleep, 20000
Send, {Tab}{Enter}
StartTime := A_TickCount
loop
{
; Check if timout have passed.
if (A_TickCount - StartTime > Timeout)
{
break
}
; Is "Finish" button visible?
ControlGet, FinishVisible, Visible,, Finish
if (FinishVisible)
{
break
}
; Sleeping for a short while before checking again.
Sleep, 1000
}
; Clicking "Finish".
Send, {Enter}
; Awaiting for terminal process and window to appear.
Process, Wait, terminal.exe, 5
WinWaitActive, ahk_class MetaQuotes::MetaTrader::4.00
; Closing dialogs and exiting from the terminal.
Send, {Esc}, {Esc}, !fx, !{F4} ; File->Exit, Alt-F4
; Awaiting terminal window to close for 2s.
WinWaitClose, ahk_exe terminal.exe, 2
; If terminal didn't close in 2s then we're forcing it to close.
Process, Close, terminal.exe
"
}
58 changes: 52 additions & 6 deletions templates/mt5_install.verb.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,61 @@ load_mt5_install()

w_try_cd "$W_CACHE/$W_PACKAGE"
w_ahk_do "
Run, "$(echo *.exe)"
; Maximum time for setup to complete.
Timeout := 600000 ; 10 min.
; Searching for a setup's EXE file.
loop, Files, *.exe
{
ExePath := A_LoopFileFullPath
break
}
; Running setup.
Run, %ExePath%
SetTitleMatchMode, RegEx
; Awaiting for setup window to appear.
WinWait, MetaTrader 5,, 30
; Clicking "Next".
Send, !n
StartTime := A_TickCount
loop
{
; Check if timout have passed.
if (A_TickCount - StartTime > Timeout)
{
break
}
; Is "Finish" button visible?
ControlGet, FinishVisible, Visible,, Finish
if (FinishVisible)
{
break
}
; Sleeping for a short while before checking again.
Sleep, 1000
}
; Clicking "Finish".
Send, {Enter}
; ControlWait, Button1, Finish # https://www.autohotkey.com/board/topic/43027-wait-for-control-to-appear/
Sleep, 20000
Send, {Tab}{Enter}
WinWaitClose
Process, Wait, terminal64.exe, 30
; Awaiting for terminal process and window to appear.
Process, Wait, terminal.exe, 5
; Closing dialogs and exiting from the terminal.
Send, {Esc}, {Esc}, !fx, !{F4} ; File->Exit, Alt-F4
; Awaiting terminal window to close for 2s.
WinWaitClose, ahk_exe terminal64.exe, 2
; If terminal didn't close in 2s then we're forcing it to close.
Process, Close, terminal64.exe
"
}

0 comments on commit bc5ec68

Please sign in to comment.