GDI+ standard library 1.45 by tic

Post your working scripts, libraries and tools for AHK v1.1 and older
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

16 Nov 2016, 20:05

just me wrote:

Code: Select all

If Var Is %Integer%
  • v1:
    variable reference: Integer -> "Integer"
  • v2:
    double variable reference: Integer -> "Integer" -> "Integer"
hrmm

then is a double deref even necessary?

Code: Select all

IsInteger(Var) {
   Static Integer := "Integer"
   If Var Is Integer
      Return True
   Return False
}
that seems to work

v1: normal if is command
v2: single var deref in if-expression

just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: GDI+ standard library 1.45 by tic

17 Nov 2016, 03:27

Code: Select all

IsInteger(Var) {
   Static Integer := "Integer"
   If Var Is Integer
      Return True
   Return False
}
Yes, I already did it this way, but I didn't remember.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

17 Nov 2016, 11:58

can anyone get Gdip.Tutorial.11 working on AHK 1.1?

it works fine for me using AHK Basic 1.0

looks like this is the relevant section in Gdip.ahk thats failing. maybe something with these DllCalls? Gdip_All fails too

Code: Select all

Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
{
	if !BRAFromMemIn
		return -1
	Loop, Parse, BRAFromMemIn, `n
	{
		if (A_Index = 1)
		{
			StringSplit, Header, A_LoopField, |
			if (Header0 != 4 || Header2 != "BRA!")
				return -2
		}
		else if (A_Index = 2)
		{
			StringSplit, Info, A_LoopField, |
			if (Info0 != 3)
				return -3
		}
		else
			break
	}
	if !Alternate
		StringReplace, File, File, \, \\, All
	RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
	if !FileInfo
		return -4
;msgbox, %FileInfo2%`n%info2%`n%fileinfo1%                      ;// this shows the same in 1.1 and 1.0
	hData := DllCall("GlobalAlloc", "uint", 2, "uint", FileInfo2)
	pData := DllCall("GlobalLock", "uint", hData)
	DllCall("RtlMoveMemory", "uint", pData, "uint", &BRAFromMemIn+Info2+FileInfo1, "uint", FileInfo2)
	DllCall("GlobalUnlock", "uint", hData)
	DllCall("ole32\CreateStreamOnHGlobal", "uint", hData, "int", 1, "uint*", pStream)
	DllCall("gdiplus\GdipCreateBitmapFromStream", "uint", pStream, "uint*", pBitmap)
	DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
	return pBitmap
}

the msgbox works so i think it must be something on the lines below it

looks like its an ANSI/Unicode thing. it works on AHK 1.1 ANSI
Last edited by guest3456 on 17 Nov 2016, 21:34, edited 2 times in total.

Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: GDI+ standard library 1.45 by tic

17 Nov 2016, 13:02

guest3456 wrote:I have updated Gdip_All.ahk to support AHK v2
These kinds of user efforts are really important if there is going to be a shift to v2 :thumbup:
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

17 Nov 2016, 13:08

Helgef wrote:
guest3456 wrote:I have updated Gdip_All.ahk to support AHK v2
These kinds of user efforts are really important if there is going to be a shift to v2 :thumbup:
yep i think we need to get v2 to beta asap. HotKeyIt says hes been using it for years.

but, i'm trying to run the Gdip.Tutorial examples and while they are working somewhat on v2, i can't seem to exit the example scripts :crazy:

guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

17 Nov 2016, 22:57

I have updated Gdip_All.ahk again to v1.49. Its now backwards compatible with both AHK v1.1 and AHK v2

I've included all of the Gdip tutorial examples (except one) so you can test and they now work for both AHK versions.

See the changes and get it here:

https://github.com/mmikeww/AHKv2-Gdip

guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

20 Nov 2016, 11:54

backwards compatible Gdip_All.ahk updated again to v1.50

'just me' has fixed the Gdip_BitmapFromBRA() func as well as example Tutorial.11

https://github.com/mmikeww/AHKv2-Gdip

ahk_learning
Posts: 2
Joined: 22 Dec 2016, 02:26

Re: GDI+ standard library 1.45 by tic

22 Dec 2016, 02:40

Hi,

Im trying to use GDIP library to capture Nox App Player's window but the result are not expected, it have a blank window instead of the content like image below:
Image

the code:

Code: Select all

SetBatchLines -1

#include Gdip.ahk

token := Gdip_Startup()
scrshot:=A_Desktop . "\ScrShot\" . A_Now . ".png"
WinGet, nox,, Nox App Player
;~ bitmap:=Gdip_BitmapFromScreen("hwnd:" . nox)
bitmap:=Gdip_BitmapFromHWND(nox)
Gdip_SaveBitmapToFile(bitmap, scrshot, 100)
GDIP_DisposeImage(bitmap)
GDIP_Shutdown(token)

return
Any suggestion are appreciate.

Thanks
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

22 Dec 2016, 10:15

some apps/games just won't let you capture their contents

guest_only today

Re: GDI+ standard library 1.45 by tic

23 Dec 2016, 12:27

Can you take a standard screenshot,if yes you can try use gdip command using the raster parameter.
ahk_learning
Posts: 2
Joined: 22 Dec 2016, 02:26

Re: GDI+ standard library 1.45 by tic

26 Dec 2016, 05:22

guest_only today wrote:Can you take a standard screenshot,if yes you can try use gdip command using the raster parameter.
Yep, it runs ok with standard screenshot or full screen. I also try the raster param but no luck :headwall:
guest_on_tuesday

Re: GDI+ standard library 1.45 by tic

27 Dec 2016, 08:19

Do not know if it helps you but if i need a similar screengrab as the standard one i iuse:

Code: Select all

raster:=0x40000000 + 0x00CC0020
pBitmap:=Gdip_BitmapFromScreen(Screen,raster)
Best of luck :)
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

27 Dec 2016, 09:26

^ should that use bitwise or | instead of add + ?

guest__today

Re: GDI+ standard library 1.45 by tic

28 Dec 2016, 03:33

Yes it should be "|" but here the result is the same :)
Acecool
Posts: 38
Joined: 10 Jan 2016, 18:25
Contact:

Re: GDI+ standard library 1.45 by tic

28 Dec 2016, 08:54

ahk_learning wrote:Hi,

Im trying to use GDIP library to capture Nox App Player's window but the result are not expected, it have a blank window instead of the content like image below:
Image

the code:

Code: Select all

SetBatchLines -1

#include Gdip.ahk

token := Gdip_Startup()
scrshot:=A_Desktop . "\ScrShot\" . A_Now . ".png"
WinGet, nox,, Nox App Player
;~ bitmap:=Gdip_BitmapFromScreen("hwnd:" . nox)
bitmap:=Gdip_BitmapFromHWND(nox)
Gdip_SaveBitmapToFile(bitmap, scrshot, 100)
GDIP_DisposeImage(bitmap)
GDIP_Shutdown(token)

return
Any suggestion are appreciate.

Thanks

I have an example Capture Screenshot of Active Window included in my AHK Framework ( uses and includes GDip also includes GDip_All ) and I haven't had any issues with it even though I have had issues with PrintScreen and various utilities... Give it a go and if it works, all of the code is mostly captured in the processes\ screenshot file ( plus 1 or 2 functions in functions\ and I have started using libraries so string.safe in classes\ )... But you will likely not need to go that far: https://bitbucket.org/Acecool/acecoolah ... k/overview

If you want to install it, drop it into Dropbox\AcecoolAHK_Framework and run _assets\_setup\setup.bat in admin mode and confirm the folder paths ( if wrong you'll need to edit the bat; I will release a new setup bat file where it is more user-friendly or as AHK because AHK needs to be installed prior to installing this ) and press enter which will generate a replacement Documents\AutoHotkey.ahk file ( which launches DropBox\AcecoolAHK_Framework\framework_launcher.ahk )[ note: if one exists it'll be backed up ] and it will symbolically link AHK_INSTALL_PATH\Lib to AcecoolAHK_Framework\libraries\ ( it will rename the original if it exists )... Then run AutoHotkey.exe and for the first launch you won't get a notification to rebuild the inclusion list ( for if you drag and drag new files in; if you simply edit existing files then you can Reload This Script from tray and it won't pop up any nags. For second launch and further it will ask you if you want to skip recreating the inclusion list or not; in most cases select Yes ( default ) which runs the framework and no will rebuild the inclusion list...

Alt + F12 is the hotkey..

I decided to download Nox App Player to give it a shot to save you some time and because it looks interesting... I'll give it a shot and post the result...
Image
Image
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

28 Dec 2016, 09:57

Acecool wrote: I have an example Capture Screenshot of Active Window included in my AHK Framework

all of the code is mostly captured in the processes\ screenshot file ( plus 1 or 2 functions in functions\ )
uh, i think some code is missing:

https://bitbucket.org/Acecool/acecoolah ... ew-default

Acecool
Posts: 38
Joined: 10 Jan 2016, 18:25
Contact:

Re: GDI+ standard library 1.45 by tic

28 Dec 2016, 11:18

That is one of the functions for it.. It is here:

https://bitbucket.org/Acecool/acecoolah ... ew-default

And what it uses:

HotKey: https://bitbucket.org/Acecool/acecoolah ... lt_f12.ahk

Libraries / Classes:
For string.safe: https://bitbucket.org/Acecool/acecoolah ... string.ahk
For reading and saving settings to config.ini: https://bitbucket.org/Acecool/acecoolah ... ration.ahk

Functions:
https://bitbucket.org/Acecool/acecoolah ... enshot.ahk
https://bitbucket.org/Acecool/acecoolah ... otName.ahk
https://bitbucket.org/Acecool/acecoolah ... rayTip.ahk


Most of this can be ignored - the important file is the processes\ file


And I just noticed something! I seem to have altered my screenshot system away from Gdip ( likely because of a similar issue ) to using NirCMD - run "_assets\bin\NirCmd_x64\nircmd.exe" savescreenshotwin %_path%%_name%

but I didn't remove some of the Gdip calls in Screenshot function likely because I was debugging or something.... My bad.. I'll look into GDip again, but I would also say take a look at NirCMD because it can handle a lot of different and useful tasks ( I also use it for my audio switcher / cycler script ) much quicker than AHK can on its own and without using hacky workarounds ( ie with AHK, from what I've gathered, to change audio device it has to open the menu, and use mouse / keyboard actions to do and can take seconds whereas with NirCMD the same task is done in microseconds and doesn't need to open any new windows which can cause other issues )..

I apologize - I have been reorganizing and cleaning things up ( and functions that aren't used in more than one spot go into their primary script so Screenshot and all will go back into the processes\ file ) but I'll see about adding a GDip example that hopefully also works...
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

28 Dec 2016, 11:45

^ right, so you're not even using GDIP, so this is all pointless and in the wrong thread

Acecool
Posts: 38
Joined: 10 Jan 2016, 18:25
Contact:

Re: GDI+ standard library 1.45 by tic

28 Dec 2016, 11:59

As I mentioned I forgot that I switched over but I'll do some digging.. It is difficult to keep track of things when you can only process a 40 hour "work week" load / tasks every 160 to 240 + days.
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
buliasz
Posts: 26
Joined: 10 Oct 2016, 14:31
Contact:

Re: GDI+ standard library 1.45 by tic

25 Jan 2017, 15:27

In case someone needs it, I've modified Gdip_All.ahk of mmikeww (guest3456) which work with AHK 2.0+ also. I made one bugfix and made additional little changes, so that it can now be used with the "#Warn All" flag enabled.
Surely there are more changes needed for "#Warn All", but they appear only when you use a particular function. The ones I used are working now.
You can get it here.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: gwarble and 118 guests