Page 1 of 1

[AHK_H v2] 'ComObjConnect' Thread direct connection

Posted: 06 Jan 2018, 16:04
by lsh
Is there a way to connect " ComObjConnect(test....)" to the " _ test " in the thread to obtain a direct "Test_EventName([Params..., ComObject]) "?
......................................................

Code: Select all

ComObjConnect(Test, "Test_ .....................  ")
ThreadList:='
(
 #Persistent
 #SingleInstance Force
 Test_EventName([Params..., ComObject])
 {
    msgbox "... event-handling code ...test"
 }
)'
Thread:=ExeThread(ThreadList)

Re: [AHK_H v2] 'ComObjConnect' Thread direct connection

Posted: 06 Jan 2018, 18:59
by HotKeyIt
You don't need COM to do that, it would even cause problems with COM due to multi-threading.
Instead use CriticalObject:

Code: Select all

ThreadList:='
(
 #Persistent
 _test:=CriticalObject(new test)
 ready:=&_test
 Class test{
   Test_EventName(params*){
      msgbox "... event-handling code ...test"
   }
 }
)'
Thread:=ExeThread(ThreadList)
While !thread.ahkgetvar.ready
  Sleep 100
_test:=CriticalObject(thread.ahkgetvar.ready)
_test.Test_EventName()

Re: [AHK_H v2] 'ComObjConnect' Thread direct connection

Posted: 07 Jan 2018, 06:55
by lsh
' CriticalObject ' is understood as a way to prevent problems caused by interference during multi-threading.
Is that right?

In the following ' script ', ' ie_BeforeNavigate2 ' in ' Thread ', only the areas where simple messages are received are isolated from the mainscript.
The area of the ' ie_BeforeNavigate2 ' in ' Thread ' would be a series of simple repetitive tasks.

Code: Select all

ie := ComObjCreate("InternetExplorer.Application") ; create a IE instance
ComObjConnect(ie, "ie_")
ie.Visible := true
loop 2
{
ie.Navigate("https://autohotkey.com/")
sleep 2000
ie.Navigate("https://www.google.com/")
}
ThreadList:='
(
 #Persistent
 #SingleInstance Force
 ie_BeforeNavigate2(prms, this)
 {
 loop 10000
 FileAppend("in Thread ....Got to Web_BeforeNavigate2\" . A_Hour . ":" . A_Min . ":" . A_Sec,A_ScriptDir . "\" . a_index . ".txt")
 }
)'
Thread:=ExeThread(ThreadList)
Because,
I want the pure function of ' ComObjConnect ', which is to connect the starting point of the memory named 'ie' to 'ie_' in 'Thread'.

Commands such as ' COM_FindConnectionPoint ' and ' RtlMoveMemory ' are not familiar commands and therefore need help.

Attachment :
ExeThread ' knows to have about 3,500 " thread " available. -> https://autohotkey.com/boards/viewtopic ... es#p170584
If there is a 'comobj' directly in each thread, about 330 to 500 are likely possible, right?

Re: [AHK_H v2] 'ComObjConnect' Thread direct connection  Topic is solved

Posted: 07 Jan 2018, 07:42
by HotKeyIt
lsh wrote:' CriticalObject ' is understood as a way to prevent problems caused by interference during multi-threading.
Is that right?
Yes

Try this ;)

Code: Select all

ie := ComObjCreate("InternetExplorer.Application") ; create a IE instance
ie.Visible := true
ThreadList:='
(
 #Persistent
 ie:=new IE_
 ready:=&ie
 Class IE_ {
   BeforeNavigate2(prms, _this)
   {
   MsgBox("in Thread ....Got to Web_BeforeNavigate2\" . A_Hour . ":" . A_Min . ":" . A_Sec,A_ScriptDir . "\" . a_index . ".txt``n" prms)
   }
 }
)'
Thread:=ExeThread("ie:=Object(" (&ie) ")`n" ThreadList)
While !thread.ahkgetvar.ready
  Sleep 100
ComObjConnect(ie, Object(thread.ahkgetvar.ready))
loop 2
{
ie.Navigate("https://autohotkey.com/")
sleep 2000
ie.Navigate("https://www.google.com/")
sleep 2000
}
ie.Quit()

Re: [AHK_H v2] 'ComObjConnect' Thread direct connection

Posted: 07 Jan 2018, 12:07
by lsh
thx.