0

我在版本 AHL_L 32Bit 1.1.05.06

我正在寻找一种合乎逻辑的方法来检测 AutoHotkey 像素是否上升了 x 时间,15 秒后,我假设它崩溃了,我们要刷新。

我当前的代码是这样的:

CrashCheck:
if stuckinbonus = 0x1D001A
{

    if(FoundCrash = 0) {   
     FirstFound := A_Tickcount
     FoundCrash = 1
        } else {
 CrashCheckTime := A_Tickcount - FirstFound
    }




if(CrashCheckTime >= 15000){
SetTimer,CrashCheck,off
 MsgBox,Refreshing page (Pseudo Code)
}
}
return

我已经尝试在脚本开头将变量像这样放在全局变量中,但是我遇到了 CrashCheckTime 只是 0 的问题:/有什么想法吗?

Global FoundCrash := ""
Global FirstFound := "0"
Global CrashCheckTime:= ""
4

2 回答 2

0

这会做这项工作吗?

#SingleInstance Force
#installKeybdHook
#Persistent
SetTimer, CrashCheck, 1000 ; run CrashCheck every second
MyAlert := 0
Return

CrashCheck:
PixelGetColor, Color, 100, 100
If (Color = 0x1D001A)
{
    MyAlert++
}
Else
{
    MyAlert := 0
}
If (MyAlert > 15)
{
    MyAlert := 0
    Refresh Page
}
Return

关于您自己的代码。难道是你FoundCrash := 0在运行 CrashCheck 之前没有设置?这样一来,您将永远不会真正做到If (FoundCrash = 0),因此总是会跳到选择的Else位置。

例子:

#SingleInstance Force
#installKeybdHook
#Persistent
;FoundCrash := 0 ; Script fails when this line is commented out!
stuckinbonus = 0x1D001A

!t:: ; [Alt]+t to simulate CrashCheck
If (stuckinbonus = 0x1D001A)
{
    If (FoundCrash = 0)
    {   
        SoundBeep, 500, 500 ;(Low beep)
                FirstFound := A_Tickcount
        FoundCrash := 1
    }
    Else
    {
        SoundBeep, 1500, 500 ;(High beep)
        CrashCheckTime := A_Tickcount - FirstFound
    }
    If (CrashCheckTime >= 15000)
    {
    ;SetTimer,CrashCheck,off
    FoundCrash := 0
    MsgBox,Refreshing page (Pseudo Code)
    }
}
Return

我建议您在 SciTE4AutoHotKey 中以调试模式运行它,以查看在逐步执行过程中采用了哪些分支以及变量值是什么。

于 2013-03-31T08:17:06.727 回答
0

我编写了一个小函数,它循环、等待并不断循环,直到在所需坐标处看到所需的像素颜色。也许这有帮助?

;This function checks the Pixel at the provided coordinates and waits until the colour matches the provided parameter 
WaitForLoad(PixelColorX,PixelColorY,PixelColorValue)
{
CycleCount = 0
  PixelGetColor SearchPixel, PixelColorX, PixelColorY
  ;msgbox "Found Pixel %SearchPixel% at %PixelColorX%, %PixelColorY%, Looking for %PixelColorValue%" ;DEBUGG ASSISTANT
  While (SearchPixel != PixelColorValue)
          {
    CycleCount = CycleCount + 1
    sleep 100
    ; Tooltip Waiting to detect pixels HERE!, PixelColorX, PixelColorY     ; Doesn't work
    PixelGetColor SearchPixel, PixelColorX, PixelColorY
  }
  sleep 500
;Debug
;msgbox Exiting Function with %PixelColorValue% at %PixelColorX%, %PixelColorY% after %CycleCount% Cycles.
SearchPixel = 0
PixelColorValue = 1
于 2013-09-06T19:08:51.603 回答