繁体   English   中英

AutoIT点击Flash按钮?

[英]AutoIT click Flash button?

是否可以使用AutoIT单击闪光按钮? 如果是这样,有人可以给我示例代码吗?

如果您知道按钮的位置以及它在那里,您可以在某个位置单击屏幕。

如果你不知道flash按钮的状态(如果它在那里,它确切地说在哪里)你可以有一个脚本截取屏幕截图,处理图像,然后创建并运行一个AutoIT脚本,点击按钮。 过去我必须使用Perl和ImageMagick来做这件事。

如果不截取屏幕截图,您可以使用PixelChecksum计算像素的哈希值。 然后与您计算的先前版本进行比较。 您需要检查一系列像素区域。

https://www.autoitscript.com/autoit3/docs/functions/PixelChecksum.htm

以下是使用AutoIt自动执行Flash游戏的示例。

#include <IE.au3>

example()

Func example()
    $oIE = _IECreate("http://andkon.com/arcade/puzzle/greatmatemaster/")

    Local $oEmbedFlash = _IETagNameGetCollection($oIE, "embed", 0)
    Local $hWin = _IEPropertyGet($oIE, "hwnd")
    WinSetState($hWin, "", @SW_MAXIMIZE)

    ;get the x/y position of the flash game
    Local $iX = _IEPropertyGet($oEmbedFlash, "screenx")
    Local $iY = _IEPropertyGet($oEmbedFlash, "screeny")

    ;add click positions
    Local $aPlayChestBtn = [$iX + 240, $iY + 350]
    Local $a2b = [$iX + 120, $iY + 390]
    Local $a4b = [$iX + 120, $iY + 300]

    ;click the play chest button
    Click($aPlayChestBtn, 2000)

    ;move pawn to 4b with clicks
    Click($a2b, 1000)
    Click($a4b, 1000)

EndFunc   ;==>example

Func Click($aPos, $iWaitTime = 0)
    ;waits for a set amount of time for nothing to change where you want to click
    If $iWaitTime <> 0 Then PixelChecksumWait($aPos, $iWaitTime)

    ;clicks the area you want to click
    MouseClick("left", $aPos[0], $aPos[1], 1, 0)
EndFunc   ;==>Click

Func PixelChecksumWait($aPos, $iWaitTime = 5000)
    Local $iCheckSum

    ;wait to make sure there is no change in the region
    While 1
        ;get checksum
        $iCheckSum = PixelChecksum($aPos[1] - 5, $aPos[0] - 5, 10, 10)

        ;sleep to make sure there is no change
        Sleep($iWaitTime)

        ;exit loop if there was no change
        If $iCheckSum = PixelChecksum($aPos[1] - 5, $aPos[0] - 5, 10, 10) Then ExitLoop
    WEnd
EndFunc   ;==>PixelChecksumWait

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM