Eine andere möglichkeit wäre mit "Windows Script Host":
(Sicher nicht ganz so leistungsfähig, dafür aber bei Windows mit dabei.)
Siehe auch
msdn.microsoft.com: SendKeys Method.
Beispiel:
var wsh = new ActiveXObject("WScript.Shell");
wsh.run("notepad.exe");
WScript.sleep( 200 ); // give notepad time to load
wsh.SendKeys( '% xabcdefx{BACKSPACE}+^{LEFT}^c^{RIGHT}^v^habc{TAB}---%l{ESC}' );
Step by step:
- eine Textdatei namens myMacroTool.js erstellen
- mit Editor öffnen
- beispielsweise obigen Code einfügen:
- Datei speichern und schliessen
- in WinXP Datei starten mit "C:/WINDOWS/system32/wscript.exe myMacroTool.js" ( normalerweise geht auch Rechtsklick->öffnen )
Das selbe Beispiel, etwas umfangreicher:
var wsh = new ActiveXObject("WScript.Shell");
var delays = { npLoad: 500, sendkeysDelay: 100 };
main();
function main(){
wsh.run("notepad.exe");
WScript.sleep( delays.npLoad ); // give notepad time to load
sendkeys( [
'% x', // alt-space, x
'abcdefx{BACKSPACE}', //
'+^{LEFT}', // shift-control-left
'^c', // control-c
'^{RIGHT}', '^v',
'+^{LEFT}', '^c', '^{RIGHT}', '^v',
'+^{LEFT}', '^c', '^{RIGHT}', '^v',
'^habc{TAB}---%l', // control-h, 'abc', tab, '---', alt-L
'{ESC}' // close dialog
], delays.sendkeysDelay );
}
function sendkeys( arr, delay ){
var i = 0, alen = arr.length;
while( i < alen ){
wsh.SendKeys( arr[i] );
if( delay ) WScript.sleep( delay ); // delay is normally not necessary
i++;
}
}