473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hotkey type scenerio

I have an application thats a viewer. I also have a form that is fired from
a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John
Nov 20 '05 #1
5 3139
"jcrouse" <me> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John


Have a look at the MenuItem.Shortc ut property. The key (pun intended) to
what you are looking for lies in the associated type converter for this.
I've never seen much documented on it, but I guess since the enumeration is
serializable, it is used internally by the IDE for code generation? And now
also by you. :-)

Stick this in some code, and type a period after it to see the goodies that
come up. I think it will help you get where you are going.

System.Componen tModel.TypeDesc riptor.GetConve rter(GetType(Sh ortcut))

Best Regards,

Andy
Nov 20 '05 #2
Here's the direction I'm headed.

Private Sub txtExitKey_KeyP ress(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtExitKey.KeyP ress

If Char.IsLetterOr Digit(e.KeyChar ) Then

txtExitKey.Sele ctionStart = 0

txtExitKey.Sele ctionLength = Len(txtExitKey. Text)

ElseIf Char.IsControl( e.KeyChar) Then

Select Case e.KeyChar

Case Microsoft.Visua lBasic.ChrW(27)

txtExitKey.Text = "Esc"

Case Microsoft.Visua lBasic.ChrW(9)

txtExitKey.Text = "Tab"

Case Microsoft.Visua lBasic.ChrW(13)

txtExitKey.Text = "Enter"

Case Microsoft.Visua lBasic.ChrW(16)

txtExitKey.Text = "Shift"

Case Microsoft.Visua lBasic.ChrW(17)

txtExitKey.Text = "Ctrl"

Case Microsoft.Visua lBasic.ChrW(19)

txtExitKey.Text = "Pause"

Case Microsoft.Visua lBasic.ChrW(20)

txtExitKey.Text = "Caps Lock"

Case Microsoft.Visua lBasic.ChrW(32)

txtExitKey.Text = "Spacebar"

Case Microsoft.Visua lBasic.ChrW(33)

txtExitKey.Text = "Page Up"

Case Microsoft.Visua lBasic.ChrW(34)

txtExitKey.Text = "Page Down"

Case Microsoft.Visua lBasic.ChrW(35)

txtExitKey.Text = "End"

Case Microsoft.Visua lBasic.ChrW(36)

txtExitKey.Text = "Home"

Case Microsoft.Visua lBasic.ChrW(37)

txtExitKey.Text = "Left Arrow"

Case Microsoft.Visua lBasic.ChrW(38)

txtExitKey.Text = "Up Arrow"

Case Microsoft.Visua lBasic.ChrW(39)

txtExitKey.Text = "Right Arrow"

Case Microsoft.Visua lBasic.ChrW(40)

txtExitKey.Text = "Down Arrow"

Case Microsoft.Visua lBasic.ChrW(42)

txtExitKey.Text = "Print Screen"

Case Microsoft.Visua lBasic.ChrW(45)

txtExitKey.Text = "Insert"

Case Microsoft.Visua lBasic.ChrW(46)

txtExitKey.Text = "Delete"

Case Microsoft.Visua lBasic.ChrW(144 )

txtExitKey.Text = "Num Lock"

Case Microsoft.Visua lBasic.ChrW(112 )

txtExitKey.Text = "F1"

Case Microsoft.Visua lBasic.ChrW(113 )

txtExitKey.Text = "F2"

Case Microsoft.Visua lBasic.ChrW(114 )

txtExitKey.Text = "F3"

Case Microsoft.Visua lBasic.ChrW(115 )

txtExitKey.Text = "F4"

Case Microsoft.Visua lBasic.ChrW(116 )

txtExitKey.Text = "F5"

Case Microsoft.Visua lBasic.ChrW(117 )

txtExitKey.Text = "F6"

Case Microsoft.Visua lBasic.ChrW(118 )

txtExitKey.Text = "F7"

Case Microsoft.Visua lBasic.ChrW(119 )

txtExitKey.Text = "F8"

Case Microsoft.Visua lBasic.ChrW(120 )

txtExitKey.Text = "F9"

Case Microsoft.Visua lBasic.ChrW(121 )

txtExitKey.Text = "F10"

Case Microsoft.Visua lBasic.ChrW(122 )

txtExitKey.Text = "F11"

Case Microsoft.Visua lBasic.ChrW(123 )

txtExitKey.Text = "F12"

Case Else

Dim response As String

response = MsgBox("That key is not supported.",
vbCritical, "CPViewer")

txtExitKey.Focu s()

End Select

End If

End Sub

Private Sub txtExitKey_KeyU p(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles txtExitKey.KeyU p

txtExitKey.Sele ctAll()

End Sub

This isn't working however. Also, I need to distinguish between the left and
right Shift, Alt and Ctrl keys. Also, when done, I need to somehow write it
out to aN XML file in some format that my app can read back in the next time
it's launched. I have the XML working for digits and numbers but am not sure
what kink this will throw into things.

Thanks,
John

PS...I REALLY hate .Net !!!!
"jcrouse" <me> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #3
Check out the Keys class, it has enumeration members which is what u need.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"jcrouse" <me> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #4
Resolved !

"jcrouse" <me> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #5
Resolved !

"jcrouse" <me> wrote in message
news:Os******** ******@TK2MSFTN GP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #6

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

Similar topics

1
1912
by: Nitesh Jain | last post by:
I want to write a simple utility, so that if I select a text, and press a hot key say (CTRL+ALT+G), then I should be able to open a google search page with the selected text. Could someone tell me how to get the selected text when this hotkey is pressed.
0
1444
by: kurotsuke | last post by:
Can anybody tell me where I can find a sample C# forms that implements the hotkey selection like in babylon so that the user can actually press the hotkey combination instead of selecting the keys on a listbox? Thanks.
3
2606
by: Rsrany | last post by:
I've been working on a few gtk applications and need to tie a hot key catcher into a thread. I am currently finding threaded user32.GetMessageA do not work. I have included two programs: 1) a non-threaded version that works 2) a threaded version that doesnt work. Any constructive suggestions would be helpful
0
1807
by: yasker | last post by:
I register a hotkey following this article: http://www.dotnet2themax.com/ShowContent.aspx?ID=103cca7a-0323-47eb-b210-c2bb7075ba78 Using windows api to archive it. But when I use it as a part of my program(it would minimize to tray before you call it), I found it doesn't work. Finally I found the statement which cause it: this.ShowInTaskbar = false; Though I wrote "ShowInTaskbar = true" later in the program, but hotkey didn't work...
1
5960
by: Rune Jacobsen | last post by:
Hi all, I have some often-performed tasks in my applications that I want users to be able to specify hotkeys for. However, I don't want to hard code these hotkeys, as sooner or later some other app is bound to use the same thing, causing end user frustration. So I want the end user to be able to specify the hot key to use for task X in the configuration window. Now receiving and handling the hotkey is no problem. I do that easily...
2
1445
by: cr113 | last post by:
Is there another way to get the parameters for a method without checking Parameter Information under Tools/Options? I keep it unchecked because 99% of the time I don't need it and all it does is irritate me. Is there a hotkey or something for that?
9
18897
by: k04jg02 | last post by:
I want to make a Python app that runs in the background, and when a user hits a key combination, for a function to run. This sounds simple enough, but all of the keypress detecting libraries I can find count on you creating a window and then detecting keypresses while that window has focus. I want my function to execute when the user presses the hotkey anywhere. I searched the PyGTK documentation and found an old newsgroup post where...
3
2532
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I want to have following hotkey used in asp.net application, how to do this especially for F5? ESC F3 F4 F5 F6 F9 F10
18
44737
by: AdamOnAccess | last post by:
Anyone know an easy way to toggle between Form and Design view with a hotkey? I know you can switch from Design view to Form view with hotkey F5. But is there a hotkey to switch back (from Form view to Design)? Shift-F5 is not it. I've searched Google and I can't believe I couldn't find an answer. Please help. Adam
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.