Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Community
Technology
Technology Q&A
Visual Basic Help (Hotkeys)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Heaplink" data-source="post: 229438" data-attributes="member: 8966"><p>The first thing is that, if you wan't to work with global hotkeys (hotkeys that work outside your application window) you'd have to use the WinAPI (Windows' core API).</p><p></p><p>This can be done by doing this</p><p>[CODE]Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer[/CODE]</p><p></p><p>GetKeyPress is now a declared function using the user32 library and returns an integer - here you can use the Keys enum when available, since that will return a integer by name so to listen for when a key is pressed you can do something like this</p><p></p><p>[CODE]If GetKeyPress(Keys.Enter)</p><p> MsgBox("You pressed enter!");</p><p>End If[/CODE]</p><p></p><p>and if you wan't to have combinations of keys pressed on same time (like CTRL+ALT+ENTER) you can do this too</p><p></p><p>[CODE]If GetKeyPress(Keys.Control) & GetKeyPress(Keys.Alt) & GetKeyPress(Keys.Enter)</p><p> MsgBox("C-c-c-combo! CTRL+ALT+Enter");</p><p>End If[/CODE]</p><p></p><p>Good luck <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Heaplink, post: 229438, member: 8966"] The first thing is that, if you wan't to work with global hotkeys (hotkeys that work outside your application window) you'd have to use the WinAPI (Windows' core API). This can be done by doing this [CODE]Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer[/CODE] GetKeyPress is now a declared function using the user32 library and returns an integer - here you can use the Keys enum when available, since that will return a integer by name so to listen for when a key is pressed you can do something like this [CODE]If GetKeyPress(Keys.Enter) MsgBox("You pressed enter!"); End If[/CODE] and if you wan't to have combinations of keys pressed on same time (like CTRL+ALT+ENTER) you can do this too [CODE]If GetKeyPress(Keys.Control) & GetKeyPress(Keys.Alt) & GetKeyPress(Keys.Enter) MsgBox("C-c-c-combo! CTRL+ALT+Enter"); End If[/CODE] Good luck :-) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Community
Technology
Technology Q&A
Visual Basic Help (Hotkeys)
Top