Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
2,345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +1
13 Comments
 
LVL 1

Author Comment

by:Cédric MARCOUX
ID: 20356941
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:2266180
ID: 20357335
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
ID: 20357385
my appz has no child cause this is a direct3d apllication...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 28

Expert Comment

by:2266180
ID: 20357705
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
ID: 20357723
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 20357738
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
 
LVL 1

Author Comment

by:Cédric MARCOUX
ID: 20358274
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
ID: 20364528
Any idea?
I know that other program can do it...
Increased to 500
0
 
LVL 28

Expert Comment

by:2266180
ID: 20365284
not in my area of expertiese (directx). sorry.
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 2000 total points
ID: 20365313
 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
ID: 20367068
will try, thanks for trick
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20632777
Forced accept.

Computer101
EE Admin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

636 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