-
June 25th, 2025, 06:05 PM
#1
[RESOLVED] VB Net 2022 InvokeMember ("keyup") does not work (proven) need alternative
I have a work project where I am automating some work from our portal. All is well, accept the InvokeMember("Keyup"). All other itmes work: KeyDown, MouseMove, KeyPress, etc.
I have proven that the Keyup is not firing by stopping on the code and letting the "Keyup" fire multiple times. Then I simply pressed another, non-alphabet, key and the window appeared. I am trying to get a combobox with a auto fill dropdown window for names. (See attached picture).
Without the Keyup working I cannot get the dropdown window to appear, so I can't move on in the program. Does anyone have an alternative to "InvovokeMember("Keyup") routine? Below is the code in use.
Code:
Public Function WrComboBoxDropDownSelect(ByVal szCBdropDown As String, ByVal szCBText As String) As Boolean
Dim HTMLele As HtmlElement
Dim HTMLeleCol As HtmlElementCollection
Dim bStatus As Boolean
Dim nCount As Integer
Dim szComp As String
Try
If (GetDebug()) Then
Debug.Print("clsIIE [WrComboBoxDropDownSelect Enter]")
End If
If (GetAbort()) Then
WrComboBoxDropDownSelect = False
Exit Function
End If
If (IsObjectConnected(WebBrowser1.Document) = False) Then
WrComboBoxDropDownSelect = False
Exit Function
End If
bStatus = True
HTMLele = GetElement(ENUM_ELEMENT.eELEMENT_ID, szCBdropDown)
'Do While (True)
' DoEvents()
'Loop
If (Not HTMLele Is Nothing) Then
'HTMLele.Focus()
HTMLele.InvokeMember("mouseover")
DoEvents()
Thread.Sleep(150)
HTMLele.InvokeMember("keydown")
DoEvents()
Thread.Sleep(150)
'Process the name placement
HTMLele.InvokeMember("keypress")
DoEvents()
Thread.Sleep(150)
'szCBText = szCBText & "]"
'Place the name in the box
HTMLele.SetAttribute("value", szCBText)
DoEvents()
Thread.Sleep(150)
'Process the name placement
HTMLele.InvokeMember("keypress")
DoEvents()
Thread.Sleep(150)
'HTMLele.Focus()
HTMLele.InvokeMember("keyup") <-Issue code.
''DoEvents()
''Thread.Sleep(150)
''HTMLele.InvokeMember("change")
DoEvents()
'HTMLele.InvokeMember(on)
BrowserWait(1000)
'Do While (1)
' Dim i As Integer
' i = 10
' DoEvents()
'Loop
'epperson, brad
'Do While (True)
' DoEvents()
' BrowserWait(1000)
'Loop
nCount = 0
HTMLele = Nothing
Do While (HTMLele Is Nothing And GetAbort() = False And nCount < 300)
DoEvents()
HTMLele = GetElement(ENUM_ELEMENT.eELEMENT_ID, "MenuScrollingDiv")
If (Not HTMLele Is Nothing) Then
HTMLeleCol = HTMLele.GetElementsByTagName("li")
If (Not HTMLeleCol Is Nothing) Then
Thread.Sleep(350)
For Each HTMLele In HTMLeleCol
' If (InStr(HTMLele2.InnerHtml, "AutoCompleteItemHover") <> 0) Then
HTMLele.InvokeMember("Click")
DoEvents()
' End If
Next
'Sleep(500)
End If
End If
Loop
Else
bStatus = False
End If
szComp = RdTextBox("SJM_COMPLAINTS_PI_PI_MANAGER_LIST")
'szComp = RdTextBox(szCBdropDown)
If (StrComp(szComp, szCBText) = 0) Then
DeleteLBItemCheck(szCBdropDown)
Call WrComboBoxDropDownSelect(szCBdropDown, szCBText)
End If
WrComboBoxDropDownSelect = bStatus
HTMLele = Nothing
'Wait for browser
BrowserWait(1000)
If (GetDebug()) Then
Debug.Print("clsIIE [WrComboBoxDropDownSelect Exit]")
End If
Catch ex As Exception
Dim szErr As String
szErr = "Error occured for the following reason [" & ex.Message & "]"
If (GetDebug()) Then
Debug.Print(szErr)
'gClsExcel.ExcelWriteErrorLog("WrComboBoxDropDownSelect", szErr)
End If
WrComboBoxDropDownSelect = False
HTMLele = Nothing
End Try
End Function
The while loop is waiting for the dropdown combobox to appear and then selects it. This all works fine, and have proven it by pressing a key and letting the program continue. The company webpage sees the keyup and reacts appropriately.
Any suggestions? I have tried SendKeys, but that simply placed the text in my VB window. Screenshot 2025-06-24 190255.png
EDIT: I should mention that this same program written in VBA work with HTMLele.FireEvent("onkeyup")
They are nearly identical, but in VBA I was able to work with CLASS types, but in VB I'm limited. Other than that the programs are identical.
Last edited by funkmonkey; June 25th, 2025 at 06:17 PM.
-
June 26th, 2025, 03:27 AM
#2
Re: VB Net 2022 InvokeMember ("keyup") does not work (proven) need alternative
[This is a very similar question to the one asked and answered here
https://www.vbforums.com/showthread....ot-not-working ]
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
June 26th, 2025, 10:00 AM
#3
Re: VB Net 2022 InvokeMember ("keyup") does not work (proven) need alternative
 Originally Posted by 2kaud
There is no solution provided, only back and forth questions. Still need assistance for resolution.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|