Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Forced Mouseclick

Author
Message
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 11th Jul 2007 23:27
How do you simulate a mouseclick using the Windows API?
I know it's possible but i'm not sure how.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 11th Jul 2007 23:43
Are you trying to make a macro machine thingy?
I always tried that. I'm not sure if this works, but I think the following should:



Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 12th Jul 2007 01:02
You need to access the commands from the windows API DLL to get a mouseclick without pressing the mouse.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Jul 2007 20:08
Here's an example using mouse_event which is a pre XP function call in USER32.dll. It should still work with XP but you might want to lookup which function has replaced it. Basically, it moves the pointer until it reaches a blue square. Once it reaches the blue square, it sends a left click - it uses DBC's mouseclick() command to check if it has been set to 1 (indicating a left mouse click has occured). You then press ENTER and it will send a leftbutton up - again I check this with DBC's mouseclick() to see that it returns zero. To make sure the mouse functions on it's own regardless of the api commands, I have you right click to restart the demo.



Enjoy your day.
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 12th Jul 2007 21:30 Edited at: 12th Jul 2007 22:10
Thanks Latch

I wasn't sure what the DLL commands were and I searched them on google but couldn't find them.

Edit: For anyone interested, after more searching I found a nice site that lists over 900 of the windows api calls here.
Pixelator
17
Years of Service
User Offline
Joined: 8th Jul 2007
Location: here
Posted: 12th Jul 2007 22:05
how do you use commands from a DLL?

The problem with the gaming community is people think that the resolution of a game defines how good it is. I am not afraid to make a game where the main character is 50x50.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Aug 2007 20:17
Can you force key presses too?

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Aug 2007 03:19
can someone explain why you would ever want to do this?

Your signature has been erased by a mod because it was rubbish.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Aug 2007 03:56 Edited at: 20th Aug 2007 04:05
Quote: "can someone explain why you would ever want to do this?"


There's a command in VBA called SendKey (if I remember correctly). This is very useful to send information or trigger small events between applications like Word, Access, or excel, or with Windows in general. The SendKey command can be simulated with a call to keybd_event which is the command that answers Sinani's question.

Here's a short example. This will launch notepad and then use keystrokes to activate the open dialog. You could do something similar with any application that accepts keystrokes. Make sure you hit F12 after you close notepad because the DBC window is hidden. I can't remember the command to change window focus so I just hid the dbc window.



You could create a quick and dirty printscreen key bitmap capture to the clipboard that you could paste into another application automatically from within your DBC app.

Enjoy your day.
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 20th Aug 2007 07:22
Are variables alt, f, and o the scancodes of the keys?

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?

Login to post a reply

Server time is: 2025-05-30 13:45:40
Your offset time is: 2025-05-30 13:45:40