Page 1 of 1

Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 03:39
by SteaIthe
I am trying to use gdip to create a pbitmap from an area of the screen and then use Gdip_SetPixel from a different script to change pixel colors of it in an attempt to speed up the process of helping the first script change all the colors of a large bitmap by making it multithreaded.


This does not work for some reason:

;script 1
screen51=50|50|20|20
raster := 0x40000000 + 0x00CC0020
pToken := Gdip_StartUp()
pBitmap := Gdip_BitmapFromScreen(screen51,raster)
run, 2.ahk %pBitmap%
sleep 500 ;time to allow second script to change pixel color
Gdip_SaveBitmapToFile(pBitmap,"test.bmp")
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
run, test.bmp


;script 2
pBitmap=%1%
x=10
y=10
color=0xffffffff
Gdip_SetPixel(pBitmap, x, y, color)

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 03:51
by nnnik
That won't work. A pBitmap is stored inside a scripts memory accessing it from outside might be possible but is definitivrly slower than doing it from the same script.

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 04:06
by swagfag
it can be done, but u need to use ahk_h.
if u check errorlevel ull see it fails with 0xc0000005 access violation

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 04:10
by nnnik
That would also involve using the same script but real multi-threading.
regardless of what you are doing there probably is a faster way of what you are doing without using multi-threading.

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 08:52
by malcev

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 09:07
by SteaIthe
Thanks a lot for replies.I had no idea multi threading was possible without multiple scripts.I will definitely have to do some research on how to do it and if it will work with ahk L though since my current code is written in and working with L

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 09:19
by nnnik
AHK_H is n extension of AHK_L almost all scripts will work for AHK_H if they work for _L

Re: Access a pbitmap from a different script than the one that created it

Posted: 22 Jan 2019, 09:26
by SteaIthe
nnnik wrote:
22 Jan 2019, 09:19
AHK_H is n extension of AHK_L almost all scripts will work for AHK_H if they work for _L
Nice!.Thank you sir