Solved

Simulate a mouse click on a window without focus or minimised to a specific x/y into this window

Posted on 2007-11-27
13
2,131 Views
Last Modified: 2013-11-23
Hi!
Just wonder how to simulate a mouse click into a specific posistion of a hidden/inactive/minimise window.

For exemple, I know the handle of a process.exe
I know that this handle window size is 480x320 and would like to simulate a click inside it at 355x155

Any idea?
0
Comment
Question by:Cédric MARCOUX
  • 5
  • 3
  • 3
  • +1
13 Comments
 
LVL 1

Author Comment

by:Cédric MARCOUX
Comment Utility
Here is my currunt code that not works
procedure TFRM_Main.Button3Click(Sender: TObject);

var AppzHandle : THandle; 

classname: array[0..255] of char; //

var hwndWinamp : THandle; 

begin

AppzHandle := FindWindow(nil,'My application');

GetClassName(AppzHandle,ClassName,SizeOf(ClassName));

hwndWinamp := FindWindow(classname,nil);

PostMessage(hwndWinamp, WM_RBUTTONDOWN, MK_RBUTTON,MakeLong(48,55));

sleep(1000);

PostMessage(hwndWinamp, WM_RBUTTONUP, MK_RBUTTON,MakeLong(48,55));

end;

Open in new window

0
 
LVL 28

Expert Comment

by:ciuly
Comment Utility
I tried the following and it workd (using total commander:

what you need to do is:
- find the window that uniquely identifies your target application
- work your way down until you find the child window you are interested in

one good tool to help you with this is http://www.greatis.com/delphicb/windowse/
var AppzHandle : THandle;

    hwndWinamp : THandle;

begin

  AppzHandle := FindWindow('TTOTAL_CMD', nil);

  assert(AppzHandle<>0);

  hwndWinamp := FindWindowEx(appzhandle, 0, 'TMyListBox',nil);

  assert(hwndWinamp<>0);

  PostMessage(hwndWinamp, WM_LBUTTONDOWN, MK_LBUTTON,MakeLong(500,500));

  sleep(1000);

  PostMessage(hwndWinamp, WM_LBUTTONUP, 0,MakeLong(500,500));

end

Open in new window

0
 
LVL 1

Author Comment

by:Cédric MARCOUX
Comment Utility
my appz has no child cause this is a direct3d apllication...
0
 
LVL 28

Expert Comment

by:ciuly
Comment Utility
I thought you ere trying something on winamp because of the variable name.

why didn't you specify that? it's a pretty important detail as a driectx application is not similar to win32 application and it doesn't behave like on either.

I'm not even sure if you can do that since as I remember, directx appications use some directx drivers for mouse/keyboard/etc. you coul try sending directly to the directx window if you are not in fullscreen, and that might work.
0
 
LVL 21

Expert Comment

by:developmentguru
Comment Utility
0
 
LVL 21

Expert Comment

by:developmentguru
Comment Utility
The only possible problem I see is that your window is minimized.  Since SendInput simulates the input at the lowest possible level, the recipient window would need to have focus.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:Cédric MARCOUX
Comment Utility
I don't try to to that on winamp, it's just a piece of code from another appz, but the target appz is a game...
And to be exact, the application is hidden using SW_HIDE not minimised
0
 
LVL 1

Author Comment

by:Cédric MARCOUX
Comment Utility
Any idea?
I know that other program can do it...
Increased to 500
0
 
LVL 28

Expert Comment

by:ciuly
Comment Utility
not in my area of expertiese (directx). sorry.
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 500 total points
Comment Utility
 Did you try the PAQ?  From what I can see SendInput is your only option due to the DriectX.  If the game is using DriectInput then sending windows messages will not work.

  If you are the one hiding the application then, instead of hiding it you could move it off screen.  this would allow it to retain focus and be used with the SendInput, while not being visible.  For testing purposes I would first determine if it will give it the commands while you can see it anyway.  This way you know the SendInput works for the DirectX.  With that out of the way, try hiding it.  If that breaks the code that worked, then try a different way of making it disappear.
0
 
LVL 1

Author Comment

by:Cédric MARCOUX
Comment Utility
will try, thanks for trick
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now