There seems to be a bug in the AutoHotkey_h version of multithreading. Please help me to fix this.

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
chcgf
Posts: 4
Joined: 04 May 2017, 08:08

There seems to be a bug in the AutoHotkey_h version of multithreading. Please help me to fix this.

16 Mar 2020, 13:22

Code: Select all

Gui, Add, CheckBox, x5 y20 w40 h20 vsample ghunt, test
Gui, Add, Text, x5 y40 w60 h20, F1: start
Gui, Show, x100 y100 h100 w100, test
Return

GuiClose:
ExitApp
return

F1 ::
if (sample = 1)
{
error_sample: = AhkThread (script_sample)
}
return

F2 ::
ExitApp
return

hunt:
gui, submit, nohide
script_sample =
(%
ParentThread: = AhkExported ()
Random, action, 0, 1

infinite:
Loop
{
sample: = ParentThread.AhkGetVar.sample
if (sample = 1)
{
break
}
}

Loop
{
sample: = ParentThread.AhkGetVar.sample
if (sample = 1)
{
break
}
}

Loop
{
sample: = ParentThread.AhkGetVar.sample
if (sample = 1)
{
break
}
}

Loop
{
sample: = ParentThread.AhkGetVar.sample
if (sample = 1)
{
continue, infinite
}
}
return
)
if (sample = 0)
{
error_sample.ahkterminate []
}
return
[Mod edit: [code][/code] tags added]

The above code is an example of a code that occurs when the auto hotkey stops working or suddenly turns off after a certain period of time (10 minutes to 1 hour if it is longer) after creating a thread.
As you can see in the code, if you press the F1 key while the gui checkbox is checked, an error_sample thread is created. However, if you look at the error_sample thread code above, you can escape the infinite loop statement into a break and continue to return to the first infinite loop statement. This is a simple script that does the work. Don't ask why you wrote the code that way. The code above is an example code, and the actual low-cost code is code that needs to be written that way. The code above is an example code that causes a bug. Error_sample thread When I look at the code of, I don't understand why. But when I write the code like that, AutoHotkey is turned off unconditionally. I don't know why. So the conclusion I made is that this is a bug in the AutoHotkey_H version. Please help this hotkeyit

Below are the specifications of the computer I am using and the AutoHotkey version.
Operating system: Windows 10 pro
Autohotkey version: autohotkey_h 1.1.30.03 x64 release MD
cpu: intel i5-4690
memory: 8GB
Graphics card: NVIDIA GeForce GTX 1050

For reference, I would like to understand that the word or sentence may be awkward or difficult to understand using the Google Translator, and there was no problem when the code in the error_sample thread was used as the main script above. I have a problem when I put it in. I want to know why this is happening
Last edited by chcgf on 16 Mar 2020, 13:36, edited 1 time in total.
chcgf
Posts: 4
Joined: 04 May 2017, 08:08

Re: There seems to be a bug in the AutoHotkey_h version of multithreading. Please help me to fix this.

16 Mar 2020, 13:24

Lastly, I understand that it may be difficult to interpret or understand the sentence using the Google Translator. Please help me to solve this.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: There seems to be a bug in the AutoHotkey_h version of multithreading. Please help me to fix this.

16 Mar 2020, 16:59

AhkGetVar and many other functions are called via SendMessage and Postmessage, doing this in a Loop without a sleep is not a good way to do it.
Instead you can use Alias:

Code: Select all

Gui, Add, CheckBox, x5 y20 w40 h20 vsample ghunt, test
Gui, Add, Text, x5 y40 w60 h20, F1: start
Gui, Show, x100 y100 h100 w100, test
Return

GuiClose:
ExitApp
return

F1::
    if (sample = 1)
    {
        error_sample := AhkThread(script_sample)
    }
return

F2::
    ExitApp
return

hunt:
    gui, submit, nohide
    script_sample := "Alias(sample," getvar(sample) ")`n
    (%
    ParentThread := AhkExported()
    Random, action, 0, 1
    infinite:
    Loop
    {
        if (sample = 1)
        {
            break
        }
    }

    Loop
    {
        if (sample = 1)
        {
            break
        }
    }

    Loop
    {
        if (sample = 1)
        {
            break
        }
    }

    Loop
    {
        if (sample = 1)
        {
            continue, infinite
        }
    }
    return
    )"

    if (sample = 0)
    {
        error_sample.ahkterminate[]
    }
return

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 3 guests