Page 23 of 32

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 26 Jul 2021, 19:00
by TAC109
Fixed download link in first post.

See this post for download details.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 26 Jul 2021, 23:27
by TAC109
Updated the first post to include a description of the Base file search algorithm used.

See this post for details.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 03 Aug 2021, 06:32
by TheArkive
@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.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 03 Aug 2021, 16:22
by TAC109
@TheArkive
Cheers!

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 29 Aug 2021, 12:17
by joedf
@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

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 29 Aug 2021, 16:09
by TAC109
@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

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 29 Aug 2021, 17:39
by joedf
@TAC109 very neat, that's great to hear! Thanks. :+1:

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 29 Aug 2021, 22:18
by TAC109
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.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 30 Aug 2021, 14:08
by TheArkive
Awesome! :thumbsup:

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 31 Aug 2021, 04:58
by just me

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 3684 times

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 31 Aug 2021, 16:26
by TAC109
Your executable has to obey the rules for UIAccess. See here for more information.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 08 Sep 2021, 19:28
by TAC109
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.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 10 Sep 2021, 12:33
by digidings
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)
   }
}

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 10 Sep 2021, 16:17
by TAC109
Thanks for reporting this. There has been a mention of other problems with FileInstall. I’ll check it out shortly.

Cheers

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 10 Sep 2021, 20:27
by TAC109
@digidings This is fixed in 1.1.34.00_Beta_3

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 10 Sep 2021, 20:28
by TAC109
1.1.34.00_Beta_3, 11 September 2021
  • Fixes 'FileInstall' when a path is specified.
See this post for download details.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 11 Sep 2021, 17:37
by TAC109
1.1.34.00_Beta_4, 12 September 2021
  • Fixes bug in AddResource introduced in Beta_3
See this post for download details.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 11 Sep 2021, 17:44
by TAC109
@digidings See Beta_4 for correct fix.

Cheers

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 16 Sep 2021, 19:26
by TAC109
1.1.34.00_Beta_5, 17 September 2021
  • Include Ahk2Exe in 'Base file' list if relevant.
See this post for download details.

Re: Upcoming Ahk2Exe Changes (2021)

Posted: 23 Sep 2021, 09:22
by digidings
@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