Skip to content

Instantly share code, notes, and snippets.

@hirokai
Last active November 3, 2015 04:20
Show Gist options
  • Save hirokai/23a39d0f602d4bd777ae to your computer and use it in GitHub Desktop.
Save hirokai/23a39d0f602d4bd777ae to your computer and use it in GitHub Desktop.
WSH JScript for repeating clicks with specified delays
// Requires:
// http://3rd.geocities.jp/kaito_extra/Download/MouseEmulatorDLL.zip
var sh = new ActiveXObject( "WScript.Shell" );
function click(x,y,_delays){
var delays = _delays || [0,100,0];
WScript.Sleep(delays[0]);
sh.Run( "rundll32.exe MouseEmulator.dll, _SetMouseXY@16 "+x+", "+y );
WScript.Sleep(delays[1]);
sh.Run( "rundll32.exe MouseEmulator.dll, _ClickLeft@16" );
WScript.Sleep(delays[2]);
}
function repeat(n,count) {
var xs = [];
for(var i=0;i<count;i++){
xs.push(n);
}
return xs;
}
WScript.Echo("Starts in 5 sec...");
// delays in sec
var delays = repeat(1,10);
WScript.Echo(delays);
WScript.Sleep(5000);
for(var i = 0; i < delays.length; i++){
WScript.Sleep(delays[i]*1000);
click(1850,300,[0,200,500]);
}
WScript.Echo("End");
// sh.sendKeys('%{TAB}');
sh = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment