ControlClick - not working

Issue #60 closed
Winter Laite created an issue

ISSUE

ControlClick does not work in Keysharp under test conditions below.

Steps to duplicate
  • Run first code below with AutoHotkey
  • Run second code below with Keysharp
  • Run third code below with Keysharp
  • Position GUIs as in image below (drag)
  • Click button on AHK Gui (“Remote Control”) - button in “Some Window Title” is remotely clicked.
  • Click button on Keysharp Gui (“Remote Control”) - button in “Some Window Title” is not remotely clicked.
First code
ThisGui := Gui(, "Remote Control")
Btn := ThisGui.Add("Button", , "Remote control")
Btn.OnEvent("Click", ClickAbove)

ThisGui.Show("w300 h50 x300 y500")

ClickAbove(*) {
    SetControlDelay -1
    ControlClick("Show MsgBox", "Some Window Title")
}
second code
ThisGui := Gui(, "Remote Control")
Btn := ThisGui.Add("Button", , "Remote control")
Btn.OnEvent("Click", "ClickRemote")

ThisGui.Show("w300 h90 x300 y500")

ClickRemote() {
    SetControlDelay -1
    ControlClick("Show MsgBox", "Some Window Title")
}
third code
MyGui := Gui(, "Some Window Title")

CC_Btn1 := MyGui.Add("Button", "x10 w120", "Show MsgBox")
CC_Btn1.OnEvent("Click", "ShowMsg")


MyGui.Show()

ShowMsg() {
    MsgBox("Test message", "ControlZoo Testing")
}

Comments (6)

  1. Winter Laite reporter

    Simpler, reliable AHK code to test:

    MyGui := Gui(, "Control Clicking")
    Btn1 := MyGui.Add("Button", "x10 y10 w80 h25", "Show MsgBox")
    Btn1.OnEvent("Click", ShowMsg)
    Btn2 := MyGui.Add("Button", "x10 y+5 w80 h25", "ClickThru")
    Btn2.OnEvent("Click", ClickThru)
    MyGui.Show()
    
    ShowMsg(*) {
        MsgBox("I am a message. Really.")
    }
    
    ClickThru(*) {
        SetControlDelay(-1)
        ControlClick(Btn1, MyGui.Hwnd,,,, "NA")
    }
    

    Similar but non-working Keysharp code:

    MyGui := Gui(, "Control Clicking")
    Btn1 := MyGui.Add("Button", "x10 y10 w80 h25", "Show MsgBox")
    Btn1.OnEvent("Click", "ShowMsg")
    Btn2 := MyGui.Add("Button", "x10 y+5 w80 h25", "ClickThru")
    Btn2.OnEvent("Click", "ClickThru")
    MyGui.Show()
    
    ShowMsg() {
        MsgBox("I am a message. Really.")
    }
    
    ClickThru() {
        SetControlDelay(-1)
        ControlClick(Btn1, MyGui.Hwnd,,,, "NA")
    }
    

  2. Log in to comment