Authotkey and Threading

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
Posts: 1
Joined: 30 Dec 2020, 18:37

Authotkey and Threading

Post by Mradr » 30 Dec 2020, 18:50

image.png (10.88 KiB) Viewed 158 times
Hello, not sure what is really causing the issue, so was hoping someone could point me in the right direction. I have written my code to hopefully to make use of m-threads, but I seem to be getting an issue about (having searching the error up) with data being share and thus causing the error you see in image. From as I know ~ I am not sharing anything and it should be creating thread. I am using AHK1_h at this time.

If there is any other information you need, please feel free to ask.


Code: Select all

#include, Gdip.ahk
#include, Vis2.ahk

SetBatchlines, -1
SetWorkingDir %A_ScriptDir%
pToken := Gdip_Startup()

stats := CriticalObject(A_Args[1])
SetTimer, update_stats, 250

    if (!stats["user_pause"]) {
        try {
            WinGet, hwnd, ID, A
            ;pToken := Gdip_Startup()
            bmpHaystack := Gdip_BitmapFromScreen( "hwnd:" hwnd )

            stats["value1"] := OCR( bmpHaystack, , [100, 23, 50, 25] ) + 0
            if !stats["value1"] {
                stats["value1"] := .7

            stats["value2"] := OCR( bmpHaystack, , [100, 42, 50, 25] ) + 0
            if !stats["value2"] {
                stats["value2"] := 90

            ;gdip_Shutdown( pToken )
            ;MsgBox, %difference%
    SetTimer, update_stats, 250

Code: Select all

global stats := CriticalObject( {"value1":.7, "value2":90, "user_pause":1} )
global get_stats_thread := AhkThread( "GetStats.ahk", &stats "", true )
In the main thread ~ I also have it searching for images as well whenever a key is press. I know in the past I had issue with pToken := Gdip_Startup() and ;gdip_Shutdown( pToken ) that would crash the program with no error. While here I am just trying to play around with that - I wonder if that is what is going on still. Is Gdip M-thread safe? Are there any workarounds? I see a lot of random threads here looks like it should work M-threaded, but I am not sure at this point.
Posts: 2255
Joined: 29 Sep 2013, 18:35

Re: Authotkey and Threading

Post by HotKeyIt » 31 Dec 2020, 09:19

AFAIK there was a non critical issue with GDIP library, try using #WarnContinuableException, Off in GetStats.ahk
Post Reply

Return to “AutoHotkey_H”