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

Ask for help, how to use AHK_H, etc.
lsh
Posts: 10
Joined: 14 Sep 2017, 07:02

[AHK_H v2] 'ComObjConnect' Thread direct connection

06 Jan 2018, 16:04

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)
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

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

06 Jan 2018, 18:59

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()
lsh
Posts: 10
Joined: 14 Sep 2017, 07:02

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

07 Jan 2018, 06:55

' 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?
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

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

07 Jan 2018, 07:42

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()

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 22 guests