xroot Posted May 28, 2019 Share Posted May 28, 2019 Was playing with an activex from HERE. It's called WindowSystemObject (WSO), so when I use ObjEvent it returns an object called IControlEvents but when I click the button nothing happens (no close exit). IControlEvents has an OnClick Interface. Here is the code Func ObjErrFunc() Msgbox(0,"*COM ERROR*",$wsobjErr.windescription & @LF & $wsobjErr.description & @LF & "Line=" & $wsobjErr.scriptline) EndFunc Func CloseForm_OnClick($Sender) $f.Close() Exit EndFunc global $wsobjErr = ObjEvent("AutoIt.Error","ObjErrFunc") local $wso = ObjCreate("Scripting.WindowSystemObject") global $f = $wso.CreateForm(0,0,500,400) $f.Color = 0xff00ff $f.Text = "Au3 Test WSO" $f.CenterControl() $b = $f.CreateButton(120,70,120,45,"Exit") $b.CenterControl() $b.Color = 0xff0000 $b.Font.Name = "Arial" $b.Font.Size = 18 $b.Font.Bold = True $b.Font.Underline = True local $ce = ObjEvent($b,"CloseForm_") ;returns an object nothing happens when button is clicked ; MsgBox(64,"@Error="&@error,StringFormat("Name\tType\n%s\t%s\n%s\t%s",objname($ce),vargettype($ce),objname($b),vargettype($b))) $f.Show() $wso.Run() Not sure what I am doing wrong?? I wrote the same code in AutoHotKey with ComObjConnect and it all worked. Even fired up VB6 using WithEvents and it also worked fine. Any help will be appreciated. Link to comment Share on other sites More sharing options...
trancexx Posted May 28, 2019 Share Posted May 28, 2019 Probably it requires synchronous execution of the event function. If so then it should be: ;... volatile Func CloseForm_OnClick($Sender) $f.Close() Exit EndFunc ;... ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
xroot Posted May 29, 2019 Author Share Posted May 29, 2019 Thanks Trancexx, that worked. 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