2016-12-22 67 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

回答

相关问题