我想每3分钟将密钥发送到我的浏览器刷新按钮( F5 ),但我不希望脚本受到干扰。有点像计时器。每3分钟点击一次刷新( F5 ),而不会干扰循环中的原始脚本?
HotKeySet("{HOME}", "Start")
AdlibRegister("refresh", 180000)
While 1
Sleep(200)
WEnd
Func refresh()
Send("{F5}")
EndFunc
Func Start()
While 1
Call "refresh"
$pink = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x8a0859)
If IsArray($pink) then
MouseMove($pink[0], $pink[1], 0)
Sleep(100)
MouseClick("Left")
Else
$pink2 = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x8c085a)
If IsArray($pink2) then
MouseMove($pink2[0], $pink2[1], 0)
Sleep(100)
MouseClick("Left")
Else
$pink3 = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x880852)
If IsArray($pink3) then
MouseMove($pink3[0], $pink3[1], 0)
Sleep(100)
MouseClick("Left")
EndIf
EndIf
EndIf
WEnd
EndFunc
答案 0 :(得分:1)
看看:AdlibRegister
class A: NSObject {
let h: Int
init(h: Int) {
self.h = h
}
override var hashValue: Int {
return h
}
}
func ==(lhs: A, rhs: A) -> Bool {
return lhs.hashValue == rhs.hashValue
}
let a = A(h: 1)
let b = A(h: 1)
var sa = Set([a])
let sb = Set([b])
sa.subtract(sb).count // Swift1.2 prints 0, Swift 2 prints 1
sa.contains(a) // Swift1.2 true, Swift 2 true
sa.contains(b) // Swift1.2 true, Swift 2 false
答案 1 :(得分:1)
AdlibRegister
有一个奇怪的习惯:如果您注销并再次注册(同一时间),则计数器不会重置。大多数时候这很烦人/出乎意料,但确切的说,您在这里需要什么:
Func Start()
AdlibUnRegister("refresh")
; your original code here
AdlibRegister("refresh", 180000)
EndFunc