473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Assign a hot key to an application

Hai all,
I have created an application which is something like a trouble
shooter. I want to use the F12 key. When the is user is using some
other application say Internet Explorer and if he presses F12 then my
application should pop up. I made a registry entry so that my
application starts when the user logs in. and I have a sys tray icon
for my application. but I can get the F12 key press. I works only when
some form of that particular application is active.

Can any body help me out.

Thank you all in advance.

S.ArulPrakash
Jul 17 '05 #1
5 7374
On 2 Jan 2004 02:18:42 -0800, sa**********@rediffmail.com
(ArulPrakash) wrote:
Hai all,
I have created an application which is something like a trouble
shooter. I want to use the F12 key. When the is user is using some
other application say Internet Explorer and if he presses F12 then my
application should pop up. I made a registry entry so that my
application starts when the user logs in. and I have a sys tray icon
for my application. but I can get the F12 key press. I works only when
some form of that particular application is active.

Can any body help me out.


You need to look at RegisterHotKey

There is an example in the downloadable API Guide from

www.AllAPI.net
Jul 17 '05 #2
thank you J French. It worked out. I thought of hooking the keyboard
and all that complex stuffs.

Thank You.
ArulPrakash.S
er*****@nowhere.com (J French) wrote in message news:<3f***************@news.btclick.com>...
On 2 Jan 2004 02:18:42 -0800, sa**********@rediffmail.com
(ArulPrakash) wrote:
Hai all,
I have created an application which is something like a trouble
shooter. I want to use the F12 key. When the is user is using some
other application say Internet Explorer and if he presses F12 then my
application should pop up. I made a registry entry so that my
application starts when the user logs in. and I have a sys tray icon
for my application. but I can get the F12 key press. I works only when
some form of that particular application is active.

Can any body help me out.


You need to look at RegisterHotKey

There is an example in the downloadable API Guide from

www.AllAPI.net

Jul 17 '05 #3
On 3 Jan 2004 01:24:07 -0800, sa**********@rediffmail.com
(ArulPrakash) wrote:
thank you J French. It worked out. I thought of hooking the keyboard
and all that complex stuffs.


Not just complex - also rather dangerous

Out of curiousity, how did you intercept the WM_HOTKEY message ?
- sub-classing or like KPD's interesting method
Jul 17 '05 #4
er*****@nowhere.com (J French) wrote in message news:<3f***************@news.btclick.com>...
On 3 Jan 2004 01:24:07 -0800, sa**********@rediffmail.com
(ArulPrakash) wrote:
thank you J French. It worked out. I thought of hooking the keyboard
and all that complex stuffs.


Not just complex - also rather dangerous

Out of curiousity, how did you intercept the WM_HOTKEY message ?
- sub-classing or like KPD's interesting method


I just copied the example from KPD given and modified the key
combination to match my requirement.

But I already completed the exercise by hooking the keyboard and
tracing each and every key pressed onto a text box. I will get all the
keypress actions i a text box and check for my hot key. that too
worked out.

here is the window procedure i have return with hooking the keyboard:
Public Function WindowProc(ByVal hwnd As Long, ByVal Msg As Long,
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim RetVal As Long
Dim KeyAscii As Long
Dim KeyName As String

If Msg = WM_USER Then
If (lParam And &H80000000) = 0 Then
If GetKeyboardState(KeyboardState(0)) <> 0 Then
RetVal = ToAscii(wParam, lParam, KeyboardState(0),
KeyAscii, 0)
If (RetVal = 1) And ((KeyAscii > 31) Or (KeyAscii = 13))
Then

If KeyAscii = 13 Then
Form1.Text1.Text = Form1.Text1.Text & "{ENTER}"
Else
Form1.Text1.Text = Form1.Text1.Text &
Chr(KeyAscii)
End If
Else
KeyName = String(20, " ")
RetVal = GetKeyNameText(lParam, KeyName, 20)
If RetVal <> 0 Then
KeyName = Left(KeyName, RetVal)
Form1.Text1.Text = Form1.Text1.Text & "{" &
KeyName & "}"
End If
End If
End If
Else

End If
End If
If (GetKeyState(VK_SHIFT) And &HF0000000) And
(GetKeyState(VK_CONTROL) And &HF0000000) And (GetKeyState(VK_F12) And
&HF0000000) Then

Form1.Combo1.Text = Form1.Combo1.List(0)
Form1.Show

End If
WindowProc = CallWindowProc(PrevFuncPointer, hwnd, Msg, wParam,
lParam)
Exit Function
End Function

I made use of the API function "SetWindowsHookEx" and
"UnhookWindowsHookEx" and created a dll and used it in the exe. but i
had a problem that i have to register this exe in each and every
machine in the network and so on so i searched for another method to
assign hot key.

Any way thanks again J French.
Jul 17 '05 #5
On 5 Jan 2004 00:52:03 -0800, sa**********@rediffmail.com
(ArulPrakash) wrote:

<snip>

I made use of the API function "SetWindowsHookEx" and
"UnhookWindowsHookEx" and created a dll and used it in the exe. but i
had a problem that i have to register this exe in each and every
machine in the network and so on so i searched for another method to
assign hot key.


That is very interesting - an AX DLL seems to have done the trick
- I've only managed that with Delphi DLLs

I agree totally that the HotKey method is cleaner
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: aa | last post by:
I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters. Is there a similar...
1
by: gaffar | last post by:
Hello Sir, How to assign more than one primary key to table by this below following code. i am able assign to a single field only. how to assign primary key to more than one field. the primary key...
0
by: dudinissan | last post by:
Hello, I am writing c# web application. My code is: Excel.Application EXL; EXL = new Excel.Application(); Excel.Worksheet WSheet = new Excel.WorksheetClass(); string FileName = MapPath(".") +...
2
by: WJ | last post by:
This post is a follow up from the original post dated Oct 16, 2004 "I have this problem, pls help!" created by Paul FI. These bugs are rather serious and we would like to know how to get around. ...
2
by: gaffar | last post by:
Hello Sir, How to assign more than one primary key to table by this below following code. i am able assign to a single field only. how to assign primary key to more than one field. the primary key...
3
by: QLD_AU | last post by:
Is their a way in a VB.Net application to set all sub form icons to the main form ? or even set all icons to the Application icon, without having to reference the icon as a filename ? With...
2
by: Randy Yates | last post by:
Forgive me if this is a basic and trivial (i.e., stupid) question. I haven't been using postgres very long, and I'm not an experienced database system developer. I noticed that there is a very...
5
by: J-T | last post by:
I guess I'm a litte bit confused about app pool and worker process. In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process...
7
by: Joe | last post by:
Is it possible to have a component which is global to the entire application? I need to have a single component act sort of like a server which components in any of the forms can access. For...
1
by: johnyjj2 | last post by:
Hello! I've got web application created for MSSQL and IIS. There are two directories in this application - Scripts and WebSite. In Script there is file CreateDb.sql. I need to run it so that it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.