|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
KeyDown for non Active windows?I want to trap a key at the System wide level.
Similar to Win-Amp ... you can press - Ctrl-Alt-Pg down from Any Program & switch songs. How can I do this in VB.Net? gregory_may wrote:
> I want to trap a key at the System wide level. Here's how I do it with Alt-F12 (As always, watch for Line-Wrapping!):> > Similar to Win-Amp ... you can press - Ctrl-Alt-Pg down from Any Program & > switch songs. > > How can I do this in VB.Net? > > > Public Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal s As String) As Int32 Const WM_SETHOTKEY As Long = &H32 Const HotKey_Alt_F12 As Long = &H47B Private Sub MainFrm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load SendMessage(Me.Handle, WM_SETHOTKEY, HotKey_Alt_F12, 0) End Sub Hope this helps. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't. Thanks!
Show quoteHide quote "ShaneO" <shane***@optusnet.com.au> wrote in message news:4436dbb2$0$7528$afc38c87@news.optusnet.com.au... > gregory_may wrote: >> I want to trap a key at the System wide level. >> >> Similar to Win-Amp ... you can press - Ctrl-Alt-Pg down from Any Program >> & switch songs. >> >> How can I do this in VB.Net? >> >> >> > Here's how I do it with Alt-F12 (As always, watch for Line-Wrapping!): > > Public Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As > IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal s As String) As > Int32 > > Const WM_SETHOTKEY As Long = &H32 > Const HotKey_Alt_F12 As Long = &H47B > > Private Sub MainFrm_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > > SendMessage(Me.Handle, WM_SETHOTKEY, HotKey_Alt_F12, 0) > > End Sub > > Hope this helps. > > ShaneO > > There are 10 kinds of people - Those who understand Binary and those who > don't. I found this, but not sure if its overkill? I am curious why your code is
so short? http://www.dotnet2themax.com/ShowContent.aspx?ID=103cca7a-0323-47eb-b210-c2bb7075ba78 Show quoteHide quote "ShaneO" <shane***@optusnet.com.au> wrote in message news:4436dbb2$0$7528$afc38c87@news.optusnet.com.au... > gregory_may wrote: >> I want to trap a key at the System wide level. >> >> Similar to Win-Amp ... you can press - Ctrl-Alt-Pg down from Any Program >> & switch songs. >> >> How can I do this in VB.Net? >> >> >> > Here's how I do it with Alt-F12 (As always, watch for Line-Wrapping!): > > Public Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As > IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal s As String) As > Int32 > > Const WM_SETHOTKEY As Long = &H32 > Const HotKey_Alt_F12 As Long = &H47B > > Private Sub MainFrm_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > > SendMessage(Me.Handle, WM_SETHOTKEY, HotKey_Alt_F12, 0) > > End Sub > > Hope this helps. > > ShaneO > > There are 10 kinds of people - Those who understand Binary and those who > don't. gregory_may wrote:
> I found this, but not sure if its overkill? I am curious why your code is Gregory, I can't access your link at the time of this message (maybe a > so short? > > http://www.dotnet2themax.com/ShowContent.aspx?ID=103cca7a-0323-47eb-b210-c2bb7075ba78 > > temporary problem) however I too have seen some VERY long-winded code written to do exactly what the code I provided does easily. If you've tried it yourself then you will know it works perfectly. The long-winded approach seems more common for .NET solutions than anything I've ever seen before and is something I have commented on in the past. I don't know why it is so, but maybe that could be the topic of a post on its own - like, Why are some people making things that are easy seem so difficult?? ShaneO There are 10 kinds of people - Those who understand Binary and those who don't. Hi,
this is very interesting. I don't understand where to search for the other key codes on MSDN. The WM_SETHOTKEY topic isn't of much help. Thanks, Tom. Show quoteHide quote "ShaneO" <shane***@optusnet.com.au> wrote in message news:4436dbb2$0$7528$afc38c87@news.optusnet.com.au... > gregory_may wrote: >> I want to trap a key at the System wide level. >> >> Similar to Win-Amp ... you can press - Ctrl-Alt-Pg down from Any Program >> & switch songs. >> >> How can I do this in VB.Net? >> >> >> > Here's how I do it with Alt-F12 (As always, watch for Line-Wrapping!): > > Public Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As > IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal s As String) As > Int32 > > Const WM_SETHOTKEY As Long = &H32 > Const HotKey_Alt_F12 As Long = &H47B > > Private Sub MainFrm_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > > SendMessage(Me.Handle, WM_SETHOTKEY, HotKey_Alt_F12, 0) > > End Sub > > Hope this helps. > > ShaneO > > There are 10 kinds of people - Those who understand Binary and those who > don't.
Timespan perplexing, please help with brain freeze.
Reg expression DataGridView - Property DataPropertyName Threading 101 Can the read() function in VB.NET start reading from somewhere else than 0 Frustrations with RTF format. XML Logging Write one record Shared Variable Question VB.NET 2003 VB proj file locations DirectoryInfo.GetFiles -> from all subfolders |
|||||||||||||||||||||||