Keysharp.Core.Window.SearchControl() bug, or related.

Issue #87 closed
Winter Laite created an issue

This code worked at least as recently as September 5, 2022. Unfortunately I don’t know when it was introduced.

MyGui := Gui()

gb3Edit := MyGui.Add("Edit", "w300 h300")
gb3Hwnd := gb3Edit.Hwnd

MyGui.Add("Text", "xp", "Testing control bug")
gb4Btn1 := MyGui.Add("Button", "s14 cLime", "Send to GB3")
gb4Btn1.OnEvent("Click", "SendToGB3")
gb4Btn2 := MyGui.Add("Button", "s14 cLime x100 yp", "Clear GB3")
gb4Btn2.OnEvent("Click", "ClearGB3")

MyGui.Show()

SendToGB3() {
GB3Text := "
(
This uses 'ControlSetText' from a button in GroupBox 4 to populate this edit.
The first message box shows the HWND of this Edit.
The second message box shows '1' (True) if GuiCtrlFromHwnd created an
object from the Hwnd.
Finally, ControlSetText operates on the Object created from the Hwnd.
)"

    MsgBox(gb3Hwnd, "Hwnd of Groupbox 3 Edit")
    obj := GuiCtrlFromHwnd(gb3Hwnd)
    Result := IsObject(obj)
    MsgBox(Result, "If '1', is Object")
    ControlSetText(GB3Text, gb3Hwnd)
}

ClearGB3() {
    ControlSetText(, gb3Hwnd)
}

Now it throws an unhandled exception, error below.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> Message: Could not find child control in window title: 
What: Keysharp.Core.Window.SearchControl()
Extra: 
File: C:\Users\testuser\Documents\repos\keysharp\Keysharp.Core\Core\Gui\Window.cs
Line: 974

I have a backup from 9/5/22 and have confirmed it worked then.

Comments (7)

  1. Log in to comment