#🔒 Autoclicker that runs when the mouse is held down

152 messages · Page 1 of 1 (latest)

lethal wharf
#

Im making an autoclicker that runs when the left mouse button is held down.
My issue is that line 17 never runs and the click crashes the program. I have all the modules imported. any idea what the error is?

alpine tuskBOT
#

@lethal wharf

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

proper pewter
static crow
#

since you have your cursor coords already

lethal wharf
static crow
#

ok

proper pewter
#

if this is for cheating then we don't help

static crow
#

!rule 5

alpine tuskBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

static crow
#

that is true

lethal wharf
#

no im just making it for fun

proper pewter
lethal wharf
#

no bro

#

i ran out of coding ideas

static crow
#

did it work?

lethal wharf
#

nope

#

the print(x,y) runs

static crow
#

is there an error message?

lethal wharf
#

nope nothing after the print(x,y)

proper pewter
lethal wharf
#

not sure what

static crow
#

ok what does it print for x and y?

lethal wharf
#

the mouse coordinates?

#

that part seems correct

#

it printed 518 1212

#

i just put that to test exactly where it breaks

static crow
#

ok

#

have you tried to run the script with admin perms

#

maybe windows is blocking it

lethal wharf
#

no

#

how would i do that

#

?

#

sounds like a good idea but how do I run it with admin perms

static crow
#

uhh open the folder that the file is in, right click the python file and run as administrator maybe?

lethal wharf
#

maybe the admin module?

static crow
#

idk

#

wait im dumb

#

go to the folder with the file

lethal wharf
#

yes?

static crow
#

and then click the path

#

and type in cmd

#

which should open a command primot with admin

#

and run it there

lethal wharf
#

oh ok

#

nope

#

unfortunately still doens’t work

#

it won’t let me type in terminal atall after i click

static crow
#

can you put a print after the mouse click down

#

to see if it's going down but no tup

lethal wharf
#

ok

#

doesn’t go down either

#

something with how im using win32api is wrong

static crow
#

there seems to be a pycwnd.SendMessage() thingy

lethal wharf
#

oh

#

btw here is my other attempt at making this

#

it usees pyautogui for the clicks instead

#

but the same thing happens

#

it crashes at the click

#

let me run this script with administrator perms

#

nope doesn’t work won’t let me close thr window either

#

super weird

static crow
#

what's the recursion for

#

maybe that's causing the crash

lethal wharf
#

if the interval is less than holdtime then time.sleep((interval - holdtime)/1000) attempts to sleep negative time

#

sure ill remove it but idk if itll change anything

#

wait no it won't

#

cause I put a print right after it

#

and it runs

#

the print

#

very odd error

#

let me simplify it and remove everything and try a program with just the code to click once

static crow
#

Ok

lethal wharf
#

program lived doesn't print

#

...

#

ok there must be something fundamental wrong

#

cause even this won't work

#

i tried installing pyautogui with pip again

#

was already installed

#

doesn't work

static crow
#

what python version are you on?

lethal wharf
#

how do I check?

static crow
#

in cmd, do py -0

lethal wharf
#

the weird part is

#

the click takes place

#

but nothing happens after

static crow
#

ok

#

what if you do two clicks in a row?

#

does the second click happen?

lethal wharf
#

good question let me try

#

also hbow do I get rid of the command prompts

#

i can't alt f4 them

lethal wharf
foggy dome
#

Is there a reason you don't want to use pyautogui?

lethal wharf
#

?

foggy dome
#

!pip pyautogui

alpine tuskBOT
#

PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.

Released on <t:1684959092:D>.

lethal wharf
#

I am using it though?

#

im confused

foggy dome
#

oh you changed halfway through your post

lethal wharf
#

oh sry

#

yeah

foggy dome
#

sorry, I just saw your original screenshot

static crow
lethal wharf
#

nope

#

this is very weird something fundamental is broken

static crow
#

what IDe are you using

lethal wharf
#

was using sublime just tried it in vscode

#

doesn't work

#

let me try it on another device lmfao

static crow
#

ok

lethal wharf
#

pip isn't working on my other device..

#

sorry for the delay ill try it on another device

#

just tried it on another device and now it works

#

let me try the full code on the other device

#

im guessing maybe its because the other user didn’t have admin

#

ok so

#

the basic clicking works now

#

but the larger program doesn’t

#

I realize im not putting the mouse up after putting it down

#

thats to keep the loop running though

#

below'

#

its not registering the clicks everything else is fine

#

maybe I have to run it as admin

#

okay to summarize

#

this is the current code

#

the loop for when the mouse is held is obstructed by the click being done above since that release makes it think that the mouse button was released

static crow
#

ah ok

lethal wharf
#

its a tricky thing to make because the clicks sent by the thing interfere with its detection of when the mouse button is held down

#

maybe I could directly get input from the mouse so that its not affected by the virtual clicks send by the program?

foggy dome
#

There is no difference between "virtual clicks" and actual clicks.

#

They are all the same

lethal wharf
#

yeah

#

what I need is

#

a program that clicks every second while the respective physical mouse button is held down

#

not sure how to do it though

lethal wharf
#

i was just refering to them as that to differentiate whether the code made them or the user did

alpine tuskBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.