一点线索:那个h的变量类型是字符串,但autoit要求是指针类型,所以问题是:如何把h转为指针?
vba:Sub t()
Set au3 = CreateObject("autoitx3.control")
w = "[CLASS:Notepad]"
au3.WinActivate (w)
Call au3.ControlSetText(w, "", "Edit1", "123") 'OK
h = au3.ControlGetHandle(w, "", "Edit1")
Call au3.ControlSetText(w, "", h, "12345") 'Fail
ph = VarPtr(h)
MsgBox TypeName(h) & " " & TypeName(ph)
Set au3 = Nothing
End Sub
autoit:;Run("notepad.exe")
$w="[CLASS:Notepad]"
WinActivate($w)
$h=ControlGetHandle($w,"","Edit1")
ControlSetText($w,"",$h,"12345")
MsgBox(0,0,$h & " " & VarGetType($h))
|