如何在特定窗口中运行自定义函数并在后台工作?

时间:2017-07-28 00:32:54

标签: autoit

我使用AutoIt编写了一个脚本。 问题是在后台运行它,以便我可以使用我的桌面进行其他工作。

我使用的_ImageSearch()通常适用于活动窗口。 有没有办法在后台调用这样的功能?这是我的代码:

WinActivate('Window Title')

$x = 0
$y = 0

If _ImageSearch('searchButton.PNG', 1, $x, $y, 20) = 1 Then
   Return 1
ElseIf _ImageSearch('bundle.PNG', 1, $x, $y, 20) = 1 Then
   Send('{ESC}{LCTRL}{LCTRL}{LCTRL}')
   sleep(1000)
Else
   Send('{LCTRL}')
EndIf

1 个答案:

答案 0 :(得分:0)

编写一个连续运行的脚本,并使用热键调用图像搜索:

HotKeySet('+!e', '_endScript')   ; terminate the script with SHIFT+ALT+E
HotKeySet('+!i', '_searchImage') ; calls the image search function with SHIFT+ALT+I

; main loop
While True
    Sleep(50)
WEnd

Func _endScript()
    Exit
EndFunc

Func _searchImage()
    ; your image search stuff
EndFunc

但可能是其他应用程序阻止了您的热键。试试吧。