How to send clicks with Python aKa Emulate mouse clicks on Windows

There are some software available to emulate mouse clicks online, some free and some paid. But sometimes the best way to do it is just to use a simple script. It’s light, and it does not require you to install any suspicious software, so you are in control of what it does.

I had the need of emulate mouse clicks on Windows to automate some boring stuff I had to do, so I created a simple script to click on stuff for me, and I decided to share it with you.

If you are here looking for I script, I assume that you have a certain degree of coding and scripting, so I will not explain this in deep detail, but at the same time, I will try to help those with less knowledge.

First things first!

Before you download this script (or even after, doesn’t matter really), go to Python.org and download Python software.


Also, if you don’t have Notepad++, download it now, as you’ll need it too. This is all free software, so don’t worry.

After download, the obvious thing to do is to install it, do that.

If you haven’t done it yet, this is a good time to download my script now, using the link bellow.

When you download the ZIP file you will have 2 Python scripts, one is the “sendClicks_config.py” and the other is “sendClicks_execute.py“, as the name implies, the file with “config” on its name will be the first file to use in order to config where to click.

Remember that I never coded in Python, so this is far from being perfect, but it works, and that’s the important bit! 🙂

Let’s prepare the pre-flight!

Now that you downloaded and installed everything, let’s make sure everything will work fine!

To make things work better and smoothly, there is a small Windows setting/variable that we need to create.

Right click on “This PC” (named “My Computer”, on Windows 7), and click on Properties.

Now, click on “Advanced system settings”

 

Now click on “Environment Variables…

Now check, under “System variables” if you have a variable called “Python“, if you don’t have it, you need to press the “New…” button and create it, pointing to the folder where you installed Python.

Now that we have this out of the way, let’s start the party! 🙂

Unzip the files you downloaded with the scripts, then right click on the “sendClicks_execute.py” and choose “Edit with Notepad++”, this will

In this file, you have some green text with some information and instructions.

Let’s install the needed modules first.


Open Windows Command Prompt from Start Menu.

Now type (or copy paste) the next commands one by one and press the ENTER key after each one.

pip install pynput
{PRESS ENTER and wait for installations to complete}
pip install colorama
{PRESS ENTER and wait for installations to complete}

Now that the needed modules are installed, just drag and drop the file “sendClicks_Config.py” to Command Prompt window and press ENTER.

What you will see is something like this…

Every 10 seconds, your mouse position/coordinates will be shown as numbers, for X and Y positions, you will need this numbers to setup your mouse click script.

Press CTRL+C on the black window to cancel the script.

Now, hopefully you still have “sendClicks_execute.py” opened on Notepad++, if not, open it now.

The numbers you had above, are the numbers in red that you will need to change on the Notepad++ code.

So, how do you automate stuff?

First, remember that this will need to be updated for any computer you use the script, because of different screen resolutions and other things on the screen (you will understand later when you play with the script more and more).

1 – Execute the script “sendClicks_config.py” (drag it to the black window).

2 – Put the mouse over the place you want to click and wait for the coordinates to be registered/shown.

3 – Do this until you done with the clicks you want, keeping an eye on the script running. When you done just stop the script using CTRL+C, so no more positions will be recorded.

The red numbers are just little helpers, usually you should ignore the number 0, because this 0 position was where you had your mouse when you initiated the script, but not always.

Now all you have to do, is to update the red numbers for “sendClicks_execute.py” on Notepad++.

The code is very easy to read, so if you need more clicks, just copy and paste the code.

Let me know in the comments what kind of automated clicks you do with this script 🙂

BONUS TIPs

If you want to do a double click, use this code:

mouse.click(Button.left, 2)

For right click is:

mouse.click(Button.right, 1)

For middle click is:

mouse.click(Button.midle, 1)

 

Download the Python scripts here

 


UAC Trust Pal

UAC Trust Pal main window

UAC Trust Pal will be your best friend when you need to add applications which need administrator rights, to the Windows startup.

Since Windows Vista, Microsoft implemented the UAC (User Account Control) to protect users from malicious software, specially the ones which adds themselves to the Windows startup,  to be executed at Windows logon, like viruses.

However this type of  “extra” security doesn’t know 100% what kind of software is malicious and what isn’t, which is a problem. Some programs you use have the option to start with Windows to give you quick access to them, or simply to check for updates. If the UAC doesn’t trust those software it will block it at startup and you will see something like the image bellow (image from Windows Vista):

windows vista blocking program

With Quick Run Adder it’s now very easy for everyone to add any program to Windows startup, but some might be blocked by UAC. That’s why now you have the UAC Trust Pal!

With UAC Trust Pal you can add any program to start at user logon bypassing UAC.

(more…)

UAC Trust Pal

UAC Trust Pal main window

UAC Trust Pal will be your best friend when you need to add applications which need administrator rights, to the Windows startup.

Since Windows Vista, Microsoft implemented the UAC (User Account Control) to protect users from malicious software, specially the ones which adds themselves to the Windows startup, to be executed at Windows logon, like viruses.

However this type of “extra” security doesn’t know 100% what kind of software is malicious and what isn’t, which is a problem. Some programs you use have the option to start with Windows to give you quick access to them, or simply to check for updates. If the UAC doesn’t trust those software it will block it at startup and you will see something like the image bellow (image from Windows Vista):

windows vista blocking program

With Quick Run Adder it’s now very easy for everyone to add any program to Windows startup, but some might be blocked by UAC. That’s why now you have the UAC Trust Pal!

With UAC Trust Pal you can add any program to start at user logon bypassing UAC.

UAC Trust Pal has a very simple intuitive interface and it’s very easy to use in 3 simple steps.

Just press the “Choose” button to select the program which will start when user log on, add a “Program name” or just leave the automatic chosen one and press “Add it to startup” button.

Quick Run Adder

Quick Run Adder main window

Did you ever had to reboot your pc because of a Windows update was in course, but you didn’t want to reboot because you had a lot of files opened where you were working on it? Well, it happened to me…a lot…

That’s why I created the Quick Run Adder, a free portable software…

What does it do? It’s simple, imagine that you have MS Outlook open, a Word and an Excel document open, and also your favorite music player, but you need to  reboot Windows because of an update (or any other reason). With Quick Run Adder you just add those Word and Excel documents, MS Outlook and your music player to the Windows Startup, then when you logon into Windows, those documents and applications will open automatically.

Will this documents/apps open everytime I logon into my Windows account?

The answer is no…And also yes… You can choose what to do! You can choose to only start those documents/apps one time, or everytime the system reboots.

Take a time to download and test this application, you will realize that is very easy to work with.Â