Skip to content

Commit

Permalink
Update WeaselServerAutostart.ahk
Browse files Browse the repository at this point in the history
Update WeaselServerAutostart.ahk
  • Loading branch information
rockbenben authored Jun 18, 2023
2 parents 8e5b4c7 + b1cb008 commit b2594c3
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions WeaselServerAutostart.ahk
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

; Set the new running directory,当前为 weasel-0.15.0 的默认安装目录
NewRunningDir := "C:\Program Files (x86)\Rime\weasel-0.15.0"

; 脚本启动即检测「小狼毫算法服务」是否运行,未运行即手动启动
Process, Exist, WeaselServer.exe
NewPID := ErrorLevel ; 由于 ErrorLevel 会经常发生改变, 所以要立即保存这个值.
if not NewPID
{
Run %A_WorkingDir%\WeaselServer.exe
}
StartWeaselServer(NewRunningDir)
; 脚本休眠 30 秒
Sleep, 30000
; 休眠过后,第二次检测「小狼毫算法服务」是否运行
Process, Exist, WeaselServer.exe
NewPID := ErrorLevel ; 由于 ErrorLevel 会经常发生改变, 所以要立即保存这个值.
if not NewPID
{
Run %A_WorkingDir%\WeaselServer.exe
}
StartWeaselServer(NewRunningDir)
return

StartWeaselServer(RunningDir) {
Process, Exist, WeaselServer.exe
NewPID := ErrorLevel ; 由于 ErrorLevel 会经常发生改变, 所以要立即保存这个值.
if not NewPID
{
Run, %RunningDir%\WeaselServer.exe
}
}

0 comments on commit b2594c3

Please # to comment.