Upcoming Ahk2Exe Changes (2024)

Post your working scripts, libraries and tools for AHK v1.1 and older
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 26 Jul 2021, 19:00

Fixed download link in first post.

See this post for download details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 26 Jul 2021, 23:27

Updated the first post to include a description of the Base file search algorithm used.

See this post for details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Upcoming Ahk2Exe Changes (2021)

Post by TheArkive » 03 Aug 2021, 06:32

@TAC109

Just wanted to report a beautiful success with compiling my first AHK v2 script in beta1.

I'll keep testing and post if I find something wonky.

EDIT: I like the interface update :D very functional.
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 03 Aug 2021, 16:22

@TheArkive
Cheers!
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Upcoming Ahk2Exe Changes (2021)

Post by joedf » 29 Aug 2021, 12:17

@lexikos just to confirm, does v1.1.33.10 include the latest Ahk2Exe or would it be the next release? I remember something about the AHK-release scripts auto pull and build the latest master branch. If so, then we have the new /silent switch in, since about 2 days ago. :think:
https://github.com/AutoHotkey/Ahk2Exe/pull/77

If so, maybe we can update the docs to include it? @TAC109 @Ragnar
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 29 Aug 2021, 16:09

@joedf
Documentation changes are coming :). Although this version is designed to work with AutoHotkey v1.1.34+ it is backwards compatible.

You may notice I included an ability to allow shrinkage of the GUI, which is something you were interested in a while back.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Upcoming Ahk2Exe Changes (2021)

Post by joedf » 29 Aug 2021, 17:39

@TAC109 very neat, that's great to hear! Thanks. :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 29 Aug 2021, 22:18

1.1.33.10, 29 August 2021
  • Added optional '/Silent' parameter to redirect all CLI error messages to stderr or stdout.
  • Added optional '/ResourceID' parameter and ';@Ahk2Exe-ResourceID' compiler directive.
  • Added optional 'Embedded Resource ID' field to the Gui (see 'Embedded Scripts' in the help for more information).
  • Added ability to include additional scripts as separate resources in the generated .exe using the ';@Ahk2Exe-AddResource' compiler directive.
There is no beta for this version. The updated Ahk2Exe is included in the AutoHotkey v1.1.33.10 release. An update to the Help information will follow soon.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Upcoming Ahk2Exe Changes (2021)

Post by TheArkive » 30 Aug 2021, 14:08

Awesome! :thumbsup:
just me
Posts: 9406
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Upcoming Ahk2Exe Changes (2021)

Post by just me » 31 Aug 2021, 04:58

Code: Select all

;@Ahk2Exe-UpdateManifest 0, , , 1
;@Ahk2Exe-UpdateManifest 1, , , 1
Should one or both of the directives enable UIAccess?

If I run the resulting exe i get:
Test_exe.PNG
Test_exe.PNG (4.21 KiB) Viewed 3501 times
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 31 Aug 2021, 16:26

Your executable has to obey the rules for UIAccess. See here for more information.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 08 Sep 2021, 19:28

1.1.34.00_Beta_2, 09 September 2021
  • Make start-up search for qualifying .bin's & .exe's more efficient.
  • Improve CLI error checking and error messages.
See this post for download details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
digidings
Posts: 24
Joined: 22 Jan 2018, 17:04

Re: Upcoming Ahk2Exe Changes (2021)

Post by digidings » 10 Sep 2021, 12:33

RCDATA behavior Change since 1.33.10 breaks existing projects

sadly i can't use the new Ahk2Exe (1.33.10 or 1.1.34.00_Beta_2) with my ahk-projects
where I don't use a flat directory structure, but have e.g. resources in subfolders, such as
Projectdir\MainFile.ahk
+ Icons\*.ico
+ Lib\*.ahk

to prevent a cleanup procedure in the compiled exe for removing embedded/extracted resources on ExitApp:
i use teadrinker's fantastic HBitMapFromResource - method:

Code: Select all

FileInstall, Icons\Sample.ico, % "EmptyVar" := ""
Gui, Add, Picture, x+10, % "HBITMAP: " . HBitMapFromResource("Icons\Sample.ico")

this is now broken.

to reproduce:
run provided script once to 'install' sample.ico and icons\sample2.ico and check the inteded appearance!
compile script with Ahk2Exe < 1.33.10
run compiled script -> appearance of compiled script: as uncompiled script = OK!
examine compiled script with reshacker.exe
RCDATA contains
>AUTOHOTKEY SCRIPT<
SAMPLE.ICO
ICONS\SAMPLE2.ICO

compile script with Ahk2Exe >= 1.33.10
run compiled script -> Sample2.ico won't show up

examine compiled script with reshacker.exe
-> both icons in RCData are stored in the root:
RCDATA contains
>AUTOHOTKEY SCRIPT<
SAMPLE.ICO
SAMPLE2.ICO

ScriptSource:

Code: Select all

#SingleInstance, force
Main:
    SetWorkingDir, % A_ScriptDir
    IconSrcPath := "c:\Windows\System32\OneDrive.ico"

;@Ahk2Exe-IgnoreBegin
    if FileExist(IconSrcPath) {
        if !FileExist("Icons")
            FileCreateDir, Icons

        if !FileExist("Sample.ico")
            FileCopy, % IconSrcPath, Sample.ico

        if !FileExist("Icons\Sample2.ico")
            FileCopy, % IconSrcPath, Icons\Sample2.ico
    } else {
        MsgBox, Change IconSrcPath to a valid one and try again!
        ExitApp
    }
;@Ahk2Exe-IgnoreEnd

    FileInstall, Sample.ico, % "EmptyVar" := ""
    Gui, Add, Text, xm w100, Sample.ico:
    Gui, Add, Picture, x+10, % "HBITMAP: " . HBitMapFromResource("Sample.ico")
    Gui, Add, GroupBox, xm w300 h2

    FileInstall, Icons\Sample2.ico, % "EmptyVar" := ""
    Gui, Add, Text, xm w100, Icons\Sample2.ico:
    Gui, Add, Picture, x+10, % "HBITMAP: " . HBitMapFromResource("Icons\Sample2.ico")
    Gui, Add, GroupBox, xm w300 h2

    ; this would show up in compiled (Ahk2Exe >= 1.33.10) script, but not in uncompiled script:
    ; Gui, Add, Text, xm w100, Sample2.ico:
    ; Gui, Add, Picture, x+10, % "HBITMAP: " . HBitMapFromResource("Sample2.ico")

    Gui Show
    return

GuiClose:
    ExitApp

; HBitMapFromResource (mentioned) from teadrinker: https://www.autohotkey.com/boards/viewtopic.php?t=83589 , second post:
HBitmapFromResource(resName) {
   if !A_IsCompiled
      hBitmap := LoadPicture(resName, "GDI+")
   else {
      hMod := DllCall("GetModuleHandle", "Ptr", 0, "Ptr")
      hRes := DllCall("FindResource", "Ptr", hMod, "Str", resName, "UInt", RT_RCDATA := 10, "Ptr")
      resSize := DllCall("SizeofResource", "Ptr", hMod, "Ptr", hRes)
      hResData := DllCall("LoadResource", "Ptr", hMod, "Ptr", hRes, "Ptr")
      pBuff := DllCall("LockResource", "Ptr", hResData, "Ptr")
      pStream := DllCall("Shlwapi\SHCreateMemStream", "Ptr", pBuff, "UInt", resSize)

      Gdip := new GDIplus
      pBitmap := Gdip.CreateBitmapFromStream(pStream)
      hBitmap := Gdip.CreateHBITMAPFromBitmap(pBitmap)
      Gdip.DisposeImage(pBitmap)
      ObjRelease(pStream)
   }
   Return hBitmap
}

class GDIplus {
   __New() {
      if !DllCall("GetModuleHandle", "Str", "gdiplus", "Ptr")
         DllCall("LoadLibrary", "Str", "gdiplus")
      VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
      DllCall("gdiplus\GdiplusStartup", "UPtrP", pToken, "Ptr", &si, "Ptr", 0)
      this.token := pToken
   }
   __Delete() {
      DllCall("gdiplus\GdiplusShutdown", "Ptr", this.token)
      if hModule := DllCall("GetModuleHandle", "Str", "gdiplus", "Ptr")
         DllCall("FreeLibrary", "Ptr", hModule)
   }
   CreateBitmapFromStream(pStream) {
      DllCall("gdiplus\GdipCreateBitmapFromStream", "Ptr", pStream, "PtrP", pBitmap)
      Return pBitmap
   }
   CreateHBITMAPFromBitmap(pBitmap, background := 0xffffffff) {
      DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Ptr", pBitmap, "PtrP", hbm, "UInt", background)
      return hbm
   }
   DisposeImage(pBitmap) {
      return DllCall("gdiplus\GdipDisposeImage", "Ptr", pBitmap)
   }
}
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 10 Sep 2021, 16:17

Thanks for reporting this. There has been a mention of other problems with FileInstall. I’ll check it out shortly.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 10 Sep 2021, 20:27

@digidings This is fixed in 1.1.34.00_Beta_3
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 10 Sep 2021, 20:28

1.1.34.00_Beta_3, 11 September 2021
  • Fixes 'FileInstall' when a path is specified.
See this post for download details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 11 Sep 2021, 17:37

1.1.34.00_Beta_4, 12 September 2021
  • Fixes bug in AddResource introduced in Beta_3
See this post for download details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 11 Sep 2021, 17:44

@digidings See Beta_4 for correct fix.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Upcoming Ahk2Exe Changes (2021)

Post by TAC109 » 16 Sep 2021, 19:26

1.1.34.00_Beta_5, 17 September 2021
  • Include Ahk2Exe in 'Base file' list if relevant.
See this post for download details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
digidings
Posts: 24
Joined: 22 Jan 2018, 17:04

Re: Upcoming Ahk2Exe Changes (2021)

Post by digidings » 23 Sep 2021, 09:22

@TAC: :dance: Thanks for fixing! I confirm expected behavior regarding FileInstall / HBitMapFromResource ("dirName/resource") in uncompiled script and in compiled script with Ahk2Exe 1.1.34.00 Beta_4 / Beta_5
Post Reply

Return to “Scripts and Functions (v1)”