[Delphi] Using SendInput (Specificaly moving and clicking the mouse)

Hello everyone, For the life of me, I cannot find an example on how to use SendInput to move and click the mouse within Delphi, Can anyone post or point me in the right direction? I would appreciate it alot
1
Jeff
4/3/2014 12:45:33 AM
embarcadero.delphi.nativeapi 1236 articles. 1 followers. Follow

4 Replies
1608 Views

Similar Articles

[PageSpeed] 56

Jeff wrote:

> Hello everyone, For the life of me, I cannot find an example on how to
> use SendInput to move and click the mouse within Delphi, Can anyone
> post or point me in the right direction?

Try something like this:

{code}
var
  Inputs: array[0..2] of TInput;
begin
  Input.Type := INPUT_MOUSE;
  Input.mi.dx := XCoordinate;
  Input.mi.dy := YCoordinate;
  Input.mi.mouseData := 0;
  Input.mi.dwFlags := MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MOVE;
  Input.mi.time := 0;
  Input.mi.dwExtraInfo := 0;

  Input.Type := INPUT_MOUSE;
  Input.mi.dx := 0;
  Input.mi.dy := 0;
  Input.mi.mouseData := 0;
  Input.mi.dwFlags := MOUSEEVENTF_LEFTDOWN;
  Input.mi.time := 0;
  Input.mi.dwExtraInfo := 0;

  Input.Type := INPUT_MOUSE;
  Input.mi.dx := 0;
  Input.mi.dy := 0;
  Input.mi.mouseData := 0;
  Input.mi.dwFlags := MOUSEEVENTF_LEFTUP;
  Input.mi.time := 0;
  Input.mi.dwExtraInfo := 0;

  SendInput(Length(Inputs), Inputs[0], SizeOf(TInput));
end;
{code}

Or:

{code}
var
  Input: TInput;
begin
  Input.Type := INPUT_MOUSE;
  Input.mi.dx := XCoordinate;
  Input.mi.dy := YCoordinate;
  Input.mi.mouseData := 0;
  Input.mi.dwFlags := MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MOVE or MOUSEEVENTF_LEFTDOWN 
or MOUSEEVENTF_LEFTUP;
  Input.mi.time := 0;
  Input.mi.dwExtraInfo := 0;

  SendInput(1, Input, SizeOf(TInput));
end;
{code}

--
Remy Lebeau (TeamB)
1
Remy
4/3/2014 1:39:29 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Jeff wrote:
> 
> > Hello everyone, For the life of me, I cannot find an example on how to
> > use SendInput to move and click the mouse within Delphi, Can anyone
> > post or point me in the right direction?
> 
> Try something like this:
> 
> {code}
> var
>   Inputs: array[0..2] of TInput;
> begin
>   Input.Type := INPUT_MOUSE;
>   Input.mi.dx := XCoordinate;
>   Input.mi.dy := YCoordinate;
>   Input.mi.mouseData := 0;
>   Input.mi.dwFlags := MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MOVE;
>   Input.mi.time := 0;
>   Input.mi.dwExtraInfo := 0;
> 
>   Input.Type := INPUT_MOUSE;
>   Input.mi.dx := 0;
>   Input.mi.dy := 0;
>   Input.mi.mouseData := 0;
>   Input.mi.dwFlags := MOUSEEVENTF_LEFTDOWN;
>   Input.mi.time := 0;
>   Input.mi.dwExtraInfo := 0;
> 
>   Input.Type := INPUT_MOUSE;
>   Input.mi.dx := 0;
>   Input.mi.dy := 0;
>   Input.mi.mouseData := 0;
>   Input.mi.dwFlags := MOUSEEVENTF_LEFTUP;
>   Input.mi.time := 0;
>   Input.mi.dwExtraInfo := 0;
> 
>   SendInput(Length(Inputs), Inputs[0], SizeOf(TInput));
> end;
> {code}
> 
> Or:
> 
> {code}
> var
>   Input: TInput;
> begin
>   Input.Type := INPUT_MOUSE;
>   Input.mi.dx := XCoordinate;
>   Input.mi.dy := YCoordinate;
>   Input.mi.mouseData := 0;
>   Input.mi.dwFlags := MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MOVE or MOUSEEVENTF_LEFTDOWN 
> or MOUSEEVENTF_LEFTUP;
>   Input.mi.time := 0;
>   Input.mi.dwExtraInfo := 0;
> 
>   SendInput(1, Input, SizeOf(TInput));
> end;
> {code}
> 
> --
> Remy Lebeau (TeamB)

Awesome, thank you so much . I greatly appreciate that! I will give you xtra kudos and mark it correct if you could Comment it a little for me, Kind of explain what going on? I would love that if you would do that for me. You have been the biggest help thus far! Thank you again
0
Jeff
4/3/2014 2:33:23 AM
Jeff wrote:

> I will give you xtra kudos and mark it correct if you could Comment it
> a little for me, Kind of explain what going on?

Is there something you do not understand in the official documentation that 
requires further commenting?

SendInput function
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx

INPUT structure
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646270.aspx

MOUSEINPUT structure
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646273.aspx

--
Remy Lebeau (TeamB)
0
Remy
4/3/2014 7:13:29 PM
Thank you again, It is just so much different from the old way of doing it. I just think i need to get used to it is all, I appreciate all your help. Thank you again
0
Jeff
4/3/2014 11:20:36 PM
Reply:

Similar Artilces:

MOVED: Use Delphi XE TLB importer in Delphi 2007?
....to the ActiveX group: https://forums.embarcadero.com/thread.jspa?threadID=47170 -- Craig Stuntz · Vertex Systems Corp. · Columbus, OH Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz/ ...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

Moving from Delphi 7 to Delphi 2007
Is there any compelling reason to move (quite a large project) from Delphi 7 to Delphi 2007? Specifically, is there better Vista/Win7/Win8 integration provided by Delphi 2007? (In the project I am already using a custom manifest file for Vista/Win7 etc.. and not the std XPMan component) Does 2007 add any new bugs to the scene? Thanks Rael Rael wrote: > Is there any compelling reason to move (quite a large project) from > Delphi 7 to Delphi 2007? If you are going to upgrade, why not upgrade to something newer? > In the project I am already using a custom man...

delphi Win32 using delphi .NET dll
Hi, I'm trying to use a delphi.NET dll in delphi.WIN32. I am currently using CodeGear Delphi 2007 with version2(base version) of .NET I can get the dll to import into the WIN32 application the only problem is when i include things such as: "using Classes,DateUtils, SysUtils" in the .NET dll the win32 application will instantly hang when any of the dll functions are called. Any help would be great thanks. Also I have tried this example and it also crashes for me? http://cc.embarcadero.com/Item/22688 -Braden I also found this.. "The problem is that, wehn you instal...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

can i use delphi 2007 bpls in delphi 2009
can i use delphi 2007 bpls in delphi 2009 ? "Gaetan SIRY" skrev i meddelelsen news:8703@forums.codegear.com... > can i use delphi 2007 bpls in delphi 2009 ? No. -- Finn Tolderlund The compatiblity between D2006 and D2007 was unique. Normaly they can't be compatible because new version enhance/change the API. And D2009 defines String = Unicode where older version has String = Ansistring so D200x/Dx-BPL are 200% incompatible with D2009. ...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

How to use a delphi XE3 obj file in delphi 2007?
Hi, I'm migrating an application from delphi 2007 to delphi XE3 and I would like to do it in several steps. To do this I need to use a part of my new code (XE3) in the current delphi 2007 application. So I want to use the .obj file from my XE3 file. I know I have to use the {$L 'Filename'} and I know that I have to declare the functions that I want to use in external in my D2007 project. I wanted to make an easy and simple example to see how it works with only 1 function 'hello world' compiled in obj with XE3 but I can't find the way to use it in D2007. In D200...

Is it worth to move my code from Delphi 2009 to Delphi 2010?
Hi guys, we are working on Delphi 2009 till this day because we do not have the time to upgrade our code to the newest version. There is always something more important (features, bugs...) and our code has 2+ million lines. I thought that instead of moving from D2009 to XE7 I could atleast move code to D2010 because it is more or less backward compatible and it shouldn't take me that much of a work. I wanted to ask you about your opinion. Is it a good version to move to? Regards. Dimitrij wrote: > I thought that instead of moving from D2009 to XE7 I could atleast > move ...

Move from Delphi 2009 to Delphi XE2 and now failing
I recently moved from Delphi 2009 to Delphi XE2 (combined with a new computer). The XML that is now created no longer accepted by the webservice. The specific steps I went through were. 1) Delphi 2009 with old pas file. Worked. 2) Delphi XE2 with old pas file. Didn't work. 3) Delphi XE2 with new pas file imported by Delphi XE2. Didn't work. The new pas file has the following lines, but commenting them out doesn't change the XML. { InvRegistry.RegisterParamInfo(TypeInfo(FaCSIADiagnosticInterface), 'Ping', 'Ping_Input', '&...

Trying to call a .DLL from Delphi XE (used to work with Delphi 6 :-) )
Hi everyone, I have a problem where perhaps some one could help point me in the right direction. In Delphi 6 I used a stand alone package to train a neural netowrk,. The trained neural network was stored as a .DEF file. The standalone software provided a .DLL and Delphi code to call the network and get the prediced values from your sw. (The .DLL was created in 2002 and apparently is 32 bit.) I have'nt used it for years but am now coming back to it.... I now use Delphi XE on Windows 7 (32 bit) The old .exe's I had compiled from that time work fine. However in Delphi XE ...

Debugging in Delphi XE2 using another Delphi BDS process as host
Hi I've been using delphi a long time And I always had the possibility of debbuging Packages using another Delphi process as host. This is very useful to test the design-time side of packages. Now with XE 2 I can whether running with options - Debugger - Host Application or Attach to process Any ideas? Thanks Plp Pedro wrote: > Now with XE 2 I can whether running with options - Debugger - Host > Application or Attach to process What exactly are you having trouble with? Error messages, unexpected behavior, etc. -- Remy Lebeau (TeamB) Hi Remy ...

I wrote an application and used cracked delphi 7, after i bought delphi 7
I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? "I embezzled some money from my employer, returned the funds, and then got it back as a bonus. Can I still be arrested?" Uhhh .... didn't you just confess to a crime? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an appli...

Is it posible to configure Delphi XE3 IDE to use Delphi 7 compiler/debuger
Hi! Like many other developer out there I have several project which has been developed with older version of Delphi (Delphi 7). Since theese projects rely on some components which are not compatible with newer versions of Delphi (no newer versions available) I'm forced to do any maintnance on theese projects using Delphi 7. Another solution would be to find replacment components which would provide me with same capabilities and work with latest versions of Delphi. But this would probbably require compleete rewritings of my projects (lots and lots of work). So currently I'm using...

Web resources about - [Delphi] Using SendInput (Specificaly moving and clicking the mouse) - embarcadero.delphi.nativeapi

Talk:Nintendo DS storage devices - Wikipedia, the free encyclopedia
This article is within the scope of WikiProject Video games , a collaborative effort to improve the coverage of video games on Wikipedia. If ...

Alleged photos showing Sony Xperia Z3 leaked
A new set of images that allegedly show Sony's upcoming Xperia Z3 smartphone have been leaked by a person using a Chinese message board, which ...

Government of Colombia has selected the Oshkosh Sandcat Plasan 4x4 armoured vehicle 2012123 - Army Recognition ...
The Government of Colombia has selected the Oshkosh Sandcat Plasan 4x4 armoured vehicle, as new model of MRAP (Mine-Resistant Ambush Protected) ...

Cageprisoners.com - serving the caged prisoners in Guantanamo Bay
08/10/2005 UNCLASSIFIED Sunday 3 Jafallah Mari only Qatari prisioner [sic***] has fallen in the hunger strike. He was taken to hospital. His ...

Guitar Tabs, Guitar Chords and Lyrics - Chordie
Guitar chords and guitar tabs. Chordie is the largest collection of chords and tabs on the Internet, with more than 200.000 songs from hundreds ...

FlyCraft gets updated for BlackBerry 10 and the PlayBook - More features for Herbie
FlyCraft for BlackBerry 10 and the PlayBook gets a bunch of new features in an update.

DJ TechTools   -   Serato Tips
Modern DJ software has nearly every feature you could ever want, but very few (other than Torq) offer the ability to warp songs. More specificaly, ...

Why You Should Consider the Moto X
... some enhancements to deal with those issues. Starting with Android 4.1, the Android team began to address performance issues dealing specificaly ...

'Minecraft' is geting a story-based game from the studio behind 'The Walking Dead' and 'Game of Thrones' ...
Minecraft's silent landscaper Steve is exiting his blocky world and stepping into Telltale's world of stories: Minecraft is getting a "narrative-driven" ...

Enforcement Agency Speeches « FCPA Professor
FCPA Professor A Forum Devoted to the Foreign Corrupt Practices Act Home About FCPA 101 FCPA Institute FCPA Connect Training Books Search Donate ...

Resources last updated: 1/6/2016 11:52:28 PM