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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SteaIthe
Posts: 10
Joined: 03 Jan 2019, 18:55

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

22 Jan 2019, 03:39

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)
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

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

22 Jan 2019, 03:51

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.
Recommends AHK Studio
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

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

22 Jan 2019, 04:06

it can be done, but u need to use ahk_h.
if u check errorlevel ull see it fails with 0xc0000005 access violation
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

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

22 Jan 2019, 04:10

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.
Recommends AHK Studio
SteaIthe
Posts: 10
Joined: 03 Jan 2019, 18:55

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

22 Jan 2019, 09:07

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
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

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

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
Recommends AHK Studio
SteaIthe
Posts: 10
Joined: 03 Jan 2019, 18:55

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

22 Jan 2019, 09:26

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, rc76 and 207 guests