2016-12-22 70 views
1

我通過Ruby WIN32OLE調用AutoItX在窗口中執行一些自動操作,遇到了必須從屏幕獲取像素顏色並在msg框中顯示顏色的場景。 Autoit沒有內置的msgbox方法,因此必須通過包含外部文件來完成。如何將外部au3(AutoIt)文件包含到Ruby中?

此,如下圖所示在AutoIt的正常工作:

#include <MsgBoxConstants.au3> 

Local $iColor = PixelGetColor(10, 100) 

MsgBox($MB_SYSTEMMODAL, "", "The decimal color is: " & $iColor) 
MsgBox($MB_SYSTEMMODAL, "", "The hex color is: " & Hex($iColor, 6)) 

由於我打電話Ruby中不能包含與上述相同的方式AutoItX方法。

這是我打開android模擬器的ruby腳本。我正計劃使用像素搜索/圖像搜索來識別應用程序併發送鼠標點擊以與它們進行交互。

require 'win32ole' 

# create autoit object from win32ole 
puts 'Creating oAutoIt Object...' 
oAutoIt = WIN32OLE.new("AutoItX3.Control") 

# open MEmu 
puts 'Opening MEmu' 
MEmu_pid = oAutoIt.Run "C:/Program Files/Microvirt/MEmu/MEmu.exe", "", oAutoIt.SW_SHOWNORMAL 
#MEmu_pid = oAutoIt.RunWait "C:/Program Files/Microvirt/MEmu/MEmu.exe", "", oAutoIt.SW_SHOWNORMAL # => pauses the script waits for MEmu to finish. 
puts "MEmu is running | PID #{MEmu_pid}" 

我需要做的是包括外部的AutoIt功能,當前的腳本。 我想以標準方式繼續(稍後計劃縮放)。那麼我該如何將au3文件包含到我的ruby腳本中呢?

+1

PixelGetColor是一個標準的AutoIt功能。 oAutoIt.PixelGetColor(10,100)應該可以工作 – Richard

+0

是的,謝謝指出。自從現在起,我已經編輯了這個問題,它清楚地表明我需要一個msg盒子的外部文件。 – Vizkrig

回答

相關問題