Hotkeys For Specific Applications?

O

Octavius Khan

How can I set system hotkey that will only work for specific applications.
For example, I have a system tray application that uses hotkeys to perform
certain tasks like placing text into a memo field of another application,
etc. However, I don't want these hotkeys to be for "every" application. I
just want them to work for, let's say Notepad or Wordpad or Internet
Explorer.

I already know how to set systemwide hotkeys, but I'd like to know how to
limit their use to certain applications.

Thanks.
 
K

kimiraikkonen

How can I set system hotkey that will only work for specific applications.
For example, I have a system tray application that uses hotkeys to perform
certain tasks like placing text into a memo field of another application,
etc.  However, I don't want these hotkeys to be for "every" application. I
just want them to work for, let's say Notepad or Wordpad or Internet
Explorer.

I already know how to set systemwide hotkeys, but I'd like to know how to
limit their use to certain applications.

Thanks.

IIUC, you want to start such applications by with key down event under
your VB.NET program. There are lots of ways to do this. First set
keypreview value to "true" for your form, if your aim is to start apps
using objects such as buttons rather than using your form, use the
same event for your objects. Then use process class to fire
application.

Example for a form:

Private Sub Form1_keydown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.<key> Then
system.diagnostics.process.start("notepad.exe")
End If
 
O

Octavius Khan

I forgot about keypreview. Thanks for pointing me in the right direction.
:)

How can I set system hotkey that will only work for specific applications.
For example, I have a system tray application that uses hotkeys to perform
certain tasks like placing text into a memo field of another application,
etc. However, I don't want these hotkeys to be for "every" application. I
just want them to work for, let's say Notepad or Wordpad or Internet
Explorer.

I already know how to set systemwide hotkeys, but I'd like to know how to
limit their use to certain applications.

Thanks.

IIUC, you want to start such applications by with key down event under
your VB.NET program. There are lots of ways to do this. First set
keypreview value to "true" for your form, if your aim is to start apps
using objects such as buttons rather than using your form, use the
same event for your objects. Then use process class to fire
application.

Example for a form:

Private Sub Form1_keydown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.<key> Then
system.diagnostics.process.start("notepad.exe")
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top