mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Update ScreenMatch.cs and related files
This commit is contained in:
parent
855cf6adef
commit
e7f65d50b0
|
@ -317,13 +317,16 @@ public class ScreenMatch
|
|||
Tag = filename
|
||||
};
|
||||
|
||||
if (filename.StartsWith("binary_"))
|
||||
if (!filename.StartsWith("no_"))
|
||||
{
|
||||
templateImages.Add(ConvertToBinary(bitmap, thresholdConvertToBinary));
|
||||
}
|
||||
else
|
||||
{
|
||||
templateImages.Add(bitmap);
|
||||
if (filename.StartsWith("binary_"))
|
||||
{
|
||||
templateImages.Add(ConvertToBinary(bitmap, thresholdConvertToBinary));
|
||||
}
|
||||
else
|
||||
{
|
||||
templateImages.Add(bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,6 +385,8 @@ public class ScreenMatch
|
|||
|
||||
Bitmap image = templateImages[templateCurrentIndex];
|
||||
string templateName = image.Tag as string;
|
||||
string nextTemplateName = parent.GetNextTemplateName();
|
||||
|
||||
Size templateSize = new Size
|
||||
{
|
||||
Width = image.Width,
|
||||
|
@ -390,6 +395,12 @@ public class ScreenMatch
|
|||
|
||||
parent.Log($"Trying match the template {templateName} on the screen {i}...");
|
||||
|
||||
if (!String.IsNullOrEmpty(nextTemplateName) && templateName != nextTemplateName)
|
||||
{
|
||||
parent.Log($"Ignored the template {templateName}");
|
||||
break;
|
||||
}
|
||||
|
||||
Bitmap _mainImage;
|
||||
if (templateName.StartsWith("binary_"))
|
||||
{
|
||||
|
@ -496,6 +507,7 @@ public class ScreenMatch
|
|||
// if use Clipboard
|
||||
if (sampleClipboard.Contains(templateName))
|
||||
{
|
||||
parent.Log($"Trying to use the clipboard... {templateName}");
|
||||
Thread th = new Thread(new ThreadStart(() =>
|
||||
{
|
||||
try
|
||||
|
|
|
@ -362,7 +362,7 @@ namespace WelsonJS.Service
|
|||
List<ScreenMatchResult> matchedResults = screenMatcher.CaptureAndMatch();
|
||||
matchedResults.ForEach(result =>
|
||||
{
|
||||
Log(DispatchServiceEvent("screenTime", new string[]
|
||||
Log(DispatchServiceEvent("screenTemplateMatched", new string[]
|
||||
{
|
||||
result.FileName,
|
||||
result.ScreenNumber.ToString(),
|
||||
|
@ -425,6 +425,22 @@ namespace WelsonJS.Service
|
|||
return arguments;
|
||||
}
|
||||
|
||||
public string GetNextTemplateName()
|
||||
{
|
||||
string templateName = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
templateName = DispatchServiceEvent("screenNextTemplate");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log($"Use all templates because of {ex.Message}");
|
||||
}
|
||||
|
||||
return templateName;
|
||||
}
|
||||
|
||||
public string DispatchServiceEvent(string eventType, string[] args = null)
|
||||
{
|
||||
if (args == null)
|
||||
|
|
3
app.js
3
app.js
|
@ -626,7 +626,8 @@ function dispatchServiceEvent(name, eventType, w_args, argl) {
|
|||
start: bind("ServiceStart"),
|
||||
stop: bind("ServiceStop"),
|
||||
elapsedTime: bind("ServiceElapsedTime"),
|
||||
screenTime: bind("ServiceScreenTime"),
|
||||
screenNextTemplate: bind("ScreenNextTemplate"),
|
||||
screenTemplateMatched: bind("ScreenTemplateMatched"),
|
||||
fileCreated: bind("FileCreated"),
|
||||
networkConnected: bind("NetworkConnected"),
|
||||
registryModified: bind("RegistryModified"),
|
||||
|
|
|
@ -26,8 +26,12 @@ function onMessageReceived() {
|
|||
return "onMessageReceived recevied. " + args.join(', ');
|
||||
}
|
||||
|
||||
function onServiceScreenTime(args) {
|
||||
return "onServiceScreenTime recevied. " + args.join(', ');
|
||||
function onScreenNextTemplate(args) {
|
||||
return "example.png";
|
||||
}
|
||||
|
||||
function onScreenTemplateMatched(args) {
|
||||
return "onScreenTemplateMatched recevied. " + args.join(', ');
|
||||
}
|
||||
|
||||
function onFileCreated(args) {
|
||||
|
@ -51,7 +55,8 @@ exports.getDeviceID = getDeviceID;
|
|||
exports.onServiceStart = onServiceStart;
|
||||
exports.onServiceStop = onServiceStop;
|
||||
exports.onServiceElapsedTime = onServiceElapsedTime;
|
||||
exports.onServiceScreenTime = onServiceScreenTime;
|
||||
exports.onScreenNextTemplate = onScreenNextTemplate;
|
||||
exports.onScreenTemplateMatched = onScreenTemplateMatched;
|
||||
exports.onFileCreated = onFileCreated;
|
||||
exports.onNetworkConnected = onNetworkConnected;
|
||||
exports.onRegistryModified = onRegistryModified;
|
||||
|
|
|
@ -49,6 +49,18 @@ function AutoItObject() {
|
|||
console.warn("AutoItX is disabled");
|
||||
}
|
||||
};
|
||||
|
||||
this.mouseMove = function(x ,y) {
|
||||
this.callFunction("MouseMove", [x, y]);
|
||||
};
|
||||
|
||||
this.mouseClick = function(_button) {
|
||||
this.callFunction("MouseClick", [_button]);
|
||||
};
|
||||
|
||||
this.send = function(keys) {
|
||||
this.callFunction("Send", [keys]);
|
||||
};
|
||||
|
||||
this.create();
|
||||
}
|
||||
|
@ -57,6 +69,6 @@ exports.create = function() {
|
|||
return new AutoItObject();
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "AutoIt API interface version 0.1.3";
|
||||
exports.VERSIONINFO = "AutoItX API interface version 0.1.4";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
|
@ -671,7 +671,7 @@ var ChromeObject = function() {
|
|||
if (this.debuggingPort > 0) {
|
||||
try {
|
||||
var pos = this.getScreenPosition();
|
||||
this.oAutoIt.callFunction("MouseMove" [pos.x + 100, pos.y + 100]);
|
||||
this.mouseMove(pos.x + 100, pos.y + 100);
|
||||
this.oAutoIt.callFunction("MouseWheel", ["down", times]);
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.downMouseWheel() ->", e.message);
|
||||
|
@ -683,7 +683,7 @@ var ChromeObject = function() {
|
|||
if (this.debuggingPort > 0) {
|
||||
try {
|
||||
var pos = this.getScreenPosition();
|
||||
this.oAutoIt.callFunction("MouseMove", [pos.x + 100, pos.y + 100]);
|
||||
this.mouseMove(pos.x + 100, pos.y + 100);
|
||||
this.oAutoIt.callFunction("MouseWheel", ["up", times]);
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.upMouseWheel() ->", e.message);
|
||||
|
@ -1144,11 +1144,11 @@ var ChromeObject = function() {
|
|||
};
|
||||
|
||||
this.sendKeys = function(s) {
|
||||
this.oAutoIt.callFunction("Send", [s]);
|
||||
this.oAutoIt.send(s);
|
||||
};
|
||||
|
||||
this.sendSpaceKey = function() {
|
||||
this.oAutoIt.callFunction("Send", ["{SPACE}"]);
|
||||
this.oAutoIt.send("{SPACE}");
|
||||
};
|
||||
|
||||
this.setValue = function(selector, value, repeat, searchIndex) {
|
||||
|
@ -1314,8 +1314,8 @@ var ChromeObject = function() {
|
|||
|
||||
this.mouseClick = function(x, y) {
|
||||
var screenPosition = this.getScreenPosition();
|
||||
this.oAutoIt.callFunction("MouseMove", [screenPosition.x + this.baseScreenX + x, screenPosition.y + this.baseScreenY + y]);
|
||||
this.oAutoIt.callFunction("MouseClick", ["left"]);
|
||||
this.oAutoIt.mouseMove(screenPosition.x + this.baseScreenX + x, screenPosition.y + this.baseScreenY + y);
|
||||
this.oAutoIt.mouseClick("left");
|
||||
};
|
||||
|
||||
this.mouseWheelUp = function() {
|
||||
|
@ -1423,7 +1423,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i
|
|||
;
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.14";
|
||||
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.15";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user