Re: keyboard event
From: David Saint (beer_at_hotmail.com)
Date: 09/15/04
- Next message: Pooja: "Re: Activate application running in system tray"
- Previous message: qiu shizhong: "Why OnComm Event for MSComm control is not triiggered after a XON handshaking signal is sent?"
- In reply to: alpine: "Re: keyboard event"
- Next in thread: alpine: "Re: keyboard event"
- Reply: alpine: "Re: keyboard event"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Sep 2004 09:05:12 +0100
"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
news:0hjek0p0jmie47v4om4j7i22r4odnt26i5@4ax.com...
> On Tue, 14 Sep 2004 18:37:40 +0100, "David Saint" <beer@hotmail.com>
> wrote:
>
> >
> >"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
> >news:ji0ek058lmv0k1j9q5jpkhvh75ahnt64al@4ax.com...
> >> On Tue, 14 Sep 2004 08:53:22 +0100, "David Saint" <beer@hotmail.com>
> >> wrote:
> >>
> >> >hello everyone
> >> >
> >> >i have had to re-post this question due to a lack
> >> >of any responce from another group.
> >> >
> >> >i really need some help with this.
> >> >this is what i am currently using in my vb6 app.
> >> >
> >> >keybd_event VK_T, 0, 0, 0
> >> >keybd_event VK_T, 0, KEYEVENTF_KEYUP, 0
> >> >
> >> >the problem is this, the user is able to unknowingly
> >> >create an error by giving the focus to another window.
> >> >
> >> >can i use something else (more reliable) to send keys to another
window
> >> >without an error being caused if my app loses focus ? i have already
> >> >tried the SetFocusAPI in a loop, but that is still not 100% effective.
> >> >
> >> >could SendMessage, SetWindowText or something like that be what
> >> >i need to use for a 100% garanteed result ?
> >> >
> >> >thanks
> >>
> >>
> >> The methods you use will depend quite a bit on the target you want to
> >> send text into. If it is a standard edit control, you will probably
> >> be better off using SetWindowText or sending a WM_SETTEXT message. Of
> >> course, you will need the hWnd of the target window in order to use
> >> either of these but getting that usually isn't too much of a problem
> >> using some combination of the FindWindow, FindWindowEx and/or
> >> EnumChildWindows API functions.
> >>
> >> HTH,
> >> Bryan
> >> ____________________________________________________________
> >> New Vision Software "When the going gets weird,"
> >> Bryan Stafford "the weird turn pro."
> >> alpine_don'tsendspam@mvps.org Hunter S. Thompson -
> >> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
> >
> >Bryan
> >i'm aready able to find the window's hWnd through
> >
> >Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA"
> >(ByVal lpClassName As _
> >Any, ByVal lpWindowName As Any) As Long
> >...
> >dwnd = FindWindow(vbNullString, "WindowName")
> >...
> >i didn't realise this was going to be the tricky part.
> >
> >thanks Bryan
>
>
> Use the Spy++ application that comes with VS to find the class name of
> the actual target control (from your description I assume it is an
> edit control residing on the parent window). Once you know the window
> hierarchy, you can walk it to get to the hWnd of the target window.
>
> HTH,
> Bryan
> ____________________________________________________________
> New Vision Software "When the going gets weird,"
> Bryan Stafford "the weird turn pro."
> alpine_don'tsendspam@mvps.org Hunter S. Thompson -
> Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
ok thanks Bryan
i use a tool from PSC i think it's called advanced windows API
it acts like visual studio's spy tool but you can do even more with this one
plus, all the code for it is freely available.
how could i maintain the focus on the window control
once i found it ? at the moment in testing, if i click anywhere
while the operation is running the keys are not sent to the correct
destination control.
what about something like this
hWnd = FindWindow(vbNullString, sWinTxt)
If hWnd = 0 Then
Exit Sub
Else
For x = 1 To 5000
r = SetFocusAPI(hWnd)
...
' SetWindowText or WM_SETTEXT code here
...
Next
End If
this does work in a fashion, but it seems stall until the loop is complete
then it deals with text ?
thanks for the help Bryan
- Next message: Pooja: "Re: Activate application running in system tray"
- Previous message: qiu shizhong: "Why OnComm Event for MSComm control is not triiggered after a XON handshaking signal is sent?"
- In reply to: alpine: "Re: keyboard event"
- Next in thread: alpine: "Re: keyboard event"
- Reply: alpine: "Re: keyboard event"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|