zjsong Posted September 2, 2014 Share Posted September 2, 2014 I need to call autoit function in VBA, here is VBA code: 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 'MsgBox h Set au3 = Nothing End Sub why can't VBA send handle "h" to autoit correctly ? Link to comment Share on other sites More sharing options...
zjsong Posted September 2, 2014 Author Share Posted September 2, 2014 a little idea: the type of h is String, but autoit need Ptr type. so the problem is: how to change h from String to Ptr or Long type? Thanks. vba code: 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 code: ;Run("notepad.exe") $w="[CLASS:Notepad]" WinActivate($w) $h=ControlGetHandle($w,"","Edit1") ControlSetText($w,"",$h,"12345") MsgBox(0,0,$h & " " & VarGetType($h)) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now