From: Steve on 15 Jun 2010 15:04 On Jun 15, 2:31 pm, Karl E. Peterson <k...(a)exmvps.org> wrote: > Steve explained : > > > > > > > Can anyone help me understand how to use the SetKeyboardState > > function. I have tried several examples I found online but none of > > them (nor any of my own attempts) work for sending keyboard > > combinations such as Ctrl+A. > > > Here is the code I currently have that does not work > > > Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState > > As Byte) As Long > > > Private Declare Function PostMessage Lib "user32" Alias > > "PostMessageA" ( _ > > > ByVal hwnd As Long, _ > > > ByVal wMsg As Long, _ > > > ByVal wParam As Long, _ > > > ByVal lParam As Long) As Long > > > Private Const WM_KEYDOWN As Long = &H100 > > Private Const KEYSTATE_KEYDOWN As Long = &H80 > > > Sub SendCtrl_A() > > Dim tmpState(0 To 255) As Byte > > > tmpState(vbKeyControl) = KEYSTATE_KEYDOWN > > SetKeyboardState tmpState(0) > > > PostMessage hwnd, WM_KEYDOWN, vbKeyA, 0& > > > End Sub > > > Can someone tell me what I am doing wrong. > > Well, not precisely, because I really haven't done this much. But > there's a precise order you need to send the keystrokes in. I think > you'll want to first send the Control down, then the A down, then the A > up, then the Control up. Not sure what you're trying to do with > SetKeyboardState? > > -- > .NET: It's About Trust! http://vfred.mvps.org > Customer Hatred Knows No Bounds at MSFT > ClassicVB Users Regroup! comp.lang.basic.visual.misc > Free usenet access athttp://www.eternal-september.org- Hide quoted text - > > - Show quoted text - As I understand it the Control keys are managed via keyboard state and can not simply be sent via the send/postmessage functions. However this could be wrong as I have no personal experience with it. I think I already tried simply sending the control key with a send message but I will try again and let you know how it works. Thanks, Steve
From: Karl E. Peterson on 15 Jun 2010 15:34 Steve wrote: >>> Can someone tell me what I am doing wrong. >> >> Well, not precisely, because I really haven't done this much. �But >> there's a precise order you need to send the keystrokes in. �I think >> you'll want to first send the Control down, then the A down, then the A >> up, then the Control up. �Not sure what you're trying to do with >> SetKeyboardState? > > As I understand it the Control keys are managed via keyboard state and > can not simply be sent via the send/postmessage functions. However > this could be wrong as I have no personal experience with it. I think > I already tried simply sending the control key with a send message but > I will try again and let you know how it works. Hmmm, well, that's possible. It's not how I do with SendInput, which I may be confusing here with SendMessage methods. -- ..NET: It's About Trust! http://vfred.mvps.org Customer Hatred Knows No Bounds at MSFT ClassicVB Users Regroup! comp.lang.basic.visual.misc Free usenet access at http://www.eternal-september.org
From: Steve on 15 Jun 2010 16:01 On Jun 15, 3:34 pm, Karl E. Peterson <k...(a)exmvps.org> wrote: > Steve wrote: > >>> Can someone tell me what I am doing wrong. > > >> Well, not precisely, because I really haven't done this much. But > >> there's a precise order you need to send the keystrokes in. I think > >> you'll want to first send the Control down, then the A down, then the A > >> up, then the Control up. Not sure what you're trying to do with > >> SetKeyboardState? > > > As I understand it the Control keys are managed via keyboard state and > > can not simply be sent via the send/postmessage functions. However > > this could be wrong as I have no personal experience with it. I think > > I already tried simply sending the control key with a send message but > > I will try again and let you know how it works. > > Hmmm, well, that's possible. It's not how I do with SendInput, which I > may be confusing here with SendMessage methods. > > -- > .NET: It's About Trust! http://vfred.mvps.org > Customer Hatred Knows No Bounds at MSFT > ClassicVB Users Regroup! comp.lang.basic.visual.misc > Free usenet access athttp://www.eternal-september.org Well simply send the control key (via sendmessage or postmessage) did not work. Steve
From: Karl E. Peterson on 15 Jun 2010 16:16 Steve was thinking very hard : > On Jun 15, 3:34�pm, Karl E. Peterson <k...(a)exmvps.org> wrote: >> Steve wrote: >>>>> Can someone tell me what I am doing wrong. >>>> Well, not precisely, because I really haven't done this much. But >>>> there's a precise order you need to send the keystrokes in. I think >>>> you'll want to first send the Control down, then the A down, then the A >>>> up, then the Control up. Not sure what you're trying to do with >>>> SetKeyboardState? >> >>> As I understand it the Control keys are managed via keyboard state and >>> can not simply be sent via the send/postmessage functions. �However >>> this could be wrong as I have no personal experience with it. �I think >>> I already tried simply sending the control key with a send message but >>> I will try again and let you know how it works. >> >> Hmmm, well, that's possible. �It's not how I do with SendInput, which I >> may be confusing here with SendMessage methods. > > Well simply send the control key (via sendmessage or postmessage) did > not work. Hmmmm, I think you'll need to attach to the other thread's input queue, maybe? Something like this... http://www.codeguru.com/forum/archive/index.php/t-49901.html There's also the WM_CHAR message that might be worth a shot? -- ..NET: It's About Trust! http://vfred.mvps.org Customer Hatred Knows No Bounds at MSFT ClassicVB Users Regroup! comp.lang.basic.visual.misc Free usenet access at http://www.eternal-september.org
From: Steve on 16 Jun 2010 07:25 On Jun 15, 4:16 pm, Karl E. Peterson <k...(a)exmvps.org> wrote: > Steve was thinking very hard : > > > > > > > On Jun 15, 3:34 pm, Karl E. Peterson <k...(a)exmvps.org> wrote: > >> Steve wrote: > >>>>> Can someone tell me what I am doing wrong. > >>>> Well, not precisely, because I really haven't done this much. But > >>>> there's a precise order you need to send the keystrokes in. I think > >>>> you'll want to first send the Control down, then the A down, then the A > >>>> up, then the Control up. Not sure what you're trying to do with > >>>> SetKeyboardState? > > >>> As I understand it the Control keys are managed via keyboard state and > >>> can not simply be sent via the send/postmessage functions. However > >>> this could be wrong as I have no personal experience with it. I think > >>> I already tried simply sending the control key with a send message but > >>> I will try again and let you know how it works. > > >> Hmmm, well, that's possible. It's not how I do with SendInput, which I > >> may be confusing here with SendMessage methods. > > > Well simply send the control key (via sendmessage or postmessage) did > > not work. > > Hmmmm, I think you'll need to attach to the other thread's input queue, > maybe? Something like this... > > http://www.codeguru.com/forum/archive/index.php/t-49901.html > > There's also the WM_CHAR message that might be worth a shot? > > -- > .NET: It's About Trust! http://vfred.mvps.org > Customer Hatred Knows No Bounds at MSFT > ClassicVB Users Regroup! comp.lang.basic.visual.misc > Free usenet access athttp://www.eternal-september.org- Hide quoted text - > > - Show quoted text - Yeah I found that thread myself. Unfortunately, I do not do C, between that and what I assume are embedded html codes, I can't make heads or tails out of what the posters are saying.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: .tlb crash Next: Windows 7 Compliance: VB6 and Adhering to REstart Manager messages |