Jump to content
  • Advertisement
Sign in to follow this  
dan1088352

need c++ help

This topic is 4992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Is this a Win32 program, or is it a console program?

You can simulate a keypress by sending a WM_KEYDOWN message to your window with the function SendMessage.

SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );

where hWnd is the handle to your window. The statement would look like this.

SendMessage(hWnd, WM_KEYDOWN, VK_RETURN, 0);

Share this post


Link to post
Share on other sites
if you mean the user will have to press a key, then look at getch() or bioskey()
if you want the computer to press a key, then just call the same functions as you called when you press that key.

Share this post


Link to post
Share on other sites
Quote:
Original post by dan1088352
this is a console program, I am trying to have it press a key for another program.


What type of program is the other program? if it's a win32 program simply fetching a hwnd to the correct window and using SendMessage will probably suffice

Share this post


Link to post
Share on other sites
I don't think so. :)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindow.asp

Put shortly:
hWnd = FindWindow(LPCSTR ClassName, LPCSTR WindowName);

Pass NULL for the missing parameters if you only have one of the parameters.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by GotenRulezU
How do you fetch the hwnd of another program? Isn't that illegal?
Hip Hip Cheerio,


Yes, you can get $10,000 fine and/or 5 years in jail.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!