void FindImageInstance::startExecution() { bool ok = true; mSource = evaluateListElement<Source>(ok, sources, QStringLiteral("source")); mImageToFind = evaluateImage(ok, QStringLiteral("imageToFind")); mIfFound = evaluateIfAction(ok, QStringLiteral("ifFound")); mIfNotFound = evaluateIfAction(ok, QStringLiteral("ifNotFound")); mPositionVariableName = evaluateVariable(ok, QStringLiteral("position")); mMethod = evaluateListElement<Method>(ok, methods, QStringLiteral("method")); mWindowRelativePosition = evaluateBoolean(ok, QStringLiteral("windowRelativePosition")); mConfidenceMinimum = evaluateInteger(ok, QStringLiteral("confidenceMinimum")); mMaximumMatches = evaluateInteger(ok, QStringLiteral("maximumMatches")); mDownPyramidCount = evaluateInteger(ok, QStringLiteral("downPyramidCount")); mSearchExpansion = evaluateInteger(ok, QStringLiteral("searchExpansion")); mConfidenceVariableName = evaluateVariable(ok, QStringLiteral("confidence")); mSearchDelay = evaluateInteger(ok, QStringLiteral("searchDelay")); if(!ok) return; validateParameterRange(ok, mConfidenceMinimum, QStringLiteral("confidenceMinimum"), tr("minimum confidence"), 0, 100); validateParameterRange(ok, mMaximumMatches, QStringLiteral("maximumMatches"), tr("maximum matches"), 1); validateParameterRange(ok, mDownPyramidCount, QStringLiteral("downPyramidCount"), tr("downsampling"), 1); validateParameterRange(ok, mSearchExpansion, QStringLiteral("searchExpansion"), tr("search expansion"), 1); if(!ok) return; if(mImageToFind.isNull()) { emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid image to find")); return; } startSearching(); }
void MessageBoxInstance::startExecution() { bool ok = true; QString message = evaluateString(ok, "message"); QString title = evaluateString(ok, "title"); Icon icon = evaluateListElement<Icon>(ok, icons, "icon"); TextMode textMode = evaluateListElement<TextMode>(ok, textmodes, "textMode"); Buttons button = evaluateListElement<Buttons>(ok, buttons, "type"); QString customIcon = evaluateString(ok, "customIcon"); QString windowIcon = evaluateString(ok, "windowIcon"); mIfYes = evaluateIfAction(ok, "ifYes"); mIfNo = evaluateIfAction(ok, "ifNo"); mMessageBox = 0; if(!ok) return; mMessageBox = new QMessageBox(); mMessageBox->setIcon(messageBoxIcon(icon)); mMessageBox->setWindowModality(Qt::NonModal); mMessageBox->setText(message); mMessageBox->setWindowTitle(title); switch(textMode) { case HtmlTextMode: mMessageBox->setTextFormat(Qt::RichText); break; case PlainTextMode: mMessageBox->setTextFormat(Qt::PlainText); break; case AutoTextMode: default: mMessageBox->setTextFormat(Qt::AutoText); break; } if(!customIcon.isEmpty()) { QPixmap customIconPixmap; if(customIconPixmap.load(customIcon)) mMessageBox->setIconPixmap(customIconPixmap); } if(!windowIcon.isEmpty()) { QPixmap windowIconPixmap; if(windowIconPixmap.load(windowIcon)) mMessageBox->setWindowIcon(QIcon(windowIconPixmap)); } switch(button) { case OkButton: mMessageBox->setStandardButtons(QMessageBox::Ok); break; case YesNoButtons: mMessageBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No); break; } mMessageBox->adjustSize(); QRect screenGeometry = QApplication::desktop()->availableGeometry(); mMessageBox->move(screenGeometry.center()); mMessageBox->move(mMessageBox->pos().x() - mMessageBox->width()/2, mMessageBox->pos().y() - mMessageBox->height()/2); mMessageBox->open(this, SLOT(buttonClicked())); }
void WindowConditionInstance::startExecution() { bool ok = true; QString title = evaluateString(ok, QStringLiteral("title")); mCondition = evaluateListElement<Condition>(ok, conditions, QStringLiteral("condition")); mIfTrue = evaluateIfAction(ok, QStringLiteral("ifTrue")); ActionTools::IfActionValue ifFalse = evaluateIfAction(ok, QStringLiteral("ifFalse")); mPosition = evaluateVariable(ok, QStringLiteral("position")); mSize = evaluateVariable(ok, QStringLiteral("size")); mXCoordinate = evaluateVariable(ok, QStringLiteral("xCoordinate")); mYCoordinate = evaluateVariable(ok, QStringLiteral("yCoordinate")); mWidth = evaluateVariable(ok, QStringLiteral("width")); mHeight = evaluateVariable(ok, QStringLiteral("height")); mProcessId = evaluateVariable(ok, QStringLiteral("processId")); if(!ok) return; mTitleRegExp = QRegExp(title, Qt::CaseSensitive, QRegExp::WildcardUnix); ActionTools::WindowHandle foundWindow = findWindow(); if((foundWindow.isValid() && mCondition == Exists) || (!foundWindow.isValid() && mCondition == DontExists)) { QString line = evaluateSubParameter(ok, mIfTrue.actionParameter()); if(!ok) return; if(mIfTrue.action() == ActionTools::IfActionValue::GOTO) setNextLine(line); else if(mIfTrue.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; } executionEnded(); } else { QString line = evaluateSubParameter(ok, ifFalse.actionParameter()); if(!ok) return; if(ifFalse.action() == ActionTools::IfActionValue::GOTO) { setNextLine(line); executionEnded(); } else if(ifFalse.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; executionEnded(); } else if(ifFalse.action() == ActionTools::IfActionValue::WAIT) { connect(&mTimer, &QTimer::timeout, this, &WindowConditionInstance::checkWindow); mTimer.setInterval(100); mTimer.start(); } else executionEnded(); } }