473,395 Members | 1,641 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,395 software developers and data experts.

How to setup a a "Global" shortcut in vb.net application?

I am writing an application for a customer and one of the late requirements is for a (ideally) configurable key stroke to display a form. This should operate no matter which form/ dialog is currently displayed. Firstly is this possible and secondly how do I do it without adding the same code to every single form and dialog box which now number about 40 and growing.

Windows 7, vs 2010, vb.net, infragistics controls.

Thanks in advance for any help.
Feb 4 '11 #1
1 2126
!NoItAll
297 100+
Check this link out:

http://www.freevbcode.com/ShowCode.asp?ID=4042
Here's the code from the above URL...

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetAsyncKeyState Lib "User32" _
  2.    (ByVal vKey As KeyCodeConstants) As Long
  3.  
Expand|Select|Wrap|Line Numbers
  1. Private Function KeyDown(ByVal vKey As KeyCodeConstants) _
  2.     As Boolean
  3.    KeyDown = GetAsyncKeyState(vKey) And &H8000
  4. End Function
  5.  
  6. 'DEMO USAGE
  7. Private Sub Timer1_Timer()
  8.    If KeyDown(vbKeyF10) Then MsgBox "You pressed F10!" 'This msgbox will appear regardless of the active app.
  9. End Sub
  10.  
I'm not entirely sure how this works - but it's worth a try. As for the Win32 API you really should PInvoke it properly - not like the code snippet above.
Feb 5 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: mrbog | last post by:
I have an array/hash that stores path information for my app. As in, what directory this is in, what directory that's in, what the name of the site is, what the products are called, etc. It's...
1
by: Chris Stromberger | last post by:
This doesn't seem like it should behave as it does without using "global d" in mod(). d = {} def mod(): d = 3 mod() print d
7
by: Lyn | last post by:
Hi and Season's Greetings to all. I have a question regarding the use of a qualifier word "Global". I cannot find any reference to this in Access help, nor in books or on the Internet. "Global"...
9
by: Javaman59 | last post by:
I saw in a recent post the :: operator used to reach the global namespace, as in global::MyNamespace I hadn't seen this before, so looked it up in MSDN, which explained it nicely. My question...
4
by: BB | last post by:
Hello all, I might be missing something here, but am trying to understand the difference between using application-level variables--i.e. Application("MyVar")--and global variables--i.e. public...
3
by: Pierre | last post by:
Hello, In an aspx page (mypage.aspx) from a web projet, I would like to get the value of a variable of the projet that is declared as public in a module. The variable can be called from...
2
by: Bryan | last post by:
I am currently working on a project that I am interested in porting to Win32 or .NET, but I don't know where to get started. I have quite a bit of experience with MFC, and I have been working with...
5
by: dave | last post by:
If I have a class that hold, for instance, user settings that should be accessible to the entire program logic, what is a good paradigm to use? In C++, I would have made it a global object,...
7
by: twang090 | last post by:
I find in other team member's project, they are referencing a type in following format " public static global::ErrorReport.Description Description = new global::ErrorReport.Description(); " I...
4
ChrisWang
by: ChrisWang | last post by:
Hi, I am having trouble understanding the use of 'global' variables I want to use a global variable with the same name as a parameter of a function. But I don't know how to use them at the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.