|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Generic SendInput samples?>>>> 432 Days, 20 Hours, 13 Minutes, and 15 Seconds Understatement of the millenium, there! :-)>>> >>> This is new... what are you counting down (or up)? >> >> ?now + 432 + 20/24 <bg> >> -- >> 432 Days, 19 Hours, 55 Minutes, and 52 Seconds > > Ah yes... **that** date. Can't wait (and its still too far off)! Hey, I'm cobbling together a little utility here, and thought I'd use it as an excuse to come up to speed with SendInput. What I can't really seem to find are any intelligible samples out there for this function. Am I missing something really obvious, or did this one just pass the ClassicVB crowd by? Thanks... Karl -- 432 Days, 19 Hours, 36 Minutes, and 23 Seconds Karl E. Peterson wrote:
> Hey, I'm cobbling together a little utility here, and thought I'd use it as an Nice enhancement, Bob! Wanted to get that here, up front.> excuse to come up to speed with SendInput. What I can't really seem to find are > any intelligible samples out there for this function. Am I missing something > really obvious, or did this one just pass the ClassicVB crowd by? I've been twiddling away, as well. This is what I've got, indented to highlight wordwrap: ' ================================= BOF: MSendInput.bas ================================= Option Explicit Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As Any, ByVal cbSize As Long) As Long Public Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal cChar As Byte) As Integer Private Type KeyboardInput ' typedef struct tagINPUT { dwType As Long ' DWORD type; wVK As Integer ' union {MOUSEINPUT mi; wScan As Integer ' KEYBDINPUT ki; dwFlags As Long ' HARDWAREINPUT hi; dwTime As Long ' }; dwExtraInfo As Long ' }INPUT, *PINPUT; dwPadding As Currency ' 8 extra bytes, because mouses take more. End Type Private Const INPUT_MOUSE As Long = 0 Private Const INPUT_KEYBOARD As Long = 1 Private Const KEYEVENTF_KEYUP As Long = 2 Private m_Data As String Private m_DatPtr As Long Private m_Events() As KeyboardInput Private m_EvtPtr As Long Private m_NamedKeys As Collection Private m_ShiftFlags As Long Private Const defBufferSize As Long = 1024 Public Sub MySendKeys(Data As String) Dim i As Long ' Make sure our collection of named keys has been built. If m_NamedKeys Is Nothing Then Call BuildNamedKeys End If ' Clear buffer, reset pointers, and cache send data. ReDim m_Events(0 To defBufferSize - 1) As KeyboardInput m_EvtPtr = 0 m_DatPtr = 0 m_Data = Data ' Loop through entire passed string. Do While m_DatPtr < Len(Data) ' Process next token in data string. Call DoNext ' Make sure there's still plenty of room in the buffer. If m_EvtPtr >= (UBound(m_Events) - 24) Then ReDim Preserve m_Events(0 To (UBound(m_Events) + defBufferSize) - 1) End If Loop ' Send the processed string to the foreground window! If m_EvtPtr > 0 Then ' All events are keyboard based. For i = 0 To m_EvtPtr - 1 m_Events(i).dwType = INPUT_KEYBOARD Next i ' m_EvtPtr is 0-based, but nInputs is 1-based. Debug.Print SendInput(m_EvtPtr, m_Events(0), Len(m_Events(0))), Debug.Print Err.LastDllError End If End Sub Private Sub DoNext() Dim this As String ' Advance data pointer, and extract next char. m_DatPtr = m_DatPtr + 1 this = Mid$(m_Data, m_DatPtr, 1) ' Branch to appropriate helper routine. If InStr("+^%", this) Then Call ProcessShift(this) ElseIf this = "(" Then Call ProcessGroup ElseIf this = "{" Then Call ProcessNamedKey Else Call ProcessChar(this) End If End Sub Private Sub ProcessChar(this As String) Dim vk As Integer Dim capped As Boolean ' Add input events for single character, taking capitalization ' into account. HiByte will contain the shift state, and LoByte ' will contain the key code. vk = VkKeyScan(Asc(this)) capped = CBool(ByteHi(vk) And 1) vk = ByteLo(vk) Call StuffBuffer(vk, capped) End Sub Private Sub ProcessGroup() Dim EndPtr As Long Dim this As String Dim i As Long ' Groups of characters are offered together, surrounded by parenthesis, ' in order to all be modified by shift key(s). We need to dig out the ' remainder of the group, and process each in turn. EndPtr = InStr(m_DatPtr, m_Data, ")") ' No need to do anything if endgroup immediateyl follows beginning. If EndPtr > (m_DatPtr + 1) Then For i = 1 To (EndPtr - m_DatPtr - 1) this = Mid$(m_Data, m_DatPtr + i, 1) Call ProcessChar(this) Next i ' Advance data pointer to closing parenthesis. m_DatPtr = EndPtr End If End Sub Private Sub ProcessNamedKey() Dim EndPtr As Long Dim this As String Dim pieces() As String Dim repeat As Long Dim vk As Integer Dim capped As Boolean Dim i As Long ' Groups of characters are offered together, surrounded by braces, ' representing a named keystroke. We need to dig out the actual ' name, and optionally the number of times this keystroke is repeated. EndPtr = InStr(m_DatPtr, m_Data, "}") ' No need to do anything if endgroup immediately follows beginning. If EndPtr > (m_DatPtr + 1) Then ' Extract group of characters. this = Mid$(m_Data, m_DatPtr + 1, EndPtr - m_DatPtr - 1) ' Break into pieces, if possible. pieces = Split(this, " ") ' Second element, if avail, is number of times to repeat stroke. If UBound(pieces) > 0 Then repeat = Val(pieces(1)) If repeat < 1 Then repeat = 1 ' Attempt to retrieve named keycode, or else retrieve standard code. vk = GetNamedKey(pieces(0)) If vk = 0 Then vk = VkKeyScan(Asc(this)) capped = CBool(ByteHi(vk) And 1) vk = ByteLo(vk) End If ' Stuff buffer as many times as required. For i = 1 To repeat Call StuffBuffer(vk, capped) Next i ' Advance data pointer to closing parenthesis. m_DatPtr = EndPtr End If End Sub Private Sub ProcessShift(shiftkey As String) ' Press appropriate shiftkey. With m_Events(m_EvtPtr) Select Case shiftkey Case "+" .wVK = vbKeyShift m_ShiftFlags = m_ShiftFlags Or vbShiftMask Case "^" .wVK = vbKeyControl m_ShiftFlags = m_ShiftFlags Or vbCtrlMask Case "%" .wVK = vbKeyMenu m_ShiftFlags = m_ShiftFlags Or vbAltMask End Select End With m_EvtPtr = m_EvtPtr + 1 ' Process next set of data Call DoNext ' Unpress same shiftkey. With m_Events(m_EvtPtr) Select Case shiftkey Case "+" .wVK = vbKeyShift m_ShiftFlags = m_ShiftFlags And Not vbShiftMask Case "^" .wVK = vbKeyControl m_ShiftFlags = m_ShiftFlags And Not vbCtrlMask Case "%" .wVK = vbKeyMenu m_ShiftFlags = m_ShiftFlags And Not vbAltMask End Select .dwFlags = KEYEVENTF_KEYUP End With m_EvtPtr = m_EvtPtr + 1 End Sub Private Sub StuffBuffer(ByVal vk As Integer, Shifted As Boolean) ' Only mess with Shift key if not already pressed. If CBool(m_ShiftFlags And vbShiftMask) = False Then If Shifted Then With m_Events(m_EvtPtr) .wVK = vbKeyShift End With m_EvtPtr = m_EvtPtr + 1 End If End If ' Press and release this key. With m_Events(m_EvtPtr) .wVK = vk End With m_EvtPtr = m_EvtPtr + 1 With m_Events(m_EvtPtr) .wVK = vk .dwFlags = KEYEVENTF_KEYUP End With m_EvtPtr = m_EvtPtr + 1 ' Only mess with Shift key if not already pressed. If CBool(m_ShiftFlags And vbShiftMask) = False Then If Shifted Then With m_Events(m_EvtPtr) .wVK = vbKeyShift .dwFlags = KEYEVENTF_KEYUP End With m_EvtPtr = m_EvtPtr + 1 End If End If End Sub Private Function ByteHi(ByVal WordIn As Integer) As Byte ' Lop off low byte with divide. If less than ' zero, then account for sign bit (adding &h10000 ' implicitly converts to Long before divide). If WordIn < 0 Then ByteHi = (WordIn + &H10000) \ &H100 Else ByteHi = WordIn \ &H100 End If End Function Private Function ByteLo(ByVal WordIn As Integer) As Byte ' Mask off high byte and return low. ByteLo = WordIn And &HFF End Function Private Function GetNamedKey(this As String) As Integer Dim nRet As Integer ' Try retrieving from collection On Error Resume Next GetNamedKey = m_NamedKeys(UCase$(this)) On Error Resume Next End Function Private Sub BuildNamedKeys() ' Build collection containing all known named keys. Set m_NamedKeys = New Collection With m_NamedKeys .Add vbKeyBack, "BACKSPACE" .Add vbKeyBack, "BS" .Add vbKeyBack, "BKSP" .Add vbKeyPause, "BREAK" .Add vbKeyCapital, "CAPSLOCK" .Add vbKeyDelete, "DELETE" .Add vbKeyDelete, "DEL" .Add vbKeyDown, "DOWN" .Add vbKeyEnd, "END" .Add vbKeyReturn, "ENTER" .Add vbKeyReturn, "~" .Add vbKeyEscape, "ESC" .Add vbKeyHelp, "HELP" .Add vbKeyHome, "HOME" .Add vbKeyInsert, "INS" .Add vbKeyInsert, "INSERT" .Add vbKeyLeft, "LEFT" .Add vbKeyNumlock, "NUMLOCK" .Add vbKeyPageDown, "PGDN" .Add vbKeyPageUp, "PGUP" .Add vbKeyPrint, "PRTSC" .Add vbKeyRight, "RIGHT" .Add vbKeyScrollLock, "SCROLLLOCK" .Add vbKeyTab, "TAB" .Add vbKeyUp, "UP" .Add vbKeyF1, "F1" .Add vbKeyF2, "F2" .Add vbKeyF3, "F3" .Add vbKeyF4, "F4" .Add vbKeyF5, "F5" .Add vbKeyF6, "F6" .Add vbKeyF7, "F7" .Add vbKeyF8, "F8" .Add vbKeyF9, "F9" .Add vbKeyF10, "F10" .Add vbKeyF11, "F11" .Add vbKeyF12, "F12" .Add vbKeyF13, "F13" .Add vbKeyF14, "F14" .Add vbKeyF15, "F15" .Add vbKeyF16, "F16" End With End Sub ' ================================= EOF: MSendInput.bas ================================= Seems to work *exactly* like SendKeys, but it has a fatal flaw. I can't seem to highlight for some reason? The shiftkeys are simply not working with the named keys. For example, try this: Private Sub Command1_Click() Text1.SetFocus DoEvents Call MySendKeys("{home}+{end}") End Sub Oughta highlight the entire textbox, right? Not doing it. Conversely, this works: Call MySendKeys("{end}+{j 4}") Stuffs "JJJJ" at the end of the textbox. This, and walking the code, both show the Shiftkey is absolutely down through that entire {} group. Anyone see the flaw? Thanks... Karl
Show quote
"Karl E. Peterson" <k***@mvps.org> wrote in message <cut>news:uVHqCLzJIHA.4272@TK2MSFTNGP05.phx.gbl... > Karl E. Peterson wrote: >> Hey, I'm cobbling together a little utility here, and thought I'd use it >> as an >> excuse to come up to speed with SendInput. What I can't really seem to >> find are >> any intelligible samples out there for this function. Am I missing >> something >> really obvious, or did this one just pass the ClassicVB crowd by? > > Nice enhancement, Bob! Wanted to get that here, up front. > > I've been twiddling away, as well. This is what I've got, indented to > highlight wordwrap: > Seems to work *exactly* like SendKeys, but it has a fatal flaw. I can't I tried it and can't get it to fail (using Vista). It highlight perfectly.> seem to highlight for some reason? The shiftkeys are simply not working > with the named keys. For example, try this: > > Private Sub Command1_Click() > Text1.SetFocus > DoEvents > Call MySendKeys("{home}+{end}") > End Sub
Show quote
"Bob Butler" <noway@nospam.ever> wrote in message I added some debugging lines to dump the events and then report the news:uCcGyk5JIHA.1188@TK2MSFTNGP04.phx.gbl... > "Karl E. Peterson" <k***@mvps.org> wrote in message > news:uVHqCLzJIHA.4272@TK2MSFTNGP05.phx.gbl... >> Karl E. Peterson wrote: >>> Hey, I'm cobbling together a little utility here, and thought I'd use it >>> as an >>> excuse to come up to speed with SendInput. What I can't really seem to >>> find are >>> any intelligible samples out there for this function. Am I missing >>> something >>> really obvious, or did this one just pass the ClassicVB crowd by? >> >> Nice enhancement, Bob! Wanted to get that here, up front. >> >> I've been twiddling away, as well. This is what I've got, indented to >> highlight wordwrap: > <cut> >> Seems to work *exactly* like SendKeys, but it has a fatal flaw. I can't >> seem to highlight for some reason? The shiftkeys are simply not working >> with the named keys. For example, try this: >> >> Private Sub Command1_Click() >> Text1.SetFocus >> DoEvents >> Call MySendKeys("{home}+{end}") >> End Sub > > I tried it and can't get it to fail (using Vista). It highlight > perfectly. text1_keydown and text1_keyup events. Under Vista I get this: MySendKeys "{home}+{end}" 0:1 36 0 1:1 36 2 2:1 16 0 3:1 35 0 4:1 35 2 5:1 16 2 6 6 0 keydown 36 0 keyup 36 0 keydown 16 1 keydown 35 1 keyup 35 1 keyup 16 0 That shows the 6 keyboard events, the call to SendInput, then the textbox events and it's all exactly what it should be and the text is highlighted. When I run it under Win2K I get this: MySendKeys "{home}+{end}" 0:1 36 0 1:1 36 2 2:1 16 0 3:1 35 0 4:1 35 2 5:1 16 2 6 6 0 keydown 36 0 keyup 36 0 keydown 16 1 keyup 16 0 keydown 35 0 keyup 35 0 keydown 16 1 keyup 16 0 The buffer and SendInput look fine but the textbox receives 2 extra keystrokes making the shift key not stick for the END key. Interestingly, if I do just SendKeys it sends the correct keystrokes followed by keydown 144 0 keyup 144 0 keydown 144 0 keyup 144 0 Bob Butler wrote:
>> I tried it and can't get it to fail (using Vista). It highlight Argh!>> perfectly. Show quote > I added some debugging lines to dump the events and then report the Too damn weird!!! I'm getting something similar (XP/SP2), now that I look at that:> text1_keydown and text1_keyup events. Under Vista I get this: > > MySendKeys "{home}+{end}" > 0:1 36 0 > 1:1 36 2 > 2:1 16 0 > 3:1 35 0 > 4:1 35 2 > 5:1 16 2 > 6 6 0 > keydown 36 0 > keyup 36 0 > keydown 16 1 > keydown 35 1 > keyup 35 1 > keyup 16 0 > > That shows the 6 keyboard events, the call to SendInput, then the textbox > events and it's all exactly what it should be and the text is highlighted. > > When I run it under Win2K I get this: > > MySendKeys "{home}+{end}" > 0:1 36 0 > 1:1 36 2 > 2:1 16 0 > 3:1 35 0 > 4:1 35 2 > 5:1 16 2 > 6 6 0 > keydown 36 0 > keyup 36 0 > keydown 16 1 > keyup 16 0 > keydown 35 0 > keyup 35 0 > keydown 16 1 > keyup 16 0 > > The buffer and SendInput look fine but the textbox receives 2 extra > keystrokes making the shift key not stick for the END key. > > Interestingly, if I do just SendKeys it sends the correct keystrokes > followed by > keydown 144 0 > keyup 144 0 > keydown 144 0 > keyup 144 0 36 0 36 2 16 0 35 0 35 2 16 2 Text1_KeyDown(36, 0) {Home} Text1_KeyUp(36, 0) Text1_KeyDown(16, 1) {Shift} Text1_KeyUp(16, 0) Text1_KeyDown(35, 0) {End} Text1_KeyUp(35, 0) Text1_KeyDown(16, 1) {Shift} Text1_KeyUp(16, 0) That makes no dang sense. And this is what I see (same thing) in Spy++, with a compiled EXE: <00017> 001B084E P WM_KEYDOWN nVirtKey:VK_HOME cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 <00018> 001B084E P WM_KEYUP nVirtKey:VK_HOME cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1 <00019> 001B084E P WM_KEYDOWN nVirtKey:VK_SHIFT cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 <00020> 001B084E P WM_KEYUP nVirtKey:VK_SHIFT cRepeat:1 ScanCode:2A fExtended:0 fAltDown:0 fRepeat:1 fUp:1 <00021> 001B084E P WM_KEYDOWN nVirtKey:VK_END cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 <00022> 001B084E P WM_KEYUP nVirtKey:VK_END cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1 <00023> 001B084E P WM_KEYDOWN nVirtKey:VK_SHIFT cRepeat:1 ScanCode:2A fExtended:0 fAltDown:0 fRepeat:0 fUp:0 <00024> 001B084E P WM_KEYUP nVirtKey:VK_SHIFT cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1 If I use VBA.SendKeys, I get this: Text1_KeyDown(36, 0) Text1_KeyUp(36, 0) Text1_KeyDown(16, 1) Text1_KeyDown(35, 1) Text1_KeyUp(35, 1) Text1_KeyUp(16, 0) Text1_KeyDown(144, 0) Text1_KeyUp(144, 0) Text1_KeyDown(144, 0) Text1_KeyUp(144, 0) What the heck's keycode 144? Thanks much... Karl "Karl E. Peterson" <k***@mvps.org> wrote in message That about sums it up. I tried sending the OEMScanCode instead and tried news:egYLZ%236JIHA.4228@TK2MSFTNGP02.phx.gbl... > Bob Butler wrote: >>> I tried it and can't get it to fail (using Vista). It highlight >>> perfectly. > > Argh! using keybd_event directly. In all cases under earlier OS versions an extra shift-down or shift-up is inserted somewhere along the line whenever a keycode like END is adjacent to it. I can send "+(abc)" just fine and get "[SHIFT]ABC[shift]" but "+{END}" always gives me 6 events instead of 4. Is SendKeys using SendMessage or PostMessage? I've searched and found several references to the problem with keybd_event but no responses and no acknowledgment that it is a bug. Under Vista it works as I'd expect so something got fixed. I don't know how SendKeys is getting around it. > Haven't tracked that one down yet, not that I've spent a lot of time > What the heck's keycode 144? looking. Bob Butler wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote ... But wait! There's more! :-(>> Bob Butler wrote: >>>> I tried it and can't get it to fail (using Vista). It highlight >>>> perfectly. >> >> Argh! > > That about sums it up. I fired up VMs of Vista and W2K. My sample worked just fine in W2K and behaved in Vista just as it did on my base XP system. WTF? I stuck the code and EXE that I'm using here: http://vb.mvps.org/samples/code/SendInput.zip in case anyone would like to try it? > I tried sending the OEMScanCode instead and tried <grumble> Yep.> using keybd_event directly. In all cases under earlier OS versions an extra > shift-down or shift-up is inserted somewhere along the line whenever a > keycode like END is adjacent to it. I can send "+(abc)" just fine and get > "[SHIFT]ABC[shift]" but "+{END}" always gives me 6 events instead of 4. > Is SendKeys using SendMessage or PostMessage? Appears to be PostMessage.> I've searched and found Well, not necessarily. It's definitely not working for me, under Vista. Fwiw, > several references to the problem with keybd_event but no responses and no > acknowledgment that it is a bug. Under Vista it works as I'd expect so > something got fixed. I don't know how SendKeys is getting around it. here's the matrix that I'm seeing, when I pass "{home}+{end}" to SendInput and SendKeys in various OSes: SendInput SendKeys Vista NO NO XP/SP2 NO YES 2000 YES YES :-( Weird, huh?>> What the heck's keycode 144? > > Haven't tracked that one down yet, not that I've spent a lot of time > looking. The exe works perfectly on my XP system at work.
Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:e8lTzf7JIHA.2064@TK2MSFTNGP06.phx.gbl... > Bob Butler wrote: >> "Karl E. Peterson" <k***@mvps.org> wrote ... >>> Bob Butler wrote: >>>>> I tried it and can't get it to fail (using Vista). It highlight >>>>> perfectly. >>> >>> Argh! >> >> That about sums it up. > > But wait! There's more! :-( > > I fired up VMs of Vista and W2K. My sample worked just fine in W2K and > behaved in Vista just as it did on my base XP system. WTF? > > I stuck the code and EXE that I'm using here: > > http://vb.mvps.org/samples/code/SendInput.zip > > in case anyone would like to try it? > >> I tried sending the OEMScanCode instead and tried >> using keybd_event directly. In all cases under earlier OS versions an >> extra >> shift-down or shift-up is inserted somewhere along the line whenever a >> keycode like END is adjacent to it. I can send "+(abc)" just fine and >> get >> "[SHIFT]ABC[shift]" but "+{END}" always gives me 6 events instead of 4. > > <grumble> Yep. > >> Is SendKeys using SendMessage or PostMessage? > > Appears to be PostMessage. > >> I've searched and found >> several references to the problem with keybd_event but no responses and >> no >> acknowledgment that it is a bug. Under Vista it works as I'd expect so >> something got fixed. I don't know how SendKeys is getting around it. > > Well, not necessarily. It's definitely not working for me, under Vista. > Fwiw, here's the matrix that I'm seeing, when I pass "{home}+{end}" to > SendInput and SendKeys in various OSes: > > SendInput SendKeys > Vista NO NO > XP/SP2 NO YES > 2000 YES YES > > :-( > >>> What the heck's keycode 144? >> >> Haven't tracked that one down yet, not that I've spent a lot of time >> looking. > > Weird, huh? > -- > .NET: It's About Trust! > http://vfred.mvps.org > Randy Birch wrote:
> The exe works perfectly on my XP system at work. GRRRRRRRRR!!! SP1 or SP2? (My money's on the former.)Thanks! SP2. I take my cappuccino with chocolate, please.
Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:ulgkjl7JIHA.3848@TK2MSFTNGP05.phx.gbl... > Randy Birch wrote: >> The exe works perfectly on my XP system at work. > > GRRRRRRRRR!!! SP1 or SP2? (My money's on the former.) > > Thanks! > -- > .NET: It's About Trust! > http://vfred.mvps.org > Randy Birch wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote ... Not the healthiest choice, but I can respect that. <G>>> Randy Birch wrote: >>> The exe works perfectly on my XP system at work. >> >> GRRRRRRRRR!!! SP1 or SP2? (My money's on the former.) > > SP2. I take my cappuccino with chocolate, please. Okay, that's just friggin' weird. Time for me to reboot? What would cause it to work on one system, but not another? Fwiw, I just tried it on the mvps server (2003/SP1), and it's not working there either, though standard SendKeys is. I can try the sample code on my vista and XP no-SP vm's tonight. FWIW.
Can't run the code here on XP 'cause they don't trust me around development tools. <g> Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:eK94Tz7JIHA.4808@TK2MSFTNGP05.phx.gbl... > Randy Birch wrote: >> "Karl E. Peterson" <k***@mvps.org> wrote ... >>> Randy Birch wrote: >>>> The exe works perfectly on my XP system at work. >>> >>> GRRRRRRRRR!!! SP1 or SP2? (My money's on the former.) >> >> SP2. I take my cappuccino with chocolate, please. > > Not the healthiest choice, but I can respect that. <G> > > Okay, that's just friggin' weird. Time for me to reboot? What would > cause it to work on one system, but not another? > > Fwiw, I just tried it on the mvps server (2003/SP1), and it's not working > there either, though standard SendKeys is. > -- > .NET: It's About Trust! > http://vfred.mvps.org > Randy Birch wrote:
> I can try the sample code on my vista and XP no-SP vm's tonight. FWIW. LOL!> Can't run the code here on XP 'cause they don't trust me around development > tools. <g> Karl E. Peterson wrote:
> Hey, I'm cobbling together a little utility here, and thought I'd use it as an Solved the problem of the shifted-cursor keys! Free clue found here:> excuse to come up to speed with SendInput. What I can't really seem to find are > any intelligible samples out there for this function. Am I missing something > really obvious, or did this one just pass the ClassicVB crowd by? http://www.xtremevbtalk.com/archive/index.php/t-203863.html D'oh!!! Seemingly fully-functional sample now available here: http://vb.mvps.org/samples/code/SendInput.zip Hope to have a description ready soon, and would prefer future links point, here: http://vb.mvps.org/samples/SendInput Thanks... Karl
Show quote
"Karl E. Peterson" <k***@mvps.org> wrote in message Yep, adding the extendedkey flag fixed it on my win2k box and left vista news:eqbTX58JIHA.4712@TK2MSFTNGP04.phx.gbl... > Karl E. Peterson wrote: >> Hey, I'm cobbling together a little utility here, and thought I'd use it >> as an >> excuse to come up to speed with SendInput. What I can't really seem to >> find are >> any intelligible samples out there for this function. Am I missing >> something >> really obvious, or did this one just pass the ClassicVB crowd by? > > Solved the problem of the shifted-cursor keys! Free clue found here: > > http://www.xtremevbtalk.com/archive/index.php/t-203863.html untouched I wonder if a WaitForInputIdle call would be a reasonable "Wait" equivalent... Hi Karl ...
Results of test at home: ------------------------------ EXE - Vista SP0 ------------------------------ Code: {home}+{end} SendInput: NO (no text selected) SendKeys: NO (and no UAC error) Code: {home}+{end}Testing123+(123) SendInput: YES ("Testing123!@#" sent to tbox) SendKeys: YES ------------------------------ EXE - XP SP2 ------------------------------ Code: {home}+{end} SendInput YES (text selected) SendKeys YES Code: {home}+{end}Testing123+(123) SendInput: YES ("Testing123!@#" sent to tbox) SendKeys: YES ----------------------------------------------------------------------------------------------- ---------------------------------- IDE - Vista SP0 ---------------------------------- Code: {home}+{end} SendInput: YES (text selected) SendKeys NO (permission error) Code: {home}+{end}Testing123+(123) SendInput: YES ("Testing123!@#" was sent to tbox) SendKeys: NO Code: qwerty{home}+{end} SendInput: YES (printed text and selected) SendKeys: NO ---------------------------------- IDE - XP SP2 ---------------------------------- Code: {home}+{end} SendInput: YES (text selected) SendKeys: YES Code: {home}+{end}Testing123+(123) SendInput: YES ("Testing123!@#" was sent to tbox) SendKeys: YES Code: qwerty{home}+{end} SendInput: YES (printed text and selected) SendKeys: YES "Karl E. Peterson" <k***@mvps.org> wrote in message Randy Birch wrote:news:uHxveO8JIHA.4712@TK2MSFTNGP04.phx.gbl... > I can try the sample code on my vista and XP no-SP vm's tonight. FWIW. LOL!> Can't run the code here on XP 'cause they don't trust me around > development > tools. <g> Bob Butler wrote:
Show quote > "Karl E. Peterson" <k***@mvps.org> wrote in message Very cool. :-)> news:eqbTX58JIHA.4712@TK2MSFTNGP04.phx.gbl... >> Karl E. Peterson wrote: >>> Hey, I'm cobbling together a little utility here, and thought I'd use it as an >>> excuse to come up to speed with SendInput. What I can't really seem to find are >>> any intelligible samples out there for this function. Am I missing something >>> really obvious, or did this one just pass the ClassicVB crowd by? >> >> Solved the problem of the shifted-cursor keys! Free clue found here: >> >> http://www.xtremevbtalk.com/archive/index.php/t-203863.html > > Yep, adding the extendedkey flag fixed it on my win2k box and left vista > untouched > I wonder if a WaitForInputIdle call would be a reasonable "Wait" Well, I'd think not, for a handful of reasons. Mainly, it requires a process > equivalent... handle, and SendKeys really shouldn't care about that. But it's also been there since VB1, and there wasn't such a call in Win16, was there? Also, I've seen no detectable difference in behavior, using that parameter, in well over 10-15 years now. I actually wonder if it does go back to a very early implementation, that maybe it was the difference between SendMessage and PostMessage? But that later on, they began using more complicated (delicate) methods like journal hooks, and whatnot, and now it's just a worthless appendage? Sure wish I had the skill to read ASM dumps from VB! Oughta be somewhat clear, from one of those, huh? Randy Birch wrote:
> Hi Karl ... Gotta ask, did you try the new code that uses the KEYEVENTF_EXTENDEDKEY for cursor > > Results of test at home: keys? Given the inconsistent results, I hope not. <g> http://vb.mvps.org/samples/SendInput Thanks... Karl Show quote > ------------------------------ > EXE - Vista SP0 > ------------------------------ > Code: {home}+{end} > SendInput: NO (no text selected) > SendKeys: NO (and no UAC error) > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" sent to tbox) > SendKeys: YES > > ------------------------------ > EXE - XP SP2 > ------------------------------ > Code: {home}+{end} > SendInput YES (text selected) > SendKeys YES > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" sent to tbox) > SendKeys: YES > ----------------------------------------------------------------------------------------------- > ---------------------------------- > IDE - Vista SP0 > ---------------------------------- > Code: {home}+{end} > SendInput: YES (text selected) > SendKeys NO (permission error) > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" was sent to tbox) > SendKeys: NO > > Code: qwerty{home}+{end} > SendInput: YES (printed text and selected) > SendKeys: NO > > ---------------------------------- > IDE - XP SP2 > ---------------------------------- > Code: {home}+{end} > SendInput: YES (text selected) > SendKeys: YES > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" was sent to tbox) > SendKeys: YES > > Code: qwerty{home}+{end} > SendInput: YES (printed text and selected) > SendKeys: YES > > -- > > > Randy Birch > http://vbnet.mvps.org/ > > Please respond to the newsgroups so all can benefit. > > > "Karl E. Peterson" <k***@mvps.org> wrote in message > news:uHxveO8JIHA.4712@TK2MSFTNGP04.phx.gbl... > Randy Birch wrote: >> I can try the sample code on my vista and XP no-SP vm's tonight. FWIW. >> Can't run the code here on XP 'cause they don't trust me around >> development >> tools. <g> > > LOL! Might have been - whatever you had on the site 15 minutes before I posted.
I didn't keep a copy of the code from earlier this afternoon. "Karl E. Peterson" <k***@mvps.org> wrote in message Randy Birch wrote:news:OglTT69JIHA.5468@TK2MSFTNGP05.phx.gbl... > Hi Karl ... Gotta ask, did you try the new code that uses the KEYEVENTF_EXTENDEDKEY for > > Results of test at home: cursor keys? Given the inconsistent results, I hope not. <g> http://vb.mvps.org/samples/SendInput Thanks... Karl Show quote > ------------------------------ > EXE - Vista SP0 > ------------------------------ > Code: {home}+{end} > SendInput: NO (no text selected) > SendKeys: NO (and no UAC error) > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" sent to tbox) > SendKeys: YES > > ------------------------------ > EXE - XP SP2 > ------------------------------ > Code: {home}+{end} > SendInput YES (text selected) > SendKeys YES > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" sent to tbox) > SendKeys: YES > ----------------------------------------------------------------------------------------------- > ---------------------------------- > IDE - Vista SP0 > ---------------------------------- > Code: {home}+{end} > SendInput: YES (text selected) > SendKeys NO (permission error) > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" was sent to tbox) > SendKeys: NO > > Code: qwerty{home}+{end} > SendInput: YES (printed text and selected) > SendKeys: NO > > ---------------------------------- > IDE - XP SP2 > ---------------------------------- > Code: {home}+{end} > SendInput: YES (text selected) > SendKeys: YES > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" was sent to tbox) > SendKeys: YES > > Code: qwerty{home}+{end} > SendInput: YES (printed text and selected) > SendKeys: YES > > -- > > > Randy Birch > http://vbnet.mvps.org/ > > Please respond to the newsgroups so all can benefit. > > > "Karl E. Peterson" <k***@mvps.org> wrote in message > news:uHxveO8JIHA.4712@TK2MSFTNGP04.phx.gbl... > Randy Birch wrote: >> I can try the sample code on my vista and XP no-SP vm's tonight. FWIW. >> Can't run the code here on XP 'cause they don't trust me around >> development >> tools. <g> > > LOL! I did mean to mention that the EXE and IDE method that worked on Vista
filled the tb like molasses. Could pretty well see each letter being added to the sentence. "Karl E. Peterson" <k***@mvps.org> wrote in message Randy Birch wrote:news:OglTT69JIHA.5468@TK2MSFTNGP05.phx.gbl... > Hi Karl ... Gotta ask, did you try the new code that uses the KEYEVENTF_EXTENDEDKEY for > > Results of test at home: cursor keys? Given the inconsistent results, I hope not. <g> http://vb.mvps.org/samples/SendInput Thanks... Karl Show quote > ------------------------------ > EXE - Vista SP0 > ------------------------------ > Code: {home}+{end} > SendInput: NO (no text selected) > SendKeys: NO (and no UAC error) > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" sent to tbox) > SendKeys: YES > > ------------------------------ > EXE - XP SP2 > ------------------------------ > Code: {home}+{end} > SendInput YES (text selected) > SendKeys YES > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" sent to tbox) > SendKeys: YES > ----------------------------------------------------------------------------------------------- > ---------------------------------- > IDE - Vista SP0 > ---------------------------------- > Code: {home}+{end} > SendInput: YES (text selected) > SendKeys NO (permission error) > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" was sent to tbox) > SendKeys: NO > > Code: qwerty{home}+{end} > SendInput: YES (printed text and selected) > SendKeys: NO > > ---------------------------------- > IDE - XP SP2 > ---------------------------------- > Code: {home}+{end} > SendInput: YES (text selected) > SendKeys: YES > > Code: {home}+{end}Testing123+(123) > SendInput: YES ("Testing123!@#" was sent to tbox) > SendKeys: YES > > Code: qwerty{home}+{end} > SendInput: YES (printed text and selected) > SendKeys: YES > > -- > > > Randy Birch > http://vbnet.mvps.org/ > > Please respond to the newsgroups so all can benefit. > > > "Karl E. Peterson" <k***@mvps.org> wrote in message > news:uHxveO8JIHA.4712@TK2MSFTNGP04.phx.gbl... > Randy Birch wrote: >> I can try the sample code on my vista and XP no-SP vm's tonight. FWIW. >> Can't run the code here on XP 'cause they don't trust me around >> development >> tools. <g> > > LOL! Randy Birch wrote:
> I did mean to mention that the EXE and IDE method that worked on Vista Damm! Another anomalous result! You still running Vista on a Mac? <gd&rvvf>> filled the tb like molasses. Could pretty well see each letter being added > to the sentence. Yes - for now - but to Vista and XP it looks like its own box.
"Karl E. Peterson" <k***@mvps.org> wrote in message Randy Birch wrote:news:eC13mn%23JIHA.5684@TK2MSFTNGP06.phx.gbl... > I did mean to mention that the EXE and IDE method that worked on Vista Damm! Another anomalous result! You still running Vista on a Mac? > filled the tb like molasses. Could pretty well see each letter being > added > to the sentence. <gd&rvvf> Randy Birch wrote:
> Might have been - whatever you had on the site 15 minutes before I posted. Hmmmmm... I'm gonna have to assume you're nothing but an anomoly, then, *Larry*... > I didn't keep a copy of the code from earlier this afternoon. <gd&r> Thanks... On Thu, 15 Nov 2007 18:37:41 -0500, "Randy Birch"
<rgb_removet***@mvps.org> wrote: in <up7RFC#JIHA.5***@TK2MSFTNGP02.phx.gbl> >I did mean to mention that the EXE and IDE method that worked on Vista Do you by any chance use a KVM switch to move from computer to computer?>filled the tb like molasses. Could pretty well see each letter being added >to the sentence. I do and whenever I switch to a W2K box and then back to XP Pro the keyboard repeat rate gets snockered. I have to go into Control Panel|Keyboard and drag the Repeat Rate slider from Fast to Slow and then back to Fast again in order to get it back where I like it - real fast. --- Stefan Berglund No, but I am using Vista and XP in virtual machines on an iMac, at least
until by blackbird arrives next month. Show quote "Stefan Berglund" <sorry.no.kool***@for.me> wrote in message news:nvspj31fbn6timda96hu3035833g7upcfk@4ax.com... > On Thu, 15 Nov 2007 18:37:41 -0500, "Randy Birch" > <rgb_removet***@mvps.org> wrote: > in <up7RFC#JIHA.5***@TK2MSFTNGP02.phx.gbl> > >>I did mean to mention that the EXE and IDE method that worked on Vista >>filled the tb like molasses. Could pretty well see each letter being >>added >>to the sentence. > > Do you by any chance use a KVM switch to move from computer to computer? > I do and whenever I switch to a W2K box and then back to XP Pro the > keyboard repeat rate gets snockered. I have to go into Control > Panel|Keyboard and drag the Repeat Rate slider from Fast to Slow and > then back to Fast again in order to get it back where I like it - real > fast. > > --- > Stefan Berglund > then, *Larry*... hmmmmmmmmm. Randy Birch wrote:
>> then, *Larry*... Jest call me Daryll... <LOL>> > hmmmmmmmmm. Where's your other brother Daryll?
(If you didn't get it, it's a Newhart thing) Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:eD8TI2LKIHA.5400@TK2MSFTNGP04.phx.gbl... | Randy Birch wrote: | >> then, *Larry*... | > | > hmmmmmmmmm. | | Jest call me Daryll... <LOL> | -- | .NET: It's About Trust! | http://vfred.mvps.org | | "Karl E. Peterson" <k***@mvps.org> wrote in message <cut>news:eHSYa59JIHA.1184@TK2MSFTNGP04.phx.gbl... >> I wonder if a WaitForInputIdle call would be a reasonable "Wait" I agree, just grasping at straws. I seem to remember reading somewhere >> equivalent... > > Well, I'd think not, for a handful of reasons. Mainly, it requires a > process handle, and SendKeys really shouldn't care about that. along the line that the Wait parameter no longer did anything but was still there for backward compatibility. I can't find that now though. BTW, I get an error opening the project in your zip file -- the file name of the form is incorrect Karl -
Here are my results from your latest offering (using Randy's test criteria): -------------------- IDE - XP SP2 -------------------- Code: {home}+{end} SendInput: Yes (text selected) SendKeys: Yes (text selected) Code: {home}+{end}Testing123+(123) SendInput: Yes ("Testing123!@#" sent to box) SendKeys: Yes Code: qwerty{home}+{end} SendInput: Yes (printed text and selected) SendKeys: Yes -------------------- IDE - Vista Home Premium -------------------- Code: {home}+{end} SendInput: Yes (text selected) SendKeys: No (permission denied) Code: {home}+{end}Testing123+(123) SendInput: Yes ("Testing123!@#" sent to box) SendKeys: No (permission denied) Code: qwerty{home}+{end} SendInput: Yes (printed text and selected) SendKeys: No (permission denied) -------------------- EXE - XP SP2 -------------------- Code: {home}+{end} SendInput: Yes (text selected) SendKeys: Yes (text selected) Code: {home}+{end}Testing123+(123) SendInput: Yes ("Testing123!@#" sent to box) SendKeys: Yes Code: qwerty{home}+{end} SendInput: Yes (printed text and selected) SendKeys: Yes -------------------- EXE - Vista Home Premium -------------------- Code: {home}+{end} SendInput: Yes (text selected) SendKeys: Yes (text selected) Code: {home}+{end}Testing123+(123) SendInput: Yes ("Testing123!@#" sent to box) SendKeys: Yes Code: qwerty{home}+{end} SendInput: Yes (printed text and selected) SendKeys: Yes Pretty much the same thing. Don't know how much help that was, but those are my results. - Kev Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:OglTT69JIHA.5468@TK2MSFTNGP05.phx.gbl... | Randy Birch wrote: | > Hi Karl ... | > | > Results of test at home: | | Gotta ask, did you try the new code that uses the KEYEVENTF_EXTENDEDKEY for cursor | keys? Given the inconsistent results, I hope not. <g> | | http://vb.mvps.org/samples/SendInput | | Thanks... Karl | | | > ------------------------------ | > EXE - Vista SP0 | > ------------------------------ | > Code: {home}+{end} | > SendInput: NO (no text selected) | > SendKeys: NO (and no UAC error) | > | > Code: {home}+{end}Testing123+(123) | > SendInput: YES ("Testing123!@#" sent to tbox) | > SendKeys: YES | > | > ------------------------------ | > EXE - XP SP2 | > ------------------------------ | > Code: {home}+{end} | > SendInput YES (text selected) | > SendKeys YES | > | > Code: {home}+{end}Testing123+(123) | > SendInput: YES ("Testing123!@#" sent to tbox) | > SendKeys: YES | > ----------------------------------------------------------------------------------------------- | > ---------------------------------- | > IDE - Vista SP0 | > ---------------------------------- | > Code: {home}+{end} | > SendInput: YES (text selected) | > SendKeys NO (permission error) | > | > Code: {home}+{end}Testing123+(123) | > SendInput: YES ("Testing123!@#" was sent to tbox) | > SendKeys: NO | > | > Code: qwerty{home}+{end} | > SendInput: YES (printed text and selected) | > SendKeys: NO | > | > ---------------------------------- | > IDE - XP SP2 | > ---------------------------------- | > Code: {home}+{end} | > SendInput: YES (text selected) | > SendKeys: YES | > | > Code: {home}+{end}Testing123+(123) | > SendInput: YES ("Testing123!@#" was sent to tbox) | > SendKeys: YES | > | > Code: qwerty{home}+{end} | > SendInput: YES (printed text and selected) | > SendKeys: YES | > | > -- | > | > | > Randy Birch | > http://vbnet.mvps.org/ | > | > Please respond to the newsgroups so all can benefit. | > | > | > "Karl E. Peterson" <k***@mvps.org> wrote in message | > news:uHxveO8JIHA.4712@TK2MSFTNGP04.phx.gbl... | > Randy Birch wrote: | >> I can try the sample code on my vista and XP no-SP vm's tonight. FWIW. | >> Can't run the code here on XP 'cause they don't trust me around | >> development | >> tools. <g> | > | > LOL! | | -- | .NET: It's About Trust! | http://vfred.mvps.org | | Kevin Provance wrote:
> Here are my results from your latest offering (using Randy's test criteria): Those actually look like what I'd expect. You? Seems we whooped this one. :-)Thanks... Karl Yeah, it worked axactly as it should...and one couldn't ask for anything
more. I may end up compiling this into a DLL (as I would be using it across multiple projects) unless you have any strong objections. I'll call it kpSndKys.dll ;-) What's with the "we" stuff? This was all you bro. I just tagged along for the ride and learned some new tricks, for which I thank you. Excellent work. - Kev Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:OpxAmo%23JIHA.1204@TK2MSFTNGP03.phx.gbl... | Kevin Provance wrote: | > Here are my results from your latest offering (using Randy's test criteria): | | Those actually look like what I'd expect. You? Seems we whooped this one. :-) | | Thanks... Karl | -- | .NET: It's About Trust! | http://vfred.mvps.org | | Kevin Provance wrote:
> Yeah, it worked axactly as it should...and one couldn't ask for anything It's "out there" now, intended to be used - go for it! Myself, I'd probably just > more. I may end up compiling this into a DLL (as I would be using it across > multiple projects) unless you have any strong objections. I'll call it > kpSndKys.dll ;-) compile that module into anything that needed it. Also probably change the the subroutine name from MySendKeys to just SendKeys, so it'd override the native one. The "rules" for native SendKeys are incredibly perverse. I guess I'd never really read them that closely before. But I believe this one exactly replicates the native in intent, if not actual outcome. Which was, afterall, the goal. <g> > What's with the "we" stuff? This was all you bro. I just tagged along for Thanks...> the ride and learned some new tricks, for which I thank you. Excellent > work. :-) Karl -
Follow up for you in case you are still monitoring this thread. I ran your project in IDE and EXE under Windows98 SE using Randy's test criteria and everything was a success...FWIW. <g> - Kev Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:e1t9NwHKIHA.4272@TK2MSFTNGP06.phx.gbl... | Kevin Provance wrote: | > Yeah, it worked axactly as it should...and one couldn't ask for anything | > more. I may end up compiling this into a DLL (as I would be using it across | > multiple projects) unless you have any strong objections. I'll call it | > kpSndKys.dll ;-) | | It's "out there" now, intended to be used - go for it! Myself, I'd probably just | compile that module into anything that needed it. Also probably change the the | subroutine name from MySendKeys to just SendKeys, so it'd override the native one. | The "rules" for native SendKeys are incredibly perverse. I guess I'd never really | read them that closely before. But I believe this one exactly replicates the native | in intent, if not actual outcome. Which was, afterall, the goal. <g> | | > What's with the "we" stuff? This was all you bro. I just tagged along for | > the ride and learned some new tricks, for which I thank you. Excellent | > work. | | :-) | | Thanks... | -- | .NET: It's About Trust! | http://vfred.mvps.org | | Kevin Provance wrote:
> Follow up for you in case you are still monitoring this thread. I ran your Cool, thanks! I didn't have a chance to even try on 9x...> project in IDE and EXE under Windows98 SE using Randy's test criteria and > everything was a success...FWIW. <g> Bob Butler wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote in message I'd love to find that. It'd totally justify me ignoring it too. <g>> news:eHSYa59JIHA.1184@TK2MSFTNGP04.phx.gbl... > <cut> >>> I wonder if a WaitForInputIdle call would be a reasonable "Wait" >>> equivalent... >> >> Well, I'd think not, for a handful of reasons. Mainly, it requires a >> process handle, and SendKeys really shouldn't care about that. > > I agree, just grasping at straws. I seem to remember reading somewhere > along the line that the Wait parameter no longer did anything but was still > there for backward compatibility. I can't find that now though. (Certainly corresponds to my observations, though!) > BTW, I get an error opening the project in your zip file -- the file name of Aw, jeeez... Sorry about that! I just replaced it with one that isn't all hosed. > the form is incorrect Might've explained some of Randy's issues, too. Trying to get way too much done here today. Thanks... Karl
Show quote
"Karl E. Peterson" <k***@mvps.org> wrote in message I found what I was remembering but it was for VB Script, not VBnews:Otjnpp%23JIHA.5764@TK2MSFTNGP06.phx.gbl... > Bob Butler wrote: >> "Karl E. Peterson" <k***@mvps.org> wrote in message >> news:eHSYa59JIHA.1184@TK2MSFTNGP04.phx.gbl... >> <cut> >>>> I wonder if a WaitForInputIdle call would be a reasonable "Wait" >>>> equivalent... >>> >>> Well, I'd think not, for a handful of reasons. Mainly, it requires a >>> process handle, and SendKeys really shouldn't care about that. >> >> I agree, just grasping at straws. I seem to remember reading somewhere >> along the line that the Wait parameter no longer did anything but was >> still >> there for backward compatibility. I can't find that now though. > > I'd love to find that. It'd totally justify me ignoring it too. <g> > > (Certainly corresponds to my observations, though!) Bob Butler wrote:
Show quote > "Karl E. Peterson" <k***@mvps.org> wrote... Mmmm, yeah, they removed it altogether there, didn't they?>> Bob Butler wrote: >>> "Karl E. Peterson" <k***@mvps.org> wrote in message >>> news:eHSYa59JIHA.1184@TK2MSFTNGP04.phx.gbl... >>> <cut> >>>>> I wonder if a WaitForInputIdle call would be a reasonable "Wait" >>>>> equivalent... >>>> >>>> Well, I'd think not, for a handful of reasons. Mainly, it requires a >>>> process handle, and SendKeys really shouldn't care about that. >>> >>> I agree, just grasping at straws. I seem to remember reading somewhere >>> along the line that the Wait parameter no longer did anything but was >>> still >>> there for backward compatibility. I can't find that now though. >> >> I'd love to find that. It'd totally justify me ignoring it too. <g> >> >> (Certainly corresponds to my observations, though!) > > I found what I was remembering but it was for VB Script, not VB "Karl E. Peterson" <k***@mvps.org> wrote in message not quitenews:e%23cph6%23JIHA.3400@TK2MSFTNGP03.phx.gbl... >> I found what I was remembering but it was for VB Script, not VB > > Mmmm, yeah, they removed it altogether there, didn't they? set s=createobject("WScript.Shell") s.AppActivate "Untitled - Notepad" s.SendKeys "abc",true Bob Butler wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote in message Yeah, that looks familiar, too. Hmmm, I think this is what I'd seen recently, that > news:e%23cph6%23JIHA.3400@TK2MSFTNGP03.phx.gbl... >>> I found what I was remembering but it was for VB Script, not VB >> >> Mmmm, yeah, they removed it altogether there, didn't they? > > not quite > > set s=createobject("WScript.Shell") > s.AppActivate "Untitled - Notepad" > s.SendKeys "abc",true made me say that: http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx
Show quote
"Karl E. Peterson" <k***@mvps.org> wrote in message Yeah, they took the optional second parameter out of the documentation but news:O03TDH$JIHA.5116@TK2MSFTNGP03.phx.gbl... > Bob Butler wrote: >> "Karl E. Peterson" <k***@mvps.org> wrote in message >> news:e%23cph6%23JIHA.3400@TK2MSFTNGP03.phx.gbl... >>>> I found what I was remembering but it was for VB Script, not VB >>> >>> Mmmm, yeah, they removed it altogether there, didn't they? >> >> not quite >> >> set s=createobject("WScript.Shell") >> s.AppActivate "Untitled - Notepad" >> s.SendKeys "abc",true > > Yeah, that looks familiar, too. Hmmm, I think this is what I'd seen > recently, that made me say that: > > http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx it's still defined, just ignored. Bob Butler wrote:
Show quote > "Karl E. Peterson" <k***@mvps.org> wrote in message Gotta like that. :-)> news:O03TDH$JIHA.5116@TK2MSFTNGP03.phx.gbl... >> Bob Butler wrote: >>> "Karl E. Peterson" <k***@mvps.org> wrote in message >>> news:e%23cph6%23JIHA.3400@TK2MSFTNGP03.phx.gbl... >>>>> I found what I was remembering but it was for VB Script, not VB >>>> >>>> Mmmm, yeah, they removed it altogether there, didn't they? >>> >>> not quite >>> >>> set s=createobject("WScript.Shell") >>> s.AppActivate "Untitled - Notepad" >>> s.SendKeys "abc",true >> >> Yeah, that looks familiar, too. Hmmm, I think this is what I'd seen >> recently, that made me say that: >> >> http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx > > Yeah, they took the optional second parameter out of the documentation but > it's still defined, just ignored.
Show quote
"Karl E. Peterson" <k***@mvps.org> wrote in message So your code is a VB6 replacement for the VBScript Sendkeys function!news:O46RmX$JIHA.3916@TK2MSFTNGP02.phx.gbl... > Bob Butler wrote: >> "Karl E. Peterson" <k***@mvps.org> wrote in message >> news:O03TDH$JIHA.5116@TK2MSFTNGP03.phx.gbl... >>> Bob Butler wrote: >>>> "Karl E. Peterson" <k***@mvps.org> wrote in message >>>> news:e%23cph6%23JIHA.3400@TK2MSFTNGP03.phx.gbl... >>>>>> I found what I was remembering but it was for VB Script, not VB >>>>> >>>>> Mmmm, yeah, they removed it altogether there, didn't they? >>>> >>>> not quite >>>> >>>> set s=createobject("WScript.Shell") >>>> s.AppActivate "Untitled - Notepad" >>>> s.SendKeys "abc",true >>> >>> Yeah, that looks familiar, too. Hmmm, I think this is what I'd seen >>> recently, that made me say that: >>> >>> http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx >> >> Yeah, they took the optional second parameter out of the documentation >> but >> it's still defined, just ignored. > > Gotta like that. :-) Bob Butler wrote:
Show quote > "Karl E. Peterson" <k***@mvps.org> wrote ... Y'know, it's weird. Microsoft told me they'd fixed WSH, but didn't want folks using >> Bob Butler wrote: >>> "Karl E. Peterson" <k***@mvps.org> wrote ... >>>> Bob Butler wrote: >>>>> "Karl E. Peterson" <k***@mvps.org> wrote in message >>>>> news:e%23cph6%23JIHA.3400@TK2MSFTNGP03.phx.gbl... >>>>>>> I found what I was remembering but it was for VB Script, not VB >>>>>> >>>>>> Mmmm, yeah, they removed it altogether there, didn't they? >>>>> >>>>> not quite >>>>> >>>>> set s=createobject("WScript.Shell") >>>>> s.AppActivate "Untitled - Notepad" >>>>> s.SendKeys "abc",true >>>> >>>> Yeah, that looks familiar, too. Hmmm, I think this is what I'd seen >>>> recently, that made me say that: >>>> >>>> http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx >>> >>> Yeah, they took the optional second parameter out of the documentation >>> but >>> it's still defined, just ignored. >> >> Gotta like that. :-) > > So your code is a VB6 replacement for the VBScript Sendkeys function! it because "there might be language issues." They've fixed Office 2007 VBA, but not Office 2003, because it's not the latest so it shouldn't give an equally good experience. (No kidding!) They've fixed VB6, but only the runtime and not the editor. VB5 can pound sand, as far as they care. Yeah, I think this code can do a decent stand-in in a *lot* of places, perhaps even from VBS! <g> I got the same message but added the form to the project manually and it
ran. Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:Otjnpp%23JIHA.5764@TK2MSFTNGP06.phx.gbl... > Bob Butler wrote: >> "Karl E. Peterson" <k***@mvps.org> wrote in message >> news:eHSYa59JIHA.1184@TK2MSFTNGP04.phx.gbl... >> <cut> >>>> I wonder if a WaitForInputIdle call would be a reasonable "Wait" >>>> equivalent... >>> >>> Well, I'd think not, for a handful of reasons. Mainly, it requires a >>> process handle, and SendKeys really shouldn't care about that. >> >> I agree, just grasping at straws. I seem to remember reading somewhere >> along the line that the Wait parameter no longer did anything but was >> still >> there for backward compatibility. I can't find that now though. > > I'd love to find that. It'd totally justify me ignoring it too. <g> > > (Certainly corresponds to my observations, though!) > >> BTW, I get an error opening the project in your zip file -- the file name >> of >> the form is incorrect > > Aw, jeeez... Sorry about that! I just replaced it with one that isn't > all hosed. Might've explained some of Randy's issues, too. Trying to get > way too much done here today. > > Thanks... Karl > -- > .NET: It's About Trust! > http://vfred.mvps.org > |
|||||||||||||||||||||||