【问题标题】:AutoIT click Flash button?AutoIT 点击 Flash 按钮?
【发布时间】:2013-04-16 10:18:45
【问题描述】:

是否可以使用 AutoIT 单击 Flash 按钮?如果是这样,任何人都可以给我它的示例代码吗?

【问题讨论】:

    标签: flash automation autoit


    【解决方案1】:

    如果您知道按钮将在哪里并且它就在那里,您只需在某个位置单击屏幕即可。

    如果您不知道 flash 按钮的状态(是否存在,具体在哪里),您可以使用一个脚本来截取屏幕截图、处理图像,然后创建并运行 AutoIT 脚本单击按钮。过去我不得不用 Perl 和 ImageMagick 来做这件事。

    【讨论】:

    • 嗨,谢谢你,Narthring 你能告诉我任何 AutoIT 点击 Flash 或迭代 Flash 的示例代码吗.. 我用谷歌搜索了它,但我无法理解它们,你能引用任何链接或任何代码..再次感谢
    • 只需使用 MouseClick 功能点击相应的区域:autoitscript.com/autoit3/docs/functions/MouseClick.htm 您需要提前知道点击的位置并将这些 X 和 Y 坐标传递给函数。
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      这是一个使用 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-14
        • 2018-02-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-02
        • 2014-07-18
        • 2013-05-30
        • 2012-03-02
        相关资源
        最近更新 更多