Hi
I have an VB.Net application running in the System Tray and I have a function in the appln. I need to invoke the function irrespective of the application which is active by assigning a global shortcut or a hotcut key. How to assign a global shortcut or a hotcut key.

Short Cut to my application running in the System tray
slimjen1
Hi
The article was really great, helpful and it worked perfectly.
Thanks.
Magnus Sthlm
Have you tried code from my previous post about pasting clipboard to the notepad
velkan
Is there any chance that we can print some data onto an application.
Consider i want to paste the clipboard content to the notepad when or where the hotkey is pressed.
I guess we use Process.
But not sure how to write onto a running process.
I have the code for finding the processes name running on a local machine.
Array arr = new Array[50];arr = System.Diagnostics.
Process.GetProcesses(); int len = arr.Length;label1.Text = arr.Length.ToString();
for (int i = 0; i < len; i++){
String temp = arr.GetValue(i).ToString().Substring(28);temp = temp.Substring(0, temp.Length - 1);
listBox1.Items.Add(temp);
temp =
null;}
AAG
Hi,
Thanks for the code. Its working fine.
And sorry for the delayed reply.......
KingCobra
MrJP
Hi,
Here is the code.
This is a simple application which takes text from clipboard and writes it to the notepad.
Process application does,
BEFORE YOU START THE FOLLOWING APPLICATION, COPY SOME TEXT FROM ANYWHERE SO CLIPBOARD WILL HAVE SOME DATA THAT OUR APPLICATION WILL WRITE INTO NOTEPAD
You can seperate out the code, use it as per your need.
private
const int WM_SETTEXT = 0x000C;[DllImport("user32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter,string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
private
void CopyClipboardTextToNotepad(){
//Get text from the clipboard
IDataObject iData = Clipboard.GetDataObject();
string str = string.Empty;
if (iData.GetDataPresent(DataFormats.Text))
{
str = (String)iData.GetData(DataFormats.Text);
}
else
{
str = "Could not retrieve data from the clipboard.";
}
//Starts the notepad process
Process objProcess = new Process();
objProcess.StartInfo.FileName = "notepad";
objProcess.Start();
objProcess.WaitForInputIdle(); //This is required else the MainWindowHandle will be ZERO and the rest of the process will not work
//Get the editable notepad area where we will write the text
IntPtr notepadHandle = FindWindowEx(objProcess.MainWindowHandle, IntPtr.Zero, "Edit", "");
//Write the text that we got from clipboard into the notepad.
SendMessage(notepadHandle, WM_SETTEXT, 0, str);
}
HTH,
IS dude
Hi,
This is your desired solution..
http://www.dotnet2themax.com/ShowContent.aspx ID=103cca7a-0323-47eb-b210-c2bb7075ba78
Follow the instructions given carefully in this article, it will solve your purpose.
Just one thing you need to take care is,
in "WndProc" method mentioned in this article, write
this.YourDesiredMethodOnGlobalHotkey();
instead of
this.Activate();
I have tested this and works perfectly.
Take care that you dont use already registered hotkey (i.e. Windowskey + E etc used by system itself as global hotkey) else you will get exception with error code 1409 mentioning that hotkey is already in use/registered.
HTH,