Skip to content

Instantly share code, notes, and snippets.

@Vany
Created March 16, 2021 21:18
Show Gist options
  • Save Vany/793daeff45a98de8fd6ab7656fdfee0a to your computer and use it in GitHub Desktop.
Save Vany/793daeff45a98de8fd6ab7656fdfee0a to your computer and use it in GitHub Desktop.
just autoclicker for windows
#!/usr/bin/perl
use 5.028;
use Win32::GuiTest qw(MouseMoveAbsPix SendMouse SendKeys IsKeyPressed GetCursorPos);
use Time::HiRes;
my $work = 0;
my $clicker = new MagicClicker;
if(0) {
while(1) {
next unless IsKeyPressed("z");
my ($x, $y) = GetCursorPos();
print(" $x, $y \n");
exit 0;
}
}
my $timer = 0;
while (1) {
$clicker->start(), $work = 1 if IsKeyPressed("Z");
$clicker->stop(), $work = 0 if IsKeyPressed("X");
Time::HiRes::sleep(0.51);
next unless $work;
#$clicker->click2();
SendMouse("{LEFTCLICK}"); next;
$timer++;
print "$timer\n" if IsKeyPressed("t");
#if (1 && !($timer % 70)) { SendKeys("5") }
if (0 && !($timer % 500)) {
my ($x, $y) = GetCursorPos();
MouseMoveAbsPix(288, 283); SendMouse("{LEFTCLICK}"); Time::HiRes::sleep(0.01);
my $delta = int((610-281)/7);
for my $i (0..7) {
MouseMoveAbsPix(875, 281 + $i * $delta); SendMouse("{LEFTCLICK}"); Time::HiRes::sleep(0.01);
}
MouseMoveAbsPix(970, 212); SendMouse("{LEFTCLICK}"); Time::HiRes::sleep(0.01);
MouseMoveAbsPix($x-1, $y-1);
}
if (0 && !($timer % 30)) {
my ($x, $y) = GetCursorPos();
#MouseMoveAbsPix(463, 198); SendMouse("{LEFTCLICK}");
MouseMoveAbsPix(324, 188); SendMouse("{LEFTCLICK}");
#for my $i (int(rand(11)),0..10) {
for my $i (int(rand(11))) {
#next if $i==3 || $i ==5 || $i == 6 || $i ==7;
MouseMoveAbsPix(1000, 702 - (702-172)/10*($i) ); SendMouse("{LEFTCLICK}");
}
MouseMoveAbsPix($x-1, $y-1);
}
}
package MagicClicker;
use 5.028;
use Win32::GuiTest qw(SendMouse SendKeys IsKeyPressed);
sub click {
my $self = shift;
return if $self->{s} == 0;
my $s = $self->{s}++;
if ($s == 2) { return SendKeys('4'); }
if ($s == 100) { return SendKeys('2'); }
#50 * 30 = 1500 =(
if ($s > 100 && $s < 800 && $s % 25 == 0) { return SendKeys('1'); }
if ($s > 1200) { $self->{s} = 1; }
}
sub click2 {
my $self = shift;
return if $self->{s} == 0;
my $s = $self->{s}++;
if ($s == 2) { return SendKeys('54'); }
if ($s > 1400) { $self->{s} = 1; }
}
sub new {
return bless {s=>0};
}
sub start {
$_[0]->{s} = 1
}
sub stop {
$_[0]->{s} = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment