AutoHotKey:如何移动进度条的位置

AutoHotKey: How to move the position of the progress bar

我有一个工作进度条,想把它移到屏幕的左上角。我用x0 y0 w300来控制位置和大小。

但是这样做我的 %progress_bar_percentage% 停止了更新。我想问一下,位置和进度条%可以同时工作吗?

a = %counter%
b = %CaseArrayCount%
progress_bar_percentage := Round(((a/b) * 100), 2)

; Draw the progress bar on the screen
Progress, x0 y0 w300, %progress_bar_percentage%, %progress_bar_percentage%`%, System Processing , Sample APP

参考:https://autohotkey.com/docs/commands/Progress.htm

文档实际上说 options 只能在进度 window 尚不存在的情况下使用。

If the progress window does not exist: A new progress window is created (replacing any old one), and Param1 is a string of zero or more options from the list below.

也就是说在创建进度条的时候只能设置最开始的位置window:

Progress, x0 y0, 0`%, System Processing , Sample APP

Loop, 100 {
    Progress, %A_Index%, %A_Index%`%, System Processing , Sample APP
    Sleep, 100
}

如果您尝试在循环中使用选项,您会看到进度 window 在每次迭代时都被销毁并重新创建,进度值将被忽略。根据文档if Param1 is an pure number, its bar's position is changed to that value,所以你实际上不能同时做选项和进度值。

如果没有黑客,你能做的最好的事情可能是:

Loop, 10 {
    value := A_Index*10
    Progress, x%value% y%value%, %A_Index%`%, System Processing , Sample APP
    Progress, % value, % value "%", System Processing , Sample APP
    Sleep, 1000
}