My autoclicker project is not working.
I will attach the codes I am using for the autoclicker so you can check and review, there is no error when compiling. It is simply that when I have it compiled it does not set coordinates and therefore it does not activate either. I have 2 Timers added, Timer 2 is in Enabled True.
76 Replies
Autoclicker for what?
?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
It's for a game, yes, but as I said, the code isn't working for me.
¯\_(ツ)_/¯
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Can you help me pls?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
The code is correct, but it doesn't work for me.
It doesn't set coordinates when I use the key and therefore nothing works
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
@シュナイダー May you share the
InitializeComponent
implementation? I think what's missing is the event linking to the timer1_Tick
function:
With this, your project does work in my end, but beware: the cursor is flashing and goes to top-left, so you should add an escape route, or comment out the Cursor.Position
actually moving the mouse while debugging.
This should work out of the box, maybe. Hope it'll help.I just saw your messages, I didn't understand what you mean by sharing InitializeComponent
I added the line: using Timer = System.Windows.Forms.Timer; but it had no effect.
Have you somewhere the line
timer1.Tick += timer1_Tick;
in your code base?Not as far as I know, but above the post you can see the .txt that I attached with all the code in case you want to review it.
I wrote the code for the entire project based on a YouTube video tutorial and in the video the person is seeing the autoclicker working, but it is true that in the comments I have found people with the same problem as me despite having done everything exactly the same...
I've attached a modified version with the missing
InitializeComponent
method.
You should click on your timer, go to events, then set the Tick
event to be timer1_Tick
.Should I change timer1 to timer1_tick?
No, hmm. I'll make a gif for you.
This comes just like I showed you.
If this is already done, can you share the Form1.Designer.cs file?
I have an interface query, why does the textbox look so bad here unlike in VS?
If you look closely, a kind of blue line appears, while in the other one it is not.
And in the VS it looks like this:
It's the "focused" style.
(?)
Oh I get it, when I select one and the other they turn blue.
Now I'm going to put the project code that you sent, because in the end I decided to start a new project.
If you want to share here your current
.designer.cs
file you had, I can merge that with the one I provided before.
Otherwise, you can already get the one I've sent by clicking the "download" button on the bottom, and apply it to your project.
You don't need to start a new project: just rename your current Form as Form2
, or alike, and get the one shared here.So this .txt code doesn't work? I say this because it's from a video tutorial
The one you put in OP was missing a key element, the
InitializeComponent
implementation (usually found in a Form.Designer.cs
file) that would link the event to the actual method call.I don't really understand... so, should I create a designer.cs or drag the one you sent me to VS?
I think the base question I should have asked is which .Net version are you coding in?
4.8
Oh. Let me tweak some code lines here and there.
Since you're here, can I send you the link to the video? Because it works for the guy in the video and it doesn't for me, despite posting line by line. The video is many years old but I think it should still be worth it.
That's the video tutorial I wanted to show you.
Although I don't understand why you have to do that, replacing one Form1.cs with another...
Solely because mine has the
initializeComponent
mixed in in the main file, not as a separate designer one. It should work roughly same.And this is going to keep happening to me every time I want to do something...?
Which of these are you saying to delete? Form1 is where I have the interface and such...
Ìf you followed only the video tutorial, you should delete none of those files. If you downloaded the file I shared, you can remove
Form1.Designer.cs
.So if I followed the tutorial in the video I sent you, what should I do then? Because the code has no errors, timer1 is set to enabled false and timer2 is set to enabled true, and each code is set where it corresponds.
At the 6:49 mark, it's written in plain text (but displayed briefly in motion at 6:58) that you have to double click on
timer1
from the form Designer to have it generate the event binding, then fill it with the code.
If you've done that, you should have a working code
You may want the timer1 Enabled
to be set to true
to have those displays working.I'm seeing it now... how stupid of me.
Not a problem!
I kept double clicking on timer1 and copying the code that was in timer2, damn it.
Is your autoclicker project working now?
No wait, if I did it 100% like in the video, I still don't understand.
Nope :/
Also in timer1 is where mouse_event goes, if I put enabled true there as soon as I open the project it will already be clicking like crazy, therefore it must be enabled false, and timer2 where the keys go to set coordinates, activate and deactivate autoclick enabled so that technically I press them and they work but it is not doing so.
And now I thought I was wrong but no, everything is as it should be.
Oh, that's timer2 that is supposed to enable timer1, I see.
Have you tried to go with a minimalistic version, where you actually have a debugger line enabled, and step-by-step break down into the code?
Mmmm no .-.
Just go in the timer2_Tick function block, and press F9, then run the project. If Timer2 is ok, you'll hit the debugger, and you may go F10 to get one line at a time. 🙂
Which line should it be on?
This is ok as it is: your timer2 does tick, so your project is likely to be working.
You can actually remove the break point (press F9 again on the same line), then F5 to resume run flow, and use the project as intended.
But it still doesn't give me coordinates...
I press F3 where technically the numbers should be displayed in the textbox and that doesn't happen...
That’s not a technical topic anymore, but I will try to help with the use case.
The autoclicker still doesn't work, I can't set coordinates, much less activate and deactivate it.
It looks like
GetAsyncKeyState
isn’t triggering on key presses.And there is no error in the code because at least VS is not marking anything for me...
Found the problem: you have to replace
-32767
by 32769
.
It looks like 32bits code isn’t working in 64bits environment here!Guess what... it still doesn't work.😂
That’s the
key_down
state value. If you set it to the expected 32769
, you may press F8 to gather mouse position, then F2 to actually trigger on/off timer1 state.
The actual trigger for timer1 is shit tho, you may prefer to not trigger+release in the same F2 call. 🙃So...
You may prefer this for your
timer2_Tick
function:
I finally got it by asking chatgpt, check this out
if ((GetAsyncKeyState(Keys.F1) & 0x8000) != 0)
Awesome...
Beware that a release state is 1, so you're at risk to trigger the call both by press then release.
What does that mean?
When you press a key, the
GetAsyncKeyState
returns a value depending on the last event: Either it's pressed (32769), or released (1), or none (0).I can't understand but oh well... now I have another question, now that the autoclicker FINALLY works, is there any way I can have my physical cursor free and the virtual cursor, let's say, the one that is going to click in the set position, can stay there and not bother the real cursor? 👀
There has to be a way, since you can send messages to windows or processes, and having them virtual clicks not triggered by your real cursor position.
How you would do that here is beyond my scope, since I use AutoIt when I have to do that: it's as simple as
ControlClick("Target window title", "optional field",
0, "primary", 1,
X,
Y)
, where 0 is the target controlID, and X and Y mouse coordinates.
It's something down the window message pipe, but it could be a little off the ground for now. 🙂Technically, this code does the job, but I think Windows 11 is interfering because sometimes I can move the cursor and click but it returns to the position where the coordinates were set...
You should have a look (and try to fully understand) what the
timer1_Tick
function does, line by line. It will help you understand the mouse movements.If I understand what I understand, it's basically creating a new point, and trying to bring the cursor to the position where it is fixed, but the thing is that I want the clicks to occur where I manually set with the "real" cursor while the "virtual" or "fictional" or "ghost" cursor clicks in the fixed position while my "real" cursor is totally free and I can move it and give manual clicks...
I think I understand your desired use case, but I don't have the knowledge yet to get you a satisfying answer.
Non-satisfying answer tho: you may have a look at
SendInput
from the user32 api. Your best bet is to ask Copilot about it, maybe you will have more satisfaction!Ok, I try. Thanks for all ❤️
I prompted "How to use the SendInput function from the user32's API to simulate mouse clicks?" and it got me a bunch of code that looks legit.
Nice.