ObjShare() example Topic is solved

Ask for help, how to use AHK_H, etc.
User avatar
RazorHalo
Posts: 32
Joined: 21 Dec 2015, 21:23

ObjShare() example

17 Feb 2020, 01:59

First time trying out AutoHotKey_H v1 to see if the Multi-Threading will help my script. Reading the docs it seems pretty simple to use ObjShare() to be able to access my class method from the thread started with AhkThread().

I have been trying everything I can think of for hours now and I can't even get the example form the docs https://hotkeyit.github.io/v2/docs/commands/ObjShare.htm#Examples to work.

All I ever get is an error LResult Object could not be created

I have installed _H correctly as far as I can tell as other examples from the docs run fine. Is there any issue with ObjShare() command that anyone else has expirenced? Can someone verify that the example works, and if so what could i possible be missing?

Thanks
HotKeyIt
Posts: 2130
Joined: 29 Sep 2013, 18:35
Contact:

Re: ObjShare() example  Topic is solved

17 Feb 2020, 16:23

The example was for an older AHK_H v2, here for v1, just changed to ObjShare(" lresult "):

Code: Select all

Gui,Add,Slider,vSlider,50
Gui,Add,CheckBox
Gui,Show,w200 h100
t:=new Test 
lresult := ObjShare(t) ; Create lresult to use in a different thread
AhkThread("
(
    t := ObjShare(" lresult ") ; Create IDispatch proxy COM object
    Loop
        t.CheckBox()
)")
 
Loop
  t.Slider()
return
GuiClose:
ExitApp
Class Test {
  CheckBox(){
    GuiControlGet,value,,Button1
    GuiControl,,Button1,% Value?0:1
  }
  Slider(){
    GuiControlGet,value,,Slider
    if value=100
      value:=0
    GuiControl,,Slider,% Value+1
  }
}
User avatar
RazorHalo
Posts: 32
Joined: 21 Dec 2015, 21:23

Re: ObjShare() example

17 Feb 2020, 17:25

Thanks HotKeyIt, I did not realize that syntax was different.

I can't seem to find reference to that in the docs...is that just for _H specific functions called from within AhkThread()?

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 24 guests