Jump to content

  • Log In with Google      Sign In   
  • Create Account

Send messages to some windows


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 06 May 2013 - 04:18 PM

I want to create an app that can send a message to the skype window saying that i pressed button x.(just an example)

 

How would I do that? I heard about spy++ but I have a hard time finding how to actually use it in code.



Sponsor:

#2 NightCreature83   Crossbones+   -  Reputation: 2826

Like
0Likes
Like

Posted 07 May 2013 - 01:33 AM

Read this as there is probably a better way of doing this in windows: http://blogs.msdn.com/b/oldnewthing/archive/2009/02/02/9388941.aspx


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#3 irreversible   Crossbones+   -  Reputation: 1347

Like
0Likes
Like

Posted 07 May 2013 - 08:15 AM

You could:

 

OPTION 1:

1) as prep work, call WindowFromPoint() to manually get the Skype window's name by hovering over it on your desktop (or just google for it ;) ) - just call it as response to a WM_MOUSEMOVE in a test application

2) programmatically call FindWindow() to look for the window name from 1 and get the HWND

 

OPTION 2:

1) use the process name as a starting point

 

3) GetWindowThreadProcessId() returns the process's ID from HWND

4) Enumerate and get the process' main thread from the window handle (I'm pretty sure it's the first one)

5) Send the message using PostThreadMessage()



#4 Adam_42   Crossbones+   -  Reputation: 2507

Like
1Likes
Like

Posted 07 May 2013 - 01:21 PM

If the window has focus then SendInput() should do the trick.

 

However, you'd probably be better off using the Skype API directly.



#5 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 07 May 2013 - 02:21 PM

Solved it.Decided to use FindWindow() to get the window's hwnd.The I use SendMessage to create an artificial mouse click.



#6 jwezorek   Crossbones+   -  Reputation: 1861

Like
0Likes
Like

Posted 07 May 2013 - 03:32 PM

Solved it.Decided to use FindWindow() to get the window's hwnd.The I use SendMessage to create an artificial mouse click.

 

This might not work the way you expect if you need to send keystrokes though.

 

In the case of keyboard events more happens when you type than just a WM_*  msg popping up in some windows message queue and it is impossible for these events to arise in a non-foreground window under normal use, so merely fabricating windows messages usually doesn't do what you want it to do. The way to do this that actually works for keyboards is to make the target window foreground and use SendInput(...) as someone said above; although, I don't think it is possible to foreground an arbitrary window across processes the way that it was years ago ... so not sure.

 

Actually I'm slightly surprised sending a WM_LBUTTONDOWN or whatver actually worked. This can have all kinds of unexpected results, if the target window proc uses GetCursorPos() instead of the coordinates in the WPARAM etc.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS