Is possible to send the key {Home} to an active application with out prssing the {Home} key
I have a media player it record button shotcut key is {Home} key, i want to send the {Home} key from my c# windows
appliy to mediaplaayer (Without prssing thr{Home} key)
Is it possible pss tell me
Aleksandar IlioskiPosted Mar 8, 2009, 3:56 AM
I send the post before with "Opera" and i don't like the formating so, I'll try with IE now:
// Get a handle to an application window.
[DllImport("USER32.DLL",EntryPoint = "FindWindow")]
public static extern IntPtr NajdiProzorec(string lpClassName, string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
// Send a series of key presses to the Calculator application.
private void button1_Click(object sender, EventArgs e)
{
}
This is how to send keys on the calculator instead of your player but it is the same...
if you want to send "Home" key i think it is:
SendKeys.SendWait("{HOME}");
You can read more about this on the topic "How do I" at www.csharpcorner.com
Aleksandar IlioskiPosted Mar 8, 2009, 11:54 AM
Hi
I have imported user32.dll so I can use the metods findWindow, and setForegroundWindow,
-findWindow* need me so I can find "IntPtr CalculatorHandle"
This is a number used from operating System for identifying process, every process has own handle number, "findWindow metod" produce that number for us,
after we know this number we can use that number in:
-"setFoergroudWindow metod so we can activate (in my case)Calculator process, or should i say this metod give the focus to the process (in my case calculator)...
You shuold find the two strings, that takes findWindow method, className, and WindowName for your player so you can use the findwindow method. You can do this using some program like spy++ if you have VisualStudio or somethig like it...
* I am from Macedonia, and FindWindow in english = NajdiProzorec in Macedonian, that's why i use that word for my method...
Hope this will help you
Pramod Kumar NandagiriPosted Mar 8, 2009, 4:49 AM
I liked the prog which u have sent ,it is very useful
U have written code for keyboard focus but iam not getting it clearly so could u plss help me on that
IntPtr calculatorHandle = NajdiProzorec("SciCalc", "Calculator"); //Here how can i set the mediaplayer settings
Why u have imported user32.dll plss tell me
When i run my i applycation my keyboard focus is not on the mediaplayer
so plss tell me how to set the keyboardfocus on mediaplayer
thanks,
pramod.
Aleksandar IlioskiPosted Mar 8, 2009, 3:48 AM