Example #1
0
	void TextInstance::startExecution()
	{
		bool ok = true;
	
		mText = evaluateString(ok, "text");
		int pause  = evaluateInteger(ok, "pause");

		if(pause < 0)
			pause = 0;

		mTimer->setInterval(pause);
		mCurrentCharacter = 0;
	
		if(!ok)
			return;
		
		if(pause == 0)
		{
			if(!mKeyboardDevice.writeText(mText))
			{
				emit executionException(FailedToSendInputException, tr("Unable to write the text"));
				return;
			}

			QTimer::singleShot(1, this, SIGNAL(executionEnded()));
		}
		else
		{
			pressNextKey();

			mTimer->start();
		}
	}
void PresentationSlideDmxBlock::goToSlide(int number) {
    if (m_sequenceRunning) {
        qDebug() << "Presentation Control: previous key sequence is still running";
        return;
    }
    if (m_controller->guiManager()->getMainWindow()->isActive()) {
        // PowerPoint is not in foreground (but Luminosus)
        // -> don't send key
        return;
    }
    m_sequenceRunning = true;
    QByteArray chars = QString::number(number).toLatin1();
    if (chars.length() <= 0) return;
    QVector<quint32> scanCodes;
    for (char c: chars) {
        switch (c) {
        case '0': scanCodes.append(ScanCode::NUMBER_0); break;
        case '1': scanCodes.append(ScanCode::NUMBER_1); break;
        case '2': scanCodes.append(ScanCode::NUMBER_2); break;
        case '3': scanCodes.append(ScanCode::NUMBER_3); break;
        case '4': scanCodes.append(ScanCode::NUMBER_4); break;
        case '5': scanCodes.append(ScanCode::NUMBER_5); break;
        case '6': scanCodes.append(ScanCode::NUMBER_6); break;
        case '7': scanCodes.append(ScanCode::NUMBER_7); break;
        case '8': scanCodes.append(ScanCode::NUMBER_8); break;
        case '9': scanCodes.append(ScanCode::NUMBER_9); break;
        default: break;
        }
    }
    pressNextKey(scanCodes, 0);
}
Example #3
0
	TextInstance::TextInstance(const ActionTools::ActionDefinition *definition, QObject *parent)
		: ActionTools::ActionInstance(definition, parent),
		  mTimer(new QTimer(this)),
		  mCurrentCharacter(0)
	{
		connect(mTimer, SIGNAL(timeout()), this, SLOT(pressNextKey()));

		mTimer->setSingleShot(false);
	}
void PresentationSlideDmxBlock::pressNextKey(QVector<quint32> scanCodes, int index) {
    if (scanCodes.length() <= index) {
        m_controller->keyboardEmulator()->pressKey(ScanCode::RETURN);
        QTimer::singleShot(50, [this](){
            m_controller->keyboardEmulator()->releaseKey(ScanCode::RETURN);
            m_sequenceRunning = false;
        });
        return;
    }
    m_controller->keyboardEmulator()->pressKey(static_cast<quint32>(scanCodes.at(index)));
    QTimer::singleShot(50, [this, scanCodes, index](){ m_controller->keyboardEmulator()->releaseKey(static_cast<quint32>(scanCodes.at(index))); });
    QTimer::singleShot(100, [this, scanCodes, index](){ pressNextKey(scanCodes, index + 1); });
}