Why doesn't the stream stop in this example?

Ask for help, how to use AHK_H, etc.
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Why doesn't the stream stop in this example?

14 Sep 2022, 13:56

Why doesn't the stream stop in this example?

Code: Select all

script1 := "
(
#NoTrayIcon 
Persistent    
loop
{
ToolTip "s1-" A_index, 100, 150
sleep 50

}
)"

script2 := "
(
#NoTrayIcon 
Persistent    
Loop
{
ToolTip "s2-" A_index, 200, 150
sleep 50
}
)"

F1::
{

MyThread1:=NewThread(script1)
MyThread2:=NewThread(script2)
}

F2::
{
 
  if (IsSet(MyThread1)) 
 MyThread1.ahkterminate()
 if(IsSet(MyThread2))
MyThread2.ahkterminate()
}

[Mod action: Moved topic to AHK_H section from main v2 section.]
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Why doesn't the stream stop in this example?

14 Sep 2022, 15:46

This belongs in the AHK_H forum, right? (v2 of AHK_H)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Why doesn't the stream stop in this example?

14 Sep 2022, 17:54

MyThread1 and MyThread2 are variables local to the F1 hotkey's function implementation. u spin up the threads and once the function returns u lose all references to them. the fact that u thought enough ahead to add the IsSet() checks, leads me to believe u must have encountered the error where it would have alerted u to MyThread1 and MyThread2 being references to uninitialized variables, and instead of realizing whats up, u figured it would be a better idea to just go ahead and suppress the warnings

i think u need to revise ur fundamentals before graduating to working with threads. otherwise, ull be largely wasting ur time(and consequently ours too)
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

14 Sep 2022, 21:34

@swagfag

This example is not my property, it was taken from here.
viewtopic.php?p=444271#p444271

I just just want to know how do I destroy the thread that was called or is it impossible in AHK V2?
@boiler

Honestly, I'm already confused myself A_AhkVersion gives me a version: 2.0-beta.
So is it possible to destroy the thread that was created?
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Why doesn't the stream stop in this example?

14 Sep 2022, 21:56

There is a v2 beta version of AHK_H. The official version of AHK doesn’t support multithreading (neither v1 nor v2), but AHK_H does (both v1 and v2). The link you posted from where you got the code says it’s for AHK_H in both the subject and the body, and it resides in the AHK_H section of the forum.

This sub-forum (v2 Ask For Help) is for getting help with the “official” v2 release, although topics that apply to both could be discussed here. However, your script directly involves multithreading. I will move this topic to that sub-forum.
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

14 Sep 2022, 22:09

@boiler

So AutoHotkey_H-2.0-beta.7 is not the official version?
And what do you mean by the phrase "Official version"?

In any case, I have found only one way, it is to destroy a Thread through WinAPI, however, I am still looking for an answer how this can be done.
In the "Process Hacker 2" application, it is possible to view all existing threads and destroy them.
However, I am still looking for an answer, because the ahk terminate() command does not exist in this assembly, but it is possible to create a thread.
Really @HotKeyIt haven't thought through the possibility of destroying the Thread?
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 00:47

bapl wrote: So AutoHotkey_H-2.0-beta.7 is not the official version?
No, just like the v1 version of AHK_H is not the official version of the full release (non-beta) version. AHK_H is a fork from the official version that is maintained by HotKeyIt. Because of the popularity of AHK_H and that it is fully maintained by HotKeyIt, a section of this forum is devoted to it.
bapl wrote: And what do you mean by the phrase "Official version"?
The official full-release version is v1.1.34.04. It is the version that is downloaded as the official release from the AutoHotkey.com main page and the download link at the top of these forum pages. AHK v2 (not the AHK_H) version, which is in beta release, was developed/is being developed by the official main developer of AHK, Lexikos, with the plan for it to be the official full-release version after it comes out of beta. He has been the main developer since the founder of AHK, Chris Mallett, handed it off to him.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 03:38

yes, hotkeyit totally forgot to implement threadstopping functionality 🤡
swagfag wrote:
14 Sep 2022, 17:54
MyThread1 and MyThread2 are variables local to the F1 hotkey's function implementation.
address that first, then the code will start working
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 14:35

@swagfag
Can you please give at least one working example? I really don't understand what you mean.
I understand better by example, thanks!
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 16:41

:roll: really...

Code: Select all

F1::
{
global MyThread1, MyThread2
MyThread1:=NewThread(script1)
MyThread2:=NewThread(script2)
}

F2::
{
global MyThread1, MyThread2
 
 MyThread1.ahkterminate()
MyThread2.ahkterminate()
}
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 22:50

@swagfag

Image

UPD:
It turns out I've been using AHK V2 by Lexikos all this time.

I installed AHK_H V2 from here: viewtopic.php?p=441117#p441117 and now it doesn't give any errors.
Thanks for the help.

I still have a couple of questions about:

1. AHK_H V2 is based on AHK V2 by lexikos?
2. Is password protection identical in both versions?
Attachments
image.png
image.png (18.2 KiB) Viewed 3189 times
Last edited by bapl on 15 Sep 2022, 23:06, edited 1 time in total.
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 23:03

Did you make script1 and script2 global? If not, then you didn't create any threads since there is no script text passed to NewThread().
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

15 Sep 2022, 23:07

@boiler
I edited the post above, please read again ^^
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Why doesn't the stream stop in this example?

16 Sep 2022, 04:49

Please don’t edit posts to remove the context of subsequent posts. Just make another post with the new information.

If you weren’t using AHK_H, how were you not getting errors for calling a non-existent function NewThread()?

Yes, AHK_H v2 is based on Lexikos’ v2.

No, password protection is only a feature of AHK_H. It requires recompiling AHK_H from the C++ source in order to implement your own password.
User avatar
boiler
Posts: 16978
Joined: 21 Dec 2014, 02:44

Re: Why doesn't the stream stop in this example?

16 Sep 2022, 05:04

bapl wrote: It turns out I've been using AHK V2 by Lexikos all this time.
I don’t see how this could possibly be true given your other posts in this thread unless you were making up the results you said you were getting when you supposedly ran the code you copied from someone else and posted.
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

16 Sep 2022, 19:23

@boiler
Sorry again.
I used the given Git: https://github.com/thqby/AutoHotkey_H
As I understand it, he is also involved in the development of AHK, but I do not understand why the NewThread () function exists, but cannot be destroyed.
I suppose I should approach him personally with this problem.

I've reached out to HotKeyIT with one problem that I can't seem to resolve when building its Feb 9 Source code: viewtopic.php?f=67&t=108498
Maybe you know what my mistake is.

I can only assume that either the AutoHotkey2.RC file and AutoHotkey2.idl were not added to the project, or they should be generated at build time, but this does not happen.
User avatar
thqby
Posts: 408
Joined: 16 Apr 2021, 11:18
Contact:

Re: Why doesn't the stream stop in this example?

17 Sep 2022, 02:26

NewThread returns a thread ID instead of an object.

https://github.com/HotKeyIt/ahkdll-v2-release/blob/master/Compiler/v2/lib/ThreadObj.ahk
The AHK library is based on the NewThread implementation.

And my ahk_h has Worker class, similar to threadobj.
User avatar
thqby
Posts: 408
Joined: 16 Apr 2021, 11:18
Contact:

Re: Why doesn't the stream stop in this example?

17 Sep 2022, 02:36

bapl wrote:
16 Sep 2022, 19:23
I can only assume that either the AutoHotkey2.RC file and AutoHotkey2.idl were not added to the project, or they should be generated at build time, but this does not happen.
Maybe Hotkeyit forgot to upload it.
AutoHotkey2.idl is the dll project file.
bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: Why doesn't the stream stop in this example?

17 Sep 2022, 04:21

@thqby

Another off-topic question, but I'd like to know.
I run a compiled script (like Script.exe) compiled through your AHK_H and dump it through the task manager, or just open the process itself.
Through search, I can easily find hotkey names, all variables without any difficulty. I used to think that all this information is cleared, isn't it? It turns out the password is meaningless to put?
User avatar
thqby
Posts: 408
Joined: 16 Apr 2021, 11:18
Contact:

Re: Why doesn't the stream stop in this example?

17 Sep 2022, 06:32

Are you sure it's encrypted? It's not encrypted by default.

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 106 guests