|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Holding down a keyIn the program I am writing I can simulate a MOUSE button hold down: Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Public Const MOUSEEVENTF_LEFTDOWN As Object = &H2 Public Const MOUSEEVENTF_LEFTUP As Object = &H4 Public Sub LeftDown() mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) End Sub Public Sub LeftUp() mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) End Sub Public Sub LeftClick() LeftDown() LeftUp() End Sub So I am Sure I can do this with a keyboard key (Specifically ALT, and the SHIFT keys). Sendkeys does not work (Its much like a click by sending a down AND an UP). As you can see I googled and found that using the hex &H2 to simulate a mouse button click worked I am sure there is a way to do it for the keyboard. Thanks if you can provide help. Daniel,
I don't see much VBNet code in what you show, it is more using VBNet to code Win32 However usualy is doing this just done by setting a keydown switch which is togled. Here a sample with some dynamic controls that you can mode over your screen completely with VBNet code.. http://www.vb-tips.com/dbPages.aspx?ID=c1be07ed-e66b-4080-bc11-47ef665ea0c2 I hope this helps, Cor Show quoteHide quote "Daniel N" <saintdark_***@yahoo.com> schreef in bericht news:aXCug.2437$nj6.687@fe08.lga... > Is there a way to hold down keys in vb.net? > > In the program I am writing I can simulate a MOUSE button hold down: > > > > Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal > dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As > Long) > > Public Const MOUSEEVENTF_LEFTDOWN As Object = &H2 > > Public Const MOUSEEVENTF_LEFTUP As Object = &H4 > > > > Public Sub LeftDown() > > mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) > > End Sub > > Public Sub LeftUp() > > mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) > > End Sub > > > > Public Sub LeftClick() > > LeftDown() > > LeftUp() > > End Sub > > > > So I am Sure I can do this with a keyboard key (Specifically ALT, and the > SHIFT keys). Sendkeys does not work (Its much like a click by sending a > down AND an UP). As you can see I googled and found that using the hex &H2 > to simulate a mouse button click worked I am sure there is a way to do it > for the keyboard. Thanks if you can provide help. > > "Daniel N" <saintdark_***@yahoo.com> schrieb: =>> Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal > dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As > Long) > > Public Const MOUSEEVENTF_LEFTDOWN As Object = &H2 > > Public Const MOUSEEVENTF_LEFTUP As Object = &H4 \\\ Public Declare Sub mouse_event Lib "user32.dll" ( _ ByVal dwFlags As Int32, _ ByVal dx As Int32, _ ByVal dy As Int32, _ ByVal cButtons As Int32, _ ByVal dwExtraInfo As Int32 _ ) Public Const MOUSEEVENTF_LEFTDOWN As Int32 = &H2 Public Const MOUSEEVENTF_LEFTUP As Int32 = &H4 /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Bug or Feature? CancelButton vs Escape Key
overides/loads usage AS400 - Ado.Net from Vb.Net Slow Query Times Can I make my Form visible during a debug session? Problems using Me.Scale in Framework 2.0 ListView and ImageList/ImageKey enforce event calling on inherited classes HELP: Problem Hosting the "Simplest" of VB.NET Apps Is this a bug: 2.2 - 0.4 = 1.8 but 1.2 - 0.4 = 0.8000001 ? detect if running on a terminal server |
|||||||||||||||||||||||