[Guide] Compiling Ahk_h's source step by step Topic is solved

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Guide] Compiling Ahk_h's source step by step

Post by HotKeyIt » 26 May 2020, 18:38

See Escape sequences, since backslash accepts \n + \nn + \nnn, \03 is considered one character, instead you need to use \000 if following char is a number.
I will update source to use \000 by default so this won't happen to someone else.

uhwok3n
Posts: 30
Joined: 15 May 2020, 23:08

Re: [Guide] Compiling Ahk_h's source step by step

Post by uhwok3n » 24 Jun 2020, 00:25

@HotKeyIt

Thank you for taking the time to respond to this, Can I replace all `\0`characters with `\000`manually? Do I have to add anything particular for it to create the correct password regardless of numbers, letters or unicode characters?
On another note, I was hoping you could provide some insight into how to generate a random password. I'm trying to create functions that generate random zeros and points for random characters

Code: Select all

passwordString = ""
charTrackerArray = []
addRandomChar() {
}
addRandomZeros() {
}
createPW_String {
	for (int n=0; n<20; n++) {
		tempString = ""
		addRandomZeros()
		addRandomChar()
		charTrackerArray.push(tempString.length() - 2)
		passwordString += tempString
	}
}
	
}
I want to:
1) add a function that adds random amounts of "\0" to a global string(passwordString) and places random letters/numbers after the 0's - keeping track of the places of where they were added in string.
2) Replace "0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" with password string mentioned above
3) use charTrackerArray array in place of [i*number] - kept track of where random letters are added... i.e[1,3,2,5,4,3]

effectively replacing this:

Code: Select all

pw[i] = pwd == g_default_pwd ? (TCHAR) _T("0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")[i*2] : (TCHAR)*pwd[i];
with this:

Code: Select all

pw[i] = pwd == g_default_pwd ? (TCHAR) _T(passwordString)[i*charTrackerArray[i+1]] : (TCHAR)*pwd[i];
I would like it to output the password in a text file as opposed to a warning. I'm not well versed in C++ but I have attempted to create something mentioned above to no avail, if you could provide your expertise I'm sure many would find this extremely useful. It would also help complete this guide.
Thank you HotKeyIt for all of your hard work, AHK_H is honestly the best.

joekingcool
Posts: 238
Joined: 14 Dec 2019, 20:21

Re: [Guide] Compiling Ahk_h's source step by step

Post by joekingcool » 27 Dec 2020, 16:48

is there a way we could write a batch to make the selections above , as to what needs installed from visual studios, and the selections for whats included in the build. incase we have to reinstall visual c again. im googling with limited info.

User avatar
manehscripts
Posts: 126
Joined: 03 May 2019, 16:10

Re: [Guide] Compiling Ahk_h's source step by step

Post by manehscripts » 04 Mar 2021, 18:07

Hello,

I have a problem about the Gdip_SaveBitmapToFile() function that's not working properly when compiling ahk_h source
No errors are displayed in the compilation process. However, the use of the official ahk_h release works, anyone can tell me if I need to add a library when compiling?

Just one more detail: The function is included in the Lib folders, I ran CleanUpAndPack.exe after compilation and the error present is -3 = Could not find matching encoder for specified file format

Function..

Code: Select all

;#####################################################################################

; Function:		  Gdip_SaveBitmapToFile
; Description:	  Saves a bitmap to a file in any supported format onto disk
;
; pBitmap			 Pointer to a bitmap
; sOutput			 The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
; Quality			 If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
; toBase64			If set to 1, instead of saving the file to disk, the function will return on success the base64 data
;						A "base64" string is the binary image data encoded into text using only 64 characters.
;						To convert it back into an image use: Gdip_BitmapFromBase64()
;
; return			  If the function succeeds, the return value is zero, otherwise:
;					  -1 = Extension supplied is not a supported file format
;					  -2 = Could not get a list of encoders on system
;					  -3 = Could not find matching encoder for specified file format
;					  -4 = Could not get WideChar name of output file
;					  -5 = Could not save file to disk
;					  -6 = Could not save image to stream [for base64]
;					  -7 = Could not convert to base64
;
; notes				This function will use the extension supplied from the sOutput parameter to determine the output format

Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality:=75, toBase64:=0) {
	Static Ptr := "UPtr"
	nCount := 0
	nSize := 0
	_p := 0

	SplitPath sOutput,,, Extension
	If !RegExMatch(Extension, "^(?i:BMP|DIB|RLE|JPG|JPEG|JPE|JFIF|GIF|TIF|TIFF|PNG)$")
		Return -1

	Extension := "." Extension
	DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
	VarSetCapacity(ci, nSize)
	DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
	If !(nCount && nSize)
		Return -2

	If (A_IsUnicode)
	{
		StrGet_Name := "StrGet"
		N := (A_AhkVersion < 2) ? nCount : "nCount"
		Loop %N%
		{
			sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16")
			If !InStr(sString, "*" Extension)
				Continue

			pCodec := &ci+idx
			Break
		}
	} Else
	{
		N := (A_AhkVersion < 2) ? nCount : "nCount"
		Loop %N%
		{
			Location := NumGet(ci, 76*(A_Index-1)+44)
			nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int",  0, "uint", 0, "uint", 0)
			VarSetCapacity(sString, nSize)
			DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
			If !InStr(sString, "*" Extension)
				Continue

			pCodec := &ci+76*(A_Index-1)
			Break
		}
	}

	If !pCodec
		Return -3

	If (Quality!=75)
	{
		Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
		If (quality>90 && toBase64=1)
			Quality := 90

		If RegExMatch(Extension, "^\.(?i:JPG|JPEG|JPE|JFIF)$")
		{
			DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize)
			VarSetCapacity(EncoderParameters, nSize, 0)
			DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters)
			nCount := NumGet(EncoderParameters, "UInt")
			N := (A_AhkVersion < 2) ? nCount : "nCount"
			Loop %N%
			{
				elem := (24+A_PtrSize)*(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
				}
			}
		}
	}

	If (toBase64=1)
	{
		; part of the function extracted from ImagePut by iseahound
		; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=76301&sid=bfb7c648736849c3c53f08ea6b0b1309
		DllCall("ole32\CreateStreamOnHGlobal", "ptr",0, "int",true, "ptr*",pStream)
		_E := DllCall("gdiplus\GdipSaveImageToStream", "ptr",pBitmap, "ptr",pStream, "ptr",pCodec, "uint", _p ? _p : 0)
		If _E
			Return -6

		DllCall("ole32\GetHGlobalFromStream", "ptr",pStream, "uint*",hData)
		pData := DllCall("GlobalLock", "ptr",hData, "ptr")
		nSize := DllCall("GlobalSize", "uint",pData)

		VarSetCapacity(bin, nSize, 0)
		DllCall("RtlMoveMemory", "ptr",&bin, "ptr",pData, "uptr",nSize)
		DllCall("GlobalUnlock", "ptr",hData)
		ObjRelease(pStream)
		DllCall("GlobalFree", "ptr",hData)

		; Using CryptBinaryToStringA saves about 2MB in memory.
		DllCall("Crypt32.dll\CryptBinaryToStringA", "ptr",&bin, "uint",nSize, "uint",0x40000001, "ptr",0, "uint*",base64Length)
		VarSetCapacity(base64, base64Length, 0)
		_E := DllCall("Crypt32.dll\CryptBinaryToStringA", "ptr",&bin, "uint",nSize, "uint",0x40000001, "ptr",&base64, "uint*",base64Length)
		If !_E
			Return -7

		VarSetCapacity(bin, 0)
		Return StrGet(&base64, base64Length, "CP0")
	}

	_E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, "WStr", sOutput, Ptr, pCodec, "uint", _p ? _p : 0)
	Return _E ? -5 : 0
}
-----------------------------------------------------------
Stop to think, shut up to resist, and act to win!

thanhkiem
Posts: 7
Joined: 23 Nov 2021, 23:20

Re: [Guide] Compiling Ahk_h's source step by step

Post by thanhkiem » 10 Apr 2022, 02:09

I had error when compile.

Code: Select all

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): error MSB8020: The build tools for v142 (Platform Toolset = 'v142') cannot be found. To build using the v142 build tools, please install v142 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
How can i sovle this ?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: [Guide] Compiling Ahk_h's source step by step

Post by swagfag » 04 Aug 2022, 16:47

thanhkiem wrote:
10 Apr 2022, 02:09
The build tools for v142 (Platform Toolset = 'v142') cannot be found. To build using the v142 build tools, please install v142 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
the error literally tells u what to do. did u even bother reading it?

either install v142 (hint: those are VS 2019's buildtools) from the VS Installer > Individual Components
or change them to whatever older ones u got installed on ur computer(right click Project > Properties > General > Platform Toolset > dropdownmenu) but compilation may fail either way if the older ones arent supported

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: [Guide] Compiling Ahk_h's source step by step

Post by ibieel » 26 Aug 2022, 02:12

I'm having some problems completing step 1.3

Can someone help me?
image.png
image.png (56.84 KiB) Viewed 4107 times

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: [Guide] Compiling Ahk_h's source step by step

Post by swagfag » 26 Aug 2022, 02:40

literally read the post above u

bapl
Posts: 119
Joined: 17 Apr 2021, 00:24

Re: [Guide] Compiling Ahk_h's source step by step

Post by bapl » 16 Sep 2022, 03:56

Hello!
The latest release of the source code (February 9, 2022) throws an error that I have no idea how to solve.

Code: Select all

Build started...
1>------ Build started: Project: lib_pcre, Configuration: MT_Release x64 ------
2>------ Build started: Project: lib_double, Configuration: MT_Release x64 ------
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(519,5): warning MSB8004: Intermediate Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Intermediate Directory.
2>bignum-dtoa.cc
1>pcre16_chartables.c
2>bignum.cc
1>pcre16_compile.c
2>cached-powers.cc
1>pcre16_config.c
1>pcre16_exec.c
2>diy-fp.cc
2>double-conversion.cc
1>pcre16_fullinfo.c
1>pcre16_get.c
2>fast-dtoa.cc
1>pcre16_globals.c
2>fixed-dtoa.cc
1>pcre16_jit_compile.c
2>strtod.cc
1>pcre16_newline.c
2>Generating Code...
1>pcre16_ord2utf16.c
1>pcre16_refcount.c
1>pcre16_string_utils.c
1>pcre16_study.c
1>pcre16_tables.c
1>pcre16_ucd.c
1>pcre16_valid_utf16.c
1>pcre16_version.c
1>pcre16_xclass.c
1>lib_pcre.vcxproj -> D:\bapl\AHK_H\AHKVersion\ahkdll-alpha\temp\x64\MT_Release\lib_pcre.lib
2>lib_double.vcxproj -> D:\bapl\AHK_H\AHKVersion\ahkdll-alpha\temp\x64\MT_Release\lib_double.lib
2>Done building project "lib_double.vcxproj".
3>------ Build started: Project: AutoHotkey2, Configuration: MT_ReleaseDll x64 ------
3>Performing Custom Build Tools
3>Microsoft (R) Macro Assembler (x64) Version 14.33.31629.0
3>Copyright (C) Microsoft Corporation.  All rights reserved.
3>
3> Assembling: D:\bapl\AHK_H\AHKVersion\ahkdll-alpha\source\libx64call\x64call.asm
3>Performing Custom Build Tools
3>Microsoft (R) Macro Assembler (x64) Version 14.33.31629.0
3>Copyright (C) Microsoft Corporation.  All rights reserved.
3>
3> Assembling: D:\bapl\AHK_H\AHKVersion\ahkdll-alpha\source\libx64call\x64stub.asm
3>pch.cpp
3>application.cpp
3>AutoHotkey2.cpp
3>clipboard.cpp
3>COMServer.cpp
3>Debugger.cpp
3>dllmain.cpp
3>exports.cpp
3>globaldata.cpp
3>hook.cpp
3>hotkey.cpp
3>input_object.cpp
3>keyboard_mouse.cpp
3>LiteZip.cpp
3>lowlevelbif.cpp
3>MemoryModule.cpp
3>MinHook.cpp
3>os_version.cpp
3>script.cpp
3>script2.cpp
3>script_autoit.cpp
3>script_com.cpp
3>script_expression.cpp
3>script_gui.cpp
3>script_menu.cpp
3>script_object.cpp
3>script_object_bif.cpp
3>script_registry.cpp
3>script_struct.cpp
3>SimpleHeap.cpp
3>StringConv.cpp
3>TextIO.cpp
3>util.cpp
3>var.cpp
3>window.cpp
3>WinGroup.cpp
3>xdlldata.c
3>RC : fatal error RC1110: could not open source\resources\AutoHotkey2.rc
3>
3>Done building project "AutoHotkey2.vcxproj" -- FAILED.
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What is curious: The project asks for files that are not included in Git: https://github.com/HotKeyIt/ahkdll/tree/alpha

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

Re: [Guide] Compiling Ahk_h's source step by step

Post by lexikos » 04 Dec 2022, 22:57

I opened an Issue on GitHub for the missing file back in April. Doesn't seem like HotKetIt is around to fix it.

SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: [Guide] Compiling Ahk_h's source step by step

Post by SOTE » 02 Feb 2023, 06:49

Maybe people might want to check out- https://github.com/thqby/AutoHotkey_H (which is an active AHK_H fork) or message thqby. Source and zip for thqby fork (https://github.com/thqby/AutoHotkey_H/releases). If/when HotKeyIt comes back, possibly he and thqby can collaborate some more, as they did before.
Last edited by SOTE on 15 Jan 2024, 06:28, edited 1 time in total.

serg
Posts: 56
Joined: 21 Mar 2015, 05:33

Re: [Guide] Compiling Ahk_h's source step by step

Post by serg » 10 Feb 2023, 13:23

I just want to say thanks to @kyuuuri for this very helpful guide, and to @HotKeyIt for such a wonderful tool as AHK_H/compiler!
Thanks!!! :thumbup:

PS. I compiled in VS 2019 and it works as expected.

Post Reply

Return to “AutoHotkey_H”