diff -Nru actionaz-3.6.2/CHANGELOG actionaz-3.7.0/CHANGELOG
--- actionaz-3.6.2/CHANGELOG 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/CHANGELOG 2013-06-27 21:41:48.000000000 +0000
@@ -1,3 +1,28 @@
+3.7.0 (28/06/13)
+Actions:
+- added a button to insert detected variables into parameter fields
+- added a more explicit error message when a list field is empty
+- fixed a bug when opening a script that had been created using a previous version of Actionaz: new action parameters did not have default values
+- corrected a bug that prevented using the Code Error exception to skip the current action or go to a line of the script
+- Pixel Color: added an offset to the position to be checked
+- Read INI File: added reading the whole file at once
+- Read INI File: corrected a bug that froze the execution when trying to read a file with an empty filename
+- Find Image: added a field allowing to retreive the confidence value
+- Find Image: added a field to choose which matching method to use
+- Find Image: added a delay between two searches when waiting
+- Find Image: added two conditions actions "if found" and "if not found"
+- Find Image: removed the "Image not found" exception, previous scripts will be automatically upgraded to use the "if found" and "if not found" parameters
+- Find Image: search can now be done in multiple windows if they satisfy the search criterion
+- Find Image: renamed "Down pyramids" to "Downsampling"
+- Find Image: fixed a bug that prevented searching in some screens when using a multiple screen configuration
+- Find Image: fixed a bug that prevented using an absolute position when searching within a window
+Code:
+- Script: added the line attribute
+- Image: added the Image.takeScreenshotUsingScreenIndex function that allows taking screenshots using a screen index
+- Image: added a parameter to the findSubImage functions to choose which matching method to use
+- Image: fixed a bug that prevented searching in some screens when using a multiple screen configuration
+- Image: fixed a bug in the Image.takeScreenshot function that took only a screenshot of the main screen when using a multiple screen configuration
+
3.6.2 (04/05/13)
- Actions: fixed a regression that caused a memory leak and a crash after a repeated use of the Find Image action
- Code: fixed a bug that caused a memory leak and a crash after a repeated use of Image.findSubImage and similar
diff -Nru actionaz-3.6.2/actexecuter/scriptexecuter.cpp actionaz-3.7.0/actexecuter/scriptexecuter.cpp
--- actionaz-3.6.2/actexecuter/scriptexecuter.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actexecuter/scriptexecuter.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -51,14 +51,14 @@
stream.flush();
}
return false;
- case ActionTools::Script::ReadBadSchema:
+ case ActionTools::Script::ReadInvalidSchema:
{
QTextStream stream(stdout);
- stream << QObject::tr("Input script file has a bad script schema") << "\n";
+ stream << QObject::tr("Input script file has an invalid script schema") << "\n";
stream.flush();
}
return false;
- case ActionTools::Script::ReadBadScriptVersion:
+ case ActionTools::Script::ReadInvalidScriptVersion:
{
QTextStream stream(stdout);
stream << QObject::tr("Input script file is too recent") << "\n";
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/actions.pri actionaz-3.7.0/actions/actionpackdata/actions/actions.pri
--- actionaz-3.6.2/actions/actionpackdata/actions/actions.pri 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/actions.pri 2013-06-27 21:41:48.000000000 +0000
@@ -29,7 +29,8 @@
actions/writeregistryinstance.cpp \
actions/writetextfileinstance.cpp \
actions/webdownloadinstance.cpp \
- actions/readenvironmentinstance.cpp
+ actions/readenvironmentinstance.cpp \
+ actions/readinifileinstance.cpp
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/readenvironmentinstance.cpp actionaz-3.7.0/actions/actionpackdata/actions/readenvironmentinstance.cpp
--- actionaz-3.6.2/actions/actionpackdata/actions/readenvironmentinstance.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/readenvironmentinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -61,7 +61,7 @@
setVariable(variable, environmentHashVariableValue.value(environmentVariable));
else
{
- emit executionException(ActionTools::ActionException::BadParameterException, tr("The specified variable cannot be found in the system environment"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The specified variable cannot be found in the system environment"));
return;
}
}
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/readinifiledefinition.h actionaz-3.7.0/actions/actionpackdata/actions/readinifiledefinition.h
--- actionaz-3.6.2/actions/actionpackdata/actions/readinifiledefinition.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/readinifiledefinition.h 2013-06-27 21:41:48.000000000 +0000
@@ -26,6 +26,8 @@
#include "textparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
+#include "listparameterdefinition.h"
+#include "groupdefinition.h"
namespace ActionTools
{
@@ -37,12 +39,14 @@
{
class ReadIniFileDefinition : public QObject, public ActionTools::ActionDefinition
{
- Q_OBJECT
+ Q_OBJECT
public:
explicit ReadIniFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
+ translateItems("ReadIniFileInstance::modes", ReadIniFileInstance::modes);
+
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file to read from"));
file->setMode(ActionTools::FileEdit::FileOpen);
@@ -50,17 +54,29 @@
file->setFilter(tr("INI files (*.ini);;All files (*.*)"));
addElement(file);
+ ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
+ variable->setTooltip(tr("The variable where to store the data"));
+ addElement(variable);
+
+ ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this);
+ mode->setTooltip(tr("The INI file read mode"));
+ mode->setItems(ReadIniFileInstance::modes);
+ mode->setDefaultValue(ReadIniFileInstance::modes.second.at(ReadIniFileInstance::SingleParameter));
+ addElement(mode);
+
+ ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this);
+ selectionMode->setMasterList(mode);
+ selectionMode->setMasterValues(QStringList() << ReadIniFileInstance::modes.first.at(ReadIniFileInstance::SingleParameter));
+
ActionTools::TextParameterDefinition *section = new ActionTools::TextParameterDefinition(ActionTools::Name("section", tr("Section")), this);
- section->setTooltip(tr("The section name of the parameter"));
- addElement(section);
+ section->setTooltip(tr("The parameter section"));
+ selectionMode->addMember(section);
ActionTools::TextParameterDefinition *parameter = new ActionTools::TextParameterDefinition(ActionTools::Name("parameter", tr("Parameter")), this);
parameter->setTooltip(tr("The parameter name"));
- addElement(parameter);
+ selectionMode->addMember(parameter);
- ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
- variable->setTooltip(tr("The variable where to store the data"));
- addElement(variable);
+ addElement(selectionMode);
addException(ReadIniFileInstance::UnableToReadFileException, tr("Unable to read file"));
addException(ReadIniFileInstance::UnableToFindSectionException, tr("Unable to find section"));
@@ -69,7 +85,7 @@
QString name() const { return QObject::tr("Read INI file"); }
QString id() const { return "ActionReadIniFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
- QString description() const { return QObject::tr("Read an entry in an INI file"); }
+ QString description() const { return QObject::tr("Read one or all the entries in an INI file"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadIniFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readini.png"); }
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/readinifileinstance.cpp actionaz-3.7.0/actions/actionpackdata/actions/readinifileinstance.cpp
--- actionaz-3.6.2/actions/actionpackdata/actions/readinifileinstance.cpp 1970-01-01 00:00:00.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/readinifileinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -0,0 +1,105 @@
+/*
+ Actionaz
+ Copyright (C) 2008-2013 Jonathan Mercier-Ganady
+
+ Actionaz is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Actionaz is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+ Contact : jmgr@jmgr.info
+*/
+
+#include "readinifileinstance.h"
+#include "stringlistpair.h"
+
+#include
+
+namespace Actions
+{
+ ActionTools::StringListPair ReadIniFileInstance::modes = qMakePair(
+ QStringList() << "singleParameter" << "wholeFile",
+ QStringList() << QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read a single parameter") << QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read the entire file"));
+
+ void ReadIniFileInstance::startExecution()
+ {
+ bool ok = true;
+
+ QString filename = evaluateString(ok, "file");
+ QString variable = evaluateVariable(ok, "variable");
+ Mode mode = evaluateListElement(ok, modes, "mode");
+
+ if(!ok)
+ return;
+
+ if(filename.isEmpty())
+ {
+ emit executionException(UnableToReadFileException, tr("Unable to read the file"));
+ return;
+ }
+
+ rude::Config config;
+ if(!config.load(filename.toLocal8Bit()))
+ {
+ setCurrentParameter("filename");
+ emit executionException(UnableToReadFileException, tr("Unable to read the file"));
+ return;
+ }
+
+ if(mode == WholeFile)
+ {
+ QHash fileContent;
+ int sectionCount = config.getNumSections();
+
+ for(int sectionIndex = 0; sectionIndex < sectionCount; ++sectionIndex)
+ {
+ QString sectionName = QString::fromLatin1(config.getSectionNameAt(sectionIndex));
+
+ if(!config.setSection(sectionName.toLatin1(), false))
+ {
+ emit executionException(UnableToReadFileException, tr("Unable to read the file"));
+ return;
+ }
+
+ int parameterCount = config.getNumDataMembers();
+
+ for(int parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex)
+ {
+ QString parameterName = QString::fromLatin1(config.getDataNameAt(parameterIndex));
+ QString parameterValue = QString::fromLatin1(config.getStringValue(parameterName.toLatin1()));
+
+ fileContent[sectionName + "/" + parameterName] = parameterValue;
+ }
+ }
+
+ setArrayKeyValue(variable, fileContent);
+ }
+ else
+ {
+ QString section = evaluateString(ok, "section");
+ QString parameter = evaluateString(ok, "parameter");
+
+ if(!ok)
+ return;
+
+ if(!config.setSection(section.toLatin1(), false))
+ {
+ setCurrentParameter("section");
+ emit executionException(UnableToFindSectionException, tr("Unable to find the section named \"%1\"").arg(section));
+ return;
+ }
+
+ setVariable(variable, QString::fromLatin1(config.getStringValue(parameter.toLatin1())));
+ }
+
+ emit executionEnded();
+ }
+}
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/readinifileinstance.h actionaz-3.7.0/actions/actionpackdata/actions/readinifileinstance.h
--- actionaz-3.6.2/actions/actionpackdata/actions/readinifileinstance.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/readinifileinstance.h 2013-06-27 21:41:48.000000000 +0000
@@ -23,55 +23,31 @@
#include "actioninstance.h"
-#include
-
namespace Actions
{
class ReadIniFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
+ Q_ENUMS(Mode)
public:
+ enum Mode
+ {
+ SingleParameter,
+ WholeFile
+ };
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException,
- UnableToFindSectionException
+ UnableToFindSectionException
};
ReadIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
- void startExecution()
- {
- bool ok = true;
-
- QString filename = evaluateString(ok, "file");
- QString section = evaluateString(ok, "section");
- QString parameter = evaluateString(ok, "parameter");
- QString variable = evaluateVariable(ok, "variable");
-
- if(!ok)
- return;
-
- rude::Config config;
- if(!config.load(filename.toLocal8Bit()))
- {
- setCurrentParameter("filename");
- emit executionException(UnableToReadFileException, tr("Unable to read the file"));
- return;
- }
-
- if(!config.setSection(section.toLatin1(), false))
- {
- setCurrentParameter("section");
- emit executionException(UnableToFindSectionException, tr("Unable to find the section named \"%1\"").arg(section));
- return;
- }
-
- setVariable(variable, QString::fromLatin1(config.getStringValue(parameter.toLatin1())));
+ static ActionTools::StringListPair modes;
- emit executionEnded();
- }
+ void startExecution();
private:
Q_DISABLE_COPY(ReadIniFileInstance)
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/readtextfileinstance.cpp actionaz-3.7.0/actions/actionpackdata/actions/readtextfileinstance.cpp
--- actionaz-3.6.2/actions/actionpackdata/actions/readtextfileinstance.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/readtextfileinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -47,21 +47,21 @@
if(firstline < 1)
{
setCurrentParameter("firstline");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid first line value : %1").arg(firstline));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid first line value : %1").arg(firstline));
return;
}
if(lastline < 1)
{
setCurrentParameter("lastline");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid last line value : %1").arg(lastline));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid last line value : %1").arg(lastline));
return;
}
if(lastline < firstline)
{
setCurrentParameter("firstline");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("The first line has to be smaller than the last line"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The first line has to be smaller than the last line"));
return;
}
}
diff -Nru actionaz-3.6.2/actions/actionpackdata/actions/webdownloadinstance.cpp actionaz-3.7.0/actions/actionpackdata/actions/webdownloadinstance.cpp
--- actionaz-3.6.2/actions/actionpackdata/actions/webdownloadinstance.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdata/actions/webdownloadinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -67,7 +67,7 @@
if(!url.isValid())
{
setCurrentParameter("url");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid URL"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid URL"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpackdevice/actions/clickinstance.cpp actionaz-3.7.0/actions/actionpackdevice/actions/clickinstance.cpp
--- actionaz-3.6.2/actions/actionpackdevice/actions/clickinstance.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdevice/actions/clickinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -52,7 +52,7 @@
if(amount <= 0)
{
setCurrentParameter("amount");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid click amount"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid click amount"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpackdevice/actions/keyinstance.cpp actionaz-3.7.0/actions/actionpackdevice/actions/keyinstance.cpp
--- actionaz-3.6.2/actions/actionpackdevice/actions/keyinstance.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackdevice/actions/keyinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -73,7 +73,7 @@
if(mAmount <= 0)
{
setCurrentParameter("amount");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid key presses amount"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid key presses amount"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpackinternal/actions/endprocedureinstance.h actionaz-3.7.0/actions/actionpackinternal/actions/endprocedureinstance.h
--- actionaz-3.6.2/actions/actionpackinternal/actions/endprocedureinstance.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackinternal/actions/endprocedureinstance.h 2013-06-27 21:41:48.000000000 +0000
@@ -40,7 +40,7 @@
setNextLine(script()->popProcedureCall() + 2);//Lines start at 1
else
{
- emit executionException(ActionTools::ActionException::BadParameterException, tr("End procedure reached without a call"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("End procedure reached without a call"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpackinternal/actions/pauseinstance.h actionaz-3.7.0/actions/actionpackinternal/actions/pauseinstance.h
--- actionaz-3.6.2/actions/actionpackinternal/actions/pauseinstance.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackinternal/actions/pauseinstance.h 2013-06-27 21:41:48.000000000 +0000
@@ -63,7 +63,7 @@
if(duration < 0)
{
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid pause duration"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid pause duration"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpackinternal/actions/timeconditioninstance.h actionaz-3.7.0/actions/actionpackinternal/actions/timeconditioninstance.h
--- actionaz-3.6.2/actions/actionpackinternal/actions/timeconditioninstance.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackinternal/actions/timeconditioninstance.h 2013-06-27 21:41:48.000000000 +0000
@@ -46,7 +46,7 @@
if(!mTestedDateTime.isValid())
{
setCurrentParameter("date");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid date"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid date"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpackinternal/actions/variableconditioninstance.h actionaz-3.7.0/actions/actionpackinternal/actions/variableconditioninstance.h
--- actionaz-3.6.2/actions/actionpackinternal/actions/variableconditioninstance.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpackinternal/actions/variableconditioninstance.h 2013-06-27 21:41:48.000000000 +0000
@@ -67,7 +67,7 @@
if(!variableValue.isValid())
{
setCurrentParameter("variable");
- emit executionException(ActionTools::ActionException::BadParameterException, tr("Invalid variable"));
+ emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid variable"));
return;
}
diff -Nru actionaz-3.6.2/actions/actionpacksystem/actions/actions.pri actionaz-3.7.0/actions/actionpacksystem/actions/actions.pri
--- actionaz-3.6.2/actions/actionpacksystem/actions/actions.pri 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpacksystem/actions/actions.pri 2013-06-27 21:41:48.000000000 +0000
@@ -21,4 +21,5 @@
actions/systeminstance.cpp \
actions/pixelcolorinstance.cpp \
actions/playsoundinstance.cpp \
- actions/findimageinstance.cpp
+ actions/findimageinstance.cpp \
+ actions/findimagedefinition.cpp
diff -Nru actionaz-3.6.2/actions/actionpacksystem/actions/commanddefinition.h actionaz-3.7.0/actions/actionpacksystem/actions/commanddefinition.h
--- actionaz-3.6.2/actions/actionpacksystem/actions/commanddefinition.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpacksystem/actions/commanddefinition.h 2013-06-27 21:41:48.000000000 +0000
@@ -25,6 +25,7 @@
#include "commandinstance.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
+#include "textparameterdefinition.h"
namespace ActionTools
{
diff -Nru actionaz-3.6.2/actions/actionpacksystem/actions/detachedcommanddefinition.h actionaz-3.7.0/actions/actionpacksystem/actions/detachedcommanddefinition.h
--- actionaz-3.6.2/actions/actionpacksystem/actions/detachedcommanddefinition.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpacksystem/actions/detachedcommanddefinition.h 2013-06-27 21:41:48.000000000 +0000
@@ -25,6 +25,7 @@
#include "detachedcommandinstance.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
+#include "textparameterdefinition.h"
namespace ActionTools
{
diff -Nru actionaz-3.6.2/actions/actionpacksystem/actions/findimagedefinition.cpp actionaz-3.7.0/actions/actionpacksystem/actions/findimagedefinition.cpp
--- actionaz-3.6.2/actions/actionpacksystem/actions/findimagedefinition.cpp 1970-01-01 00:00:00.000000000 +0000
+++ actionaz-3.7.0/actions/actionpacksystem/actions/findimagedefinition.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -0,0 +1,57 @@
+/*
+ Actionaz
+ Copyright (C) 2008-2013 Jonathan Mercier-Ganady
+
+ Actionaz is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Actionaz is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+ Contact : jmgr@jmgr.info
+*/
+
+#include "findimagedefinition.h"
+#include "actioninstance.h"
+#include "ifactionparameterdefinition.h"
+
+void Actions::FindImageDefinition::updateAction(ActionTools::ActionInstance *actionInstance, const Tools::Version &version) const
+{
+ //In 1.1.0 we have removed the ImageNotFound exception and added ifActions instead
+ if(version < Tools::Version(1, 1, 0))
+ {
+ const ActionTools::ExceptionActionInstancesHash &exceptions = actionInstance->exceptionActionInstances();
+
+ if(exceptions.contains(static_cast(FindImageInstance::CannotFindTheImageException)))
+ {
+ const ActionTools::ActionException::ExceptionActionInstance &exceptionAction = exceptions.value(static_cast(FindImageInstance::CannotFindTheImageException));
+ ActionTools::Parameter ifNotFoundParameter = actionInstance->parameter("ifNotFound");
+
+ switch(exceptionAction.action())
+ {
+ case ActionTools::ActionException::StopExecutionExceptionAction:
+ ifNotFoundParameter.setSubParameter("action", false, ActionTools::IfActionParameterDefinition::actions.first[ActionTools::IfActionParameterDefinition::RunCode]);
+ ifNotFoundParameter.setSubParameter("line", true, "Console.printError(\"Script line \" + Script.line + \": Cannot find the image\");\nExecution.stop();");
+ break;
+ case ActionTools::ActionException::SkipExceptionAction:
+ ifNotFoundParameter.setSubParameter("action", false, ActionTools::IfActionParameterDefinition::actions.first[ActionTools::IfActionParameterDefinition::DoNothing]);
+ break;
+ case ActionTools::ActionException::GotoLineExceptionAction:
+ ifNotFoundParameter.setSubParameter("action", false, ActionTools::IfActionParameterDefinition::actions.first[ActionTools::IfActionParameterDefinition::Goto]);
+ ifNotFoundParameter.setSubParameter("line", false, exceptionAction.line());
+ break;
+ default:
+ break;
+ }
+
+ actionInstance->setParameter("ifNotFound", ifNotFoundParameter);
+ }
+ }
+}
diff -Nru actionaz-3.6.2/actions/actionpacksystem/actions/findimagedefinition.h actionaz-3.7.0/actions/actionpacksystem/actions/findimagedefinition.h
--- actionaz-3.6.2/actions/actionpacksystem/actions/findimagedefinition.h 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpacksystem/actions/findimagedefinition.h 2013-06-27 21:41:48.000000000 +0000
@@ -30,6 +30,7 @@
#include "groupdefinition.h"
#include "windowparameterdefinition.h"
#include "booleanparameterdefinition.h"
+#include "ifactionparameterdefinition.h"
#include
@@ -50,6 +51,7 @@
: ActionDefinition(pack)
{
translateItems("FindImageInstance::sources", FindImageInstance::sources);
+ translateItems("FindImageInstance::methods", FindImageInstance::methods);
ActionTools::ListParameterDefinition *source = new ActionTools::ListParameterDefinition(ActionTools::Name("source", tr("Source")), this);
source->setTooltip(tr("The source of the image to search in"));
@@ -57,15 +59,19 @@
source->setDefaultValue(FindImageInstance::sources.second.at(FindImageInstance::ScreenshotSource));
addElement(source);
- ActionTools::GroupDefinition *windowNameGroup = new ActionTools::GroupDefinition(this);
- windowNameGroup->setMasterList(source);
- windowNameGroup->setMasterValues(QStringList() << FindImageInstance::sources.first.at(FindImageInstance::WindowSource));
+ ActionTools::GroupDefinition *windowGroup = new ActionTools::GroupDefinition(this);
+ windowGroup->setMasterList(source);
+ windowGroup->setMasterValues(QStringList() << FindImageInstance::sources.first.at(FindImageInstance::WindowSource));
ActionTools::WindowParameterDefinition *windowName = new ActionTools::WindowParameterDefinition(ActionTools::Name("windowName", tr("Window name")), this);
windowName->setTooltip(tr("The title of the window to search in, you can use wildcards like * (any number of characters) or ? (one character) here"));
- windowNameGroup->addMember(windowName);
+ windowGroup->addMember(windowName);
- addElement(windowNameGroup);
+ ActionTools::BooleanParameterDefinition *relativePosition = new ActionTools::BooleanParameterDefinition(ActionTools::Name("windowRelativePosition", tr("Window relative position")), this);
+ relativePosition->setTooltip(tr("The position is relative to the window\nIf this parameter is set to false (not checked) then the position is absolute"));
+ windowGroup->addMember(relativePosition);
+
+ addElement(windowGroup);
ActionTools::GroupDefinition *imageToSearchInGroup = new ActionTools::GroupDefinition(this);
imageToSearchInGroup->setMasterList(source);
@@ -87,19 +93,25 @@
imageToFind->setFilter(tr("Image files (*.bmp *.gif *.jpg *.jpeg *.mng *.png *.pbm *.pgm *.ppm *.tiff *.xbm *.xpm *.svg)\nAll files (*.*)"));
addElement(imageToFind);
+ ActionTools::IfActionParameterDefinition *ifFound = new ActionTools::IfActionParameterDefinition(ActionTools::Name("ifFound", tr("If found")), this);
+ ifFound->setTooltip(tr("What to do if the image is found"));
+ ifFound->setAllowWait(true);
+ addElement(ifFound);
+
+ ActionTools::IfActionParameterDefinition *ifNotFound = new ActionTools::IfActionParameterDefinition(ActionTools::Name("ifNotFound", tr("If not found")), this);
+ ifNotFound->setTooltip(tr("What to do if the image is not found"));
+ ifNotFound->setAllowWait(true);
+ addElement(ifNotFound);
+
ActionTools::VariableParameterDefinition *position = new ActionTools::VariableParameterDefinition(ActionTools::Name("position", tr("Position")), this);
position->setTooltip(tr("The name of the variable where to store the coordinates of the center of the found image"));
addElement(position);
- ActionTools::GroupDefinition *relativePositionGroup = new ActionTools::GroupDefinition(this);
- relativePositionGroup->setMasterList(source);
- relativePositionGroup->setMasterValues(QStringList() << FindImageInstance::sources.first.at(FindImageInstance::WindowSource));
-
- ActionTools::BooleanParameterDefinition *relativePosition = new ActionTools::BooleanParameterDefinition(ActionTools::Name("windowRelativePosition", tr("Window relative position")), this);
- relativePosition->setTooltip(tr("The position is relative to the window\nIf this parameter is set to false (not checked) then the position is absolute"));
- relativePositionGroup->addMember(relativePosition);
-
- addElement(relativePositionGroup, 1);
+ ActionTools::ListParameterDefinition *method = new ActionTools::ListParameterDefinition(ActionTools::Name("method", tr("Method")), this);
+ method->setTooltip(tr("The matching method to use"));
+ method->setItems(FindImageInstance::methods);
+ method->setDefaultValue(FindImageInstance::methods.second.at(FindImageInstance::CorrelationCoefficientMethod));
+ addElement(method, 1);
ActionTools::NumberParameterDefinition *confidenceMinimum = new ActionTools::NumberParameterDefinition(ActionTools::Name("confidenceMinimum", tr("Confidence minimum")), this);
confidenceMinimum->setTooltip(tr("The minimum confidence percentage required to select a possible matching image"));
@@ -115,8 +127,8 @@
maximumMatches->setDefaultValue(1);
addElement(maximumMatches, 1);
- ActionTools::NumberParameterDefinition *downPyramidCount = new ActionTools::NumberParameterDefinition(ActionTools::Name("downPyramidCount", tr("Down pyramid count")), this);
- downPyramidCount->setTooltip(tr("The number of down pyramids to use\nA pyramid is a subdivision of the image used to accelerate the search\nEnter 1 here if the searched image is not very different from the source image"));
+ ActionTools::NumberParameterDefinition *downPyramidCount = new ActionTools::NumberParameterDefinition(ActionTools::Name("downPyramidCount", tr("Downsampling")), this);
+ downPyramidCount->setTooltip(tr("The downsampling value to use\nDownsampling is used to accelerate the search when using large images"));
downPyramidCount->setMinimum(1);
downPyramidCount->setMaximum(std::numeric_limits::max());
downPyramidCount->setDefaultValue(1);
@@ -129,22 +141,36 @@
searchExpansion->setDefaultValue(15);
addElement(searchExpansion, 1);
+ ActionTools::NumberParameterDefinition *searchDelay = new ActionTools::NumberParameterDefinition(ActionTools::Name("searchDelay", tr("Delay between two searches when waiting")), this);
+ searchDelay->setTooltip(tr("The delay between two searches"));
+ searchDelay->setMinimum(0);
+ searchDelay->setMaximum(std::numeric_limits::max());
+ searchDelay->setDefaultValue(100);
+ searchDelay->setSuffix(tr(" ms", "milliseconds"));
+ addElement(searchDelay, 1);
+
+ ActionTools::VariableParameterDefinition *confidence = new ActionTools::VariableParameterDefinition(ActionTools::Name("confidence", tr("Confidence")), this);
+ confidence->setTooltip(tr("The name of the variable where to store the confidence value found image"));
+ addElement(confidence, 1);
+
addException(FindImageInstance::ErrorWhileSearchingException, tr("Error while searching"));
- addException(FindImageInstance::CannotFindTheImageException, tr("Cannot find the image"));
}
QString name() const { return QObject::tr("Find image"); }
QString id() const { return "ActionFindImage"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Finds an image on the screen, on a window or on another image"); }
+ Tools::Version version() const { return Tools::Version(1, 1, 0); }
ActionTools::ActionInstance *newActionInstance() const { return new FindImageInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::System; }
QPixmap icon() const { return QPixmap(":/icons/findimage.png"); }
QStringList tabs() const { return ActionDefinition::StandardTabs; }
+ void updateAction(ActionTools::ActionInstance *actionInstance, const Tools::Version &version) const;
+
private:
- Q_DISABLE_COPY(FindImageDefinition)
- };
+ Q_DISABLE_COPY(FindImageDefinition)
+ };
}
#endif // FINDIMAGEDEFINITION_H
diff -Nru actionaz-3.6.2/actions/actionpacksystem/actions/findimageinstance.cpp actionaz-3.7.0/actions/actionpacksystem/actions/findimageinstance.cpp
--- actionaz-3.6.2/actions/actionpacksystem/actions/findimageinstance.cpp 2013-05-04 11:48:12.000000000 +0000
+++ actionaz-3.7.0/actions/actionpacksystem/actions/findimageinstance.cpp 2013-06-27 21:41:48.000000000 +0000
@@ -21,9 +21,9 @@
#include "findimageinstance.h"
#include "opencvalgorithms.h"
#include "code/point.h"
+#include "screenshooter.h"
#include
-#include
#include
#include
@@ -35,15 +35,28 @@
<< QT_TRANSLATE_NOOP("FindImageInstance::sources", "Screenshot")
<< QT_TRANSLATE_NOOP("FindImageInstance::sources", "Window")
<< QT_TRANSLATE_NOOP("FindImageInstance::sources", "Image"));
+ ActionTools::StringListPair FindImageInstance::methods = qMakePair(
+ QStringList() << "correlationcoefficient" << "crosscorrelation" << "squareddifference",
+ QStringList()
+ << QT_TRANSLATE_NOOP("FindImageInstance::sources", "Correlation Coefficient")
+ << QT_TRANSLATE_NOOP("FindImageInstance::sources", "Cross Correlation")
+ << QT_TRANSLATE_NOOP("FindImageInstance::sources", "Squared Difference"));
FindImageInstance::FindImageInstance(const ActionTools::ActionDefinition *definition, QObject *parent)
: ActionTools::ActionInstance(definition, parent),
mOpenCVAlgorithms(new ActionTools::OpenCVAlgorithms(this)),
+ mMethod(CorrelationCoefficientMethod),
mWindowRelativePosition(false),
- mSource(ScreenshotSource),
- mMaximumMatches(1)
+ mConfidenceMinimum(0),
+ mSource(ScreenshotSource),
+ mMaximumMatches(1),
+ mDownPyramidCount(0),
+ mSearchExpansion(0)
{
connect(mOpenCVAlgorithms, SIGNAL(finished(ActionTools::MatchingPointList)), this, SLOT(searchFinished(ActionTools::MatchingPointList)));
+ connect(&mWaitTimer, SIGNAL(timeout()), this, SLOT(startSearching()));
+
+ mWaitTimer.setSingleShot(true);
}
FindImageInstance::~FindImageInstance()
@@ -56,129 +69,215 @@
mSource = evaluateListElement