Porting Gdip to 2.0-a129

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Frizelbliz
Posts: 1
Joined: 20 Mar 2021, 23:34

Porting Gdip to 2.0-a129

Post by Frizelbliz » 22 Mar 2021, 02:03

I started extensively using AutoHotkey some weeks ago and start getting pretty secure with it. I once had to decide between AutoHotkey_L 1.1 and AutoHotkey v2 and never had any problems with my decision for the latter, but I have some trouble since trying to include a library.

Code: Select all

#Warn All, StdOut
#SingleInstance Prompt
; https://github.com/mmikeww/AHKv2-Gdip/blob/master/Gdip_All.ahk
#Include ../lib/gdip.ahk2
Using this repository of Gdip, I fail to port the included code to AutoHotkey v2 2.0-a129.

Plain include returns this:

Code: Select all

E:/Portables/autohotkey2/2.0-a129/AutoHotkeyU64.exe /Debug=localhost:9002 /ErrorStdOut e:\AutoHotkey\timers\timers.ahk2
e:\AutoHotkey\lib\gdip.ahk2:410 : ==> Missing comma
     Specifically: CreateRectF(ByRef RectF, x, y, w, h)
AutoHotkey closed for the following exit code: 2
Replaced ByRef by &.

Now it returns this:

Code: Select all

E:/Portables/autohotkey2/2.0-a129/AutoHotkeyU64.exe /Debug=localhost:9002 /ErrorStdOut e:\AutoHotkey\timers\timers.ahk2
e:\AutoHotkey\lib\gdip.ahk2:1769 : ==> Warning: This local variable has the same name as a global variable.
     Specifically: Format  (in function Gdip_GetImagePixelFormat)
e:\AutoHotkey\lib\gdip.ahk2:3001 : ==> Warning: This local variable has the same name as a global variable.
     Specifically: String  (in function StrGetB)
e:\AutoHotkey\lib\gdip.ahk2:86 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:412 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:431 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:447 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:463 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:486 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:560 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:567 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:797 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local FileInfo
e:\AutoHotkey\lib\gdip.ahk2:798 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local FileInfo
e:\AutoHotkey\lib\gdip.ahk2:799 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local FileInfo
e:\AutoHotkey\lib\gdip.ahk2:835 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1070 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1162 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1288 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1425 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1595 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1600 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:1619 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1638 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1655 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:1658 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1660 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1661 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1837 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Extension
e:\AutoHotkey\lib\gdip.ahk2:1838 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Extension
e:\AutoHotkey\lib\gdip.ahk2:1843 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1877 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1890 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:1892 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1927 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1948 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1964 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:1967 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2011 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2021 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2024 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2103 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2361 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2362 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local NoWrap
e:\AutoHotkey\lib\gdip.ahk2:2397 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local NoWrap
e:\AutoHotkey\lib\gdip.ahk2:2403 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local RC
e:\AutoHotkey\lib\gdip.ahk2:2406 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local RC
e:\AutoHotkey\lib\gdip.ahk2:2408 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2412 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2412 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2414 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2414 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2416 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2416 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local vPos
e:\AutoHotkey\lib\gdip.ahk2:2419 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local RC
e:\AutoHotkey\lib\gdip.ahk2:2420 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local RC
e:\AutoHotkey\lib\gdip.ahk2:2424 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local RC
e:\AutoHotkey\lib\gdip.ahk2:2440 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:2443 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2447 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:2463 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2464 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:2467 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2473 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:2528 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:2531 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2536 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:2586 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2656 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2796 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2890 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2895 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2898 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Width
e:\AutoHotkey\lib\gdip.ahk2:2898 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Height
e:\AutoHotkey\lib\gdip.ahk2:2900 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Width
e:\AutoHotkey\lib\gdip.ahk2:2900 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Height
e:\AutoHotkey\lib\gdip.ahk2:2902 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Width
e:\AutoHotkey\lib\gdip.ahk2:2902 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Height
e:\AutoHotkey\lib\gdip.ahk2:2905 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Width
e:\AutoHotkey\lib\gdip.ahk2:2905 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Height
e:\AutoHotkey\lib\gdip.ahk2:2905 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Stride1
e:\AutoHotkey\lib\gdip.ahk2:2905 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Scan01
e:\AutoHotkey\lib\gdip.ahk2:2905 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local BitmapData1
e:\AutoHotkey\lib\gdip.ahk2:2906 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Width
e:\AutoHotkey\lib\gdip.ahk2:2906 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Height
e:\AutoHotkey\lib\gdip.ahk2:2906 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Stride2
e:\AutoHotkey\lib\gdip.ahk2:2906 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Scan02
e:\AutoHotkey\lib\gdip.ahk2:2906 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local BitmapData2
e:\AutoHotkey\lib\gdip.ahk2:2911 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Scan01
e:\AutoHotkey\lib\gdip.ahk2:2911 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Scan02
e:\AutoHotkey\lib\gdip.ahk2:2911 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Width
e:\AutoHotkey\lib\gdip.ahk2:2911 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Height
e:\AutoHotkey\lib\gdip.ahk2:2911 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local Stride1
e:\AutoHotkey\lib\gdip.ahk2:2913 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local BitmapData1
e:\AutoHotkey\lib\gdip.ahk2:2913 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local BitmapData2
e:\AutoHotkey\lib\gdip.ahk2:2987 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:2993 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:3000 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:3126 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:3146 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:3154 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local VarSetCapacity
e:\AutoHotkey\lib\gdip.ahk2:3154 : ==> Warning: This variable appears to never be assigned a value.
     Specifically: local A_IsUnicode
e:\AutoHotkey\lib\gdip.ahk2:1648 : ==> Too few parameters passed to function.
     Specifically: NumPut
AutoHotkey closed for the following exit code: 2
This is the referenced code section of the error:

Code: Select all

Loop %N%
{
	elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
	if (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6)
	{
		_p := elem+&EncoderParameters-pad-4
		NumPut(Quality, NumGet(NumPut(4, NumPut(1, _p+0)+20, "UInt")), "UInt")
		break
	}
}
And I don't know what to try now. This section is too complex for me to edit. I don't even know why the NumPut call is not valid.

Can you help me please?

lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Porting Gdip to 2.0-a129

Post by lexikos » 23 Mar 2021, 04:19

You can compare the documentation between v1 and v2 for obvious differences, or search in v2-changes.
v1: NumPut(Number, Target, Type)
v2: NumPut(Type, Number, Target)

The warnings are due to some obvious differences between v1 and v2, and some less obvious differences. Searching v2-changes for "A_IsUnicode" and "VarSetCapacity" will give you basic details about those two.

I would generally not enable the LocalSameAsGlobal warning. Use of "Format" as a local variable name generates this warning due to other changes to the language (see "Names" in v2-changes) and "String" is a new predefined class. In this case they were probably intended to be local variables (but I haven't checked the script).

"This variable appears to never be assigned a value." is what you get when you refer to a variable or function for which no direct assignment (or &var) can be seen in the script. (Speaking of &var, if the script used that operator in v1, you'd better search for and read about "&var" in v2-changes.) VarSetCapacity() generates this warning because VarSetCapacity is a variable reference in this context (even if a function with that name is defined; in that case the variable contains a reference to the function).

There could be a number of reasons to get these warnings about names that aren't used by built-ins:
  • Words in v1 unquoted strings which are now interpreted as variables.
  • Changes in variable scope (see "Scope" in v2-changes).
  • Use of dynamic variables (so the variables will be assigned, but the program cannot confirm this at load-time).
  • Errors in the original script (where variables actually were never assigned, and were just blank in v1).
  • Probably more.
Replaced ByRef by &.
Be aware that you must also use & when calling the function.

iseahound
Posts: 1446
Joined: 13 Aug 2016, 21:04
Contact:

Re: Porting Gdip to 2.0-a129

Post by iseahound » 30 Mar 2021, 13:18

The specific code snippet can be found in a v2-122 comparable version here.
https://github.com/iseahound/ImagePut/blob/291620a77bfa80c396556e21b527b1b05c8813dd/v2/ImagePut.ahk#L1532

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Porting Gdip to 2.0-a129

Post by TheArkive » 30 Mar 2021, 16:41

I will be posting a transcription of the old Gdip_all.ahk soon (for a129).

I'm actually working on a similar lib that uses all GDI and blitting.

Post Reply

Return to “Ask for Help (v2)”