Skip to content

Script Samples

Sami Ylönen edited this page Jan 26, 2016 · 4 revisions

Open start menu

function execute() {
    sendInputMod("Escape", ["LControlKey"], 200, function() {
        log("Opened");  
    });
}

Test script

var Utils = importNamespace("KeySndr.Base.JsUtils");

function execute() {
    log(getPixelColor(50, 500)[0]);
    log(getPixelColor(50, 500)[1]);
    log(getPixelColor(50, 500)[2]);
    log(getPixelColor(50, 500)[3]);
    
	sendInput("T", 150, function() {
		sendInput("E", 150, function() {
			sendInput("S", 150, function() {
				sendInput("T", 150, function() {
					sendInputSync("Enter", 150);
					sendString("It is done", 10, function() {
						sendInputSync("Enter", 150);
						moveMouse(50, 50);
						pause(200);
						sendStringSync("Mouse", 10);
						moveMouse(150, 50);
						pause(200);
						sendStringSync(" is", 10);
						moveMouse(250, 50);
						pause(200);
						sendStringSync(" moving", 10);
						moveMouse(350, 50);
						pause(200);
						moveMouse(450, 50);
						pause(200);
						moveMouse(550, 50);
						doLoop();
					});
				});
			});
		});
	});
}

function doLoop() {
	var timer = new Utils.JsTimer();
	var timesRun = 0;
	var x = 300;
	var y = 300;
	var a = 1.2;
	var b = 0.9;
	
	moveMouse(x, y);
	
	timer.Tick(function() {
		var angle = 0.1 * timesRun;
		var xx = x + (a + b * angle) * Math.cos(angle);
		var yy = y + (a + b * angle) * Math.sin(angle);
		moveMouse(x + xx, y + yy);
	    if (timesRun == 720) {
		  timer.Stop();
	    }
	    timesRun++;
	});
	pause(500);
	timer.Start(0, 10); 
}
Clone this wiki locally