Compiling V2 scripts

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Compiling V2 scripts

Post by iruizdeconejo » 24 Jan 2023, 20:54

I am running a V2 script that extends the AutoHotkeyUxGui.
It runs nicely under V2.0.2. However, it´s been impossible to me to generate a proper executable for it.

Launching ahk2Exe 1.36 and selecting no matter what .bin or exe, it does not work.
The 1.1 bins generate an exe that complains as soon as it starts.
The 2.0.2 exes, both 32U and 64U, selected as .bin in the ahk2exe GUI generate exes that run, but do nothing, just return.

The script is a medium size class with a TaB3 panel, several buttons, radio buttons, dropDownLists, boxes, Text and Edits and their associated event methods.

Any hint on how to debug the compilation? Which elements do not compile properly in V2?
THanks,
Ignacio

TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compiling V2 scripts

Post by TAC109 » 25 Jan 2023, 17:10

Can you confirm that your script runs correctly as a freestanding script?

If so, can you supply the complete script so that I can compile it and check that the compiler is working correctly.

Thanks
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

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 09 Feb 2023, 03:23

Ooops, I was expecting an email and didn´t check this topic...
Thanks for the reply. Yes, the script runs as standalone. It compiles, but does nothing when I launch the EXE, just returns to the prompt.
Maybe I´m misplacing the calls...
If you are able to compile and execute, please share instructions, thanks,

Ignacio

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 09 Feb 2023, 03:24

Code: Select all

;==========================================================================
;  BundleEditor
;  Copyright (C) 2023 EFI Cretaprint
;
; BndlEditor.ahk: AutoHotkey's "main menu" for the App.
; Run the script to show the GUI.
;
;    Editing this source file with Notepad++
;         ;IN comienza un desplegable en lenguaje ahk (XML modificado por mi)
;         ;OUT cierra el desplegable
;         Es necesario para los¨"if" que tienen llave ("{") si no hay "else"
;         The "for" clause also breaks the folding "in" Notepad++,
;         so we put it at the end of it an "OUT" comment, tb necesita ";OUT"
;
;    For books on AutoHotKey, search for "Jack Dunning"
;           https://www.amazon.com/stores/Jack-Dunning/author/B001KCK5H0
;
;    TO debug AHK scripts: use scite4ahk editor
;           https://www.autohotkey.com/scite4ahk/pages/debugger.htm
;
;    RunCmd https://www.autohotkey.com/boards/viewtopic.php?t=74647
;           https://www.autohotkey.com/board/topic/15455-stdouttovar
;           https://www.autohotkey.com/board/topic/96903-simplified-versions-of-seans-stdouttovar/
;
;    Books on Google Chrome Developer Tools:
;           Beginners Guide + Video Course Kindle,    Peter Moxon
;	   	    Learning Chrome Web Developer Tools,      Sasha Vodnik
;			Chrome DevTools Introduction 2020 Web Developers Guide, Laurence Svekis
;			Debugging with Chrome Developer Tools,    Diego Jose Arguelles Rojas
;           Creating Google Chrome Extensions,        Prateek Mehta
;
;
;    DEBUG with   -v w26 -l14 -s1 -c4 test_14x25 out99.tif
;                 -v w800 -l1140 -s5 -c7 juan jj.tif
; =========================== END OF HEADER ==================================

;IN  =========== Definition of Help texts ====================================

HlpText := "Input BNDL files`n"
HlpText .= "==========`n"
HlpText .= "The *Number of drop sizes* ('of drops') is the number of halftone "
HlpText .= " minus one.`nIn other words, it does not take into account the 0 "
HlpText .= "value, which stands for 'no ink'.`n"
HlpText .= "`n"
HlpText .= "The *Channel suffixes* determines the name of the first (and "
HlpText .= "subsequent) bundle`nfile to include in the conversion."
HlpText .= "You can still select any of the files of the set, though.`n"
HlpText .= "`n"
HlpText .= "*Number of bundle files* : any number between 1 and 6 will generate "
HlpText .= "a multichannel`nTIFF image with that number of channels.`n"
HlpText .= "If selected via the Directory browser, the bundle file names are "
HlpText .= "filled in automatically.`n"
HlpText .= "Bundle file names can be edited individually.`n"
HlpText .= "If number is set to 0, no automatic name filling occurs and "
HlpText .= "bndl file names get used`nstrictly, although they can be blank.`n"
HlpText .= "`n"
HlpText .= "The contone value for each pixel of the generated TIF file "
HlpText .= "is a function of:`n"
HlpText .= "  - the *drop size* (a 4-bit value ~=amount of ink) in the BNDL file`n"
HlpText .= "  - the *Number of drop sizes*`n`n"
HlpText .= "`t`tNumber of drop sizes (not counting 0=no drop)`n"
HlpText .= "`t 1 `t  2`t   3`t   4`t  5`t  6`t  7`t  8`n"
HlpText .= "drop :  ==================================================`n"
HlpText .= "  2    :`t127`t255`n"
HlpText .= "  3    :`t85`t170`t255`n"
HlpText .= "  4    :`t64`t128`t191`t255`n"
HlpText .= "  5    :`t51`t102`t153`t204`t255`n"
HlpText .= "  6    :`t42`t 85`t128`t170`t213`t255`n"
HlpText .= "  7    :`t36`t 72`t108`t146`t183`t219`t255`n"
HlpText .= "  8    :`t32`t64`t96`t127`t160`t192`t223`t255`n"
HlpText .= "======================================================`n"
HlpText .= "`n"
HlpText .= "The initial values of this table are based on an ICC profile of "
HlpText .= "of the Nozomi printer.`n"
HlpText .= "They can varied at will in the settings tab.`n"
HlpText .= "To keep consistency with Engineering BNDL viewers we could`n"
HlpText .= "support additional levels, say, 3 drops with 7 drop sizes.`n"
HlpText .= "`nOutput TIFF file`n"
HlpText .= "==========`n"
HlpText .= "*Width* and *Height* must be set to assign visualization "
HlpText .= "dimensions of the TIFF`nimage file."
HlpText .= "The adjacent dropdown control facilitates correct values.`n"
HlpText .= "`n*Resolution* is a value stored in one of the TIFF tags `n"
HlpText .= "for its proper printing/`nvisualization. It should match the "
HlpText .= "resolution of the printhead used to generate the print.`n"
HlpText .= "`n"

Hlp2Text := "The buttons on the left of the panel will launch different tasks:`n`n "
Hlp2Text .= "*PHOTOSHOP* will launch that program, which will be use as an`n"
Hlp2Text .= "    advanced editor for the drop sizes, via a plug-in.`n`n"
Hlp2Text .= "*PRE-VIEW* will launch the system application associated to the`n"
Hlp2Text .= "    TIFF format, using the image generated from the bndl files.`n`n"
Hlp2Text .= "*POST-VIEW* will launch the viewer with the image saved after`n"
Hlp2Text .= "    editing it with Photoshop.`n`n"
Hlp2Text .= "*WARNING*: Most of the Windows viewers will not display the alpha`n"
Hlp2Text .= "channels properly. This functionality is just a quick and dirty`n"
Hlp2Text .= "hack that helps to verify (at least) the CMYK channels`n`n"

Hlp3Text := "*Filename* corresponds to the edited TIFF file, which must be`n"
Hlp3Text .= "    in CMYK color space and with as many as 8 alpha channels.`n"
Hlp3Text .= "    DO NOT convert to Multichannel, because Photoshop does not`n"
Hlp3Text .= "    allow saving it as TIFF.`n`n"
Hlp3Text .= "The *Channel suffixes* determines the name of the first (and "
Hlp3Text .= "subsequent)`nbundle file that will be generated.`n`n"
Hlp3Text .= "Output BNDL files* specifies the directory where these bndl files`n"
Hlp3Text .= "    will be saved.`n`n"
Hlp3Text .= "*Base name* is the string that will be used in all the output files`n "
Hlp3Text .= "    which will also receive the apropriate suffixes.`n`n`n"

Hlp4Text := "These are tags that go inside the TIFF file and apparently will not`n"
Hlp4Text .= "be displayed on the TIFF image. They will help with the identification`n"
Hlp4Text .= "of the intermediate TIF output file. If this image contains alpha`n"
Hlp4Text .= "proper visualization of the alpha channels.`n`n"
Hlp4Text .= "*Description* is a text we include in a tag of the TIF file`n`n"
Hlp4Text .= "*Alpha channels* are those beyond CMYK...`n"
Hlp4Text .= "...`n"

;OUT

;IN ============ Variables definition ========================================

ROOT_DIR := "C:\Program Files\AutoHotkey\UX"
SetWorkingDir ROOT_DIR

;#include inc\bounce-v1.ahk
#include "C:\Program Files\AutoHotkey\UX\inc\bounce-v1.ahk"

/* v1 stops here */
#requires AutoHotkey v2.0

#NoTrayIcon
#SingleInstance Force

#include "C:\Program Files\AutoHotkey\UX\inc\ui-base.ahk"
#include "C:\Program Files\AutoHotkey\UX\ui-launcherconfig.ahk"


BundleRegKey := 'HKCU\Software\EFI\BundleEditor\'
Verbose := True

if A_ScriptFullPath = A_LineFile
    Bndl2TiffGui.Show()

;Esc::ExitApp

;OUT

;IN ============ Begin generic Methods =======================================

ShowHelpFile(hlpText, title) {
    ;SetWorkingDir ROOT_DIR
	MsgBox(hlpText, title)
}

getRectangles(product) {		;Return pairs (width, height) of possible rects
    rectangles := []
	i := 2
	while (i <= integer(sqrt(product))) {
        if (Mod(i,2)==0) i:= i+1
        j := integer(product/i)
        if (j*i==product) AND j<40000 AND i<40000 {
           rectangles.InsertAt(1, i, j)
           rectangles.InsertAt(0, j, i)
		}
    }
    return rectangles
}

;OUT End Generic Methods =====================================================

class Bndl2TiffGui extends AutoHotkeyUxGui {

    __new() {	; ======== GUI Class constructor==============================
        super.__new("EFI CretaPrint (c)  TIFF<-->BNDL conversion  [v.1.0.0032]")

		this.sizesA := [""]					; needs one value, make it null
		this.colorsA := ["RGB","HSB","CMYK","L*a*b*"]
        Tab := this.Add("Tab3","c0000FF", ["Bndl2Tiff","Editor","Tiff2Bndl","Settings"])

		;IN Tab1 
		Tab.UseTab(1)		; ================================================

		;IN Input bundle files group --------------------------------------

		this.AddGroupBox("w655 h164 c000099", " Input BNDL files ")
        this.Add("Text","xp+10 yp+20","Number of drop sizes:")
		this.drops1 := this.Add("Edit", "xp+120 yp-4 w38")
        this.Add("UpDown", "vdrop1Choice Range1-8", 4)
		this.drops1.OnEvent("Change", "drops1_Change")

        this.Add("Text","xp+55 yp+2","bits/drop:")
		this.bitsRadio11 := this.Add("Radio", "Group xp+56 yp+1", "2")
        this.bitsRadio12 := this.Add("Radio", "xp+30 yp", "4")
		this.bitsRadio11.Value := 0
		this.bitsRadio12.Value := 1
		this.bitsRadio11.OnEvent("Click", "bits1_Click")
		this.bitsRadio12.OnEvent("Click", "bits1_Click")

		this.check1 := this.Add("CheckBox", "xp+58 yp vCheckBox1", "Use suffix")
 		this.check1.OnEvent("Click", "check1_CliCk")   	; Call check1_Click
		this.check1.Value := 1

        this.sufixRadioText := this.Add("Text","xp+84 yp", "Channel sufixes:")
		this.sufixRadio11 := this.Add("Radio", "Group xp+87 yp", "0123")
        this.sufixRadio12 := this.Add("Radio", "xp+49 yp", "1234")
        this.sufixRadio13 := this.Add("Radio", "xp+49 yp", "CMYK")
		this.sufixRadio11.Value := 1
		this.sufixRadio12.Value := 0
		this.sufixRadio13.Value := 0
		this.sufixRadio11.OnEvent("Click", "sufix1_Click")
		this.sufixRadio12.OnEvent("Click", "sufix1_Click")
		this.sufixRadio13.OnEvent("Click", "sufix1_Click")

		this.Add("Text","xp-586 yp+30", "Directory:")
        this.bndlDir1 := this.Add("Edit", "xp+58 yp-3 r1 vDirName1 w525")
		bndl1Btn := this.Add("Button", "xp+534 yp-2 w35", "...")
 		bndl1Btn.OnEvent("Click", "bndl1Btn_Click")   	; Select bndl file
        this.Add("Text","xp-593 yp+35","Number of bundle files:")
        this.number1 := this.Add("Edit", "xp+130 yp-4 w38")
        this.number1.OnEvent("Change", "number1_Change")
        this.Add("UpDown", "vnumberChoice Range0-8", 4)
		this.Add("Text","xp+60 yp+4", "(0 => uses all not empty names, no suffixes)")

		this.t1 := this.Add("Text","xp-192 yp+28", "C:")
		this.t2 := this.Add("Text","xp+155 yp",    "M:")
		this.t3 := this.Add("Text","xp+155 yp",    "Y:")
		this.t4 := this.Add("Text","xp+155 yp",    "K:")
		this.t5 := this.Add("Text","xp-465 yp+28", "5:")
		this.t6 := this.Add("Text","xp+155 yp",    "6:")
		this.t7 := this.Add("Text","xp+155 yp",    "7:")
		this.t8 := this.Add("Text","xp+155 yp",    "8:")
        this.bndl11 := this.Add("Edit", "xp-451 yp-32 r1 vBndlName11 w132")
        this.bndl12 := this.Add("Edit", "xp+155 yp r1 vBndlName12 w132 Hidden")
        this.bndl13 := this.Add("Edit", "xp+155 yp r1 vBndlName13 w132 Hidden")
        this.bndl14 := this.Add("Edit", "xp+155 yp r1 vBndlName14 w132 Hidden")
        this.bndl15 := this.Add("Edit", "xp-464 yp+30 r1 vBndlName15 w132 Hidden")
        this.bndl16 := this.Add("Edit", "xp+155 yp r1 vBndlName16 w132 Hidden")
        this.bndl17 := this.Add("Edit", "xp+155 yp r1 vBndlName17 w132 Hidden")
        this.bndl18 := this.Add("Edit", "xp+155 yp r1 vBndlName18 w132 Hidden")
		this.bndl12.Enabled := 0
		this.bndl13.Enabled := 0
		this.bndl14.Enabled := 0
		this.bndl15.Enabled := 0
		this.bndl16.Enabled := 0
		this.bndl17.Enabled := 0
		this.bndl18.Enabled := 0

 		this.bndl11.OnEvent("LoseFocus", "bndl11_Lose")   	; Call bndl11_Lose
 		this.bndl12.OnEvent("LoseFocus", "bndl12_Lose")
 		this.bndl13.OnEvent("LoseFocus", "bndl13_Lose")
 		this.bndl14.OnEvent("LoseFocus", "bndl14_Lose")
 		this.bndl15.OnEvent("LoseFocus", "bndl15_Lose")
 		this.bndl16.OnEvent("LoseFocus", "bndl16_Lose")
 		this.bndl17.OnEvent("LoseFocus", "bndl17_Lose")
 		this.bndl18.OnEvent("LoseFocus", "bndl18_Lose")
		;OUT input bndl
		
		;IN Output tiff file group ----------------------------------------

		this.AddGroupBox("xp-493 yp+40 w654 h80 c000099", " Output TIFF file ")
        this.Add("Text", "xp+10 yp+20","Width:")
        this.width1 := this.Add("Edit", "xp+37 yp-2 vWidth1 r1 w42")
        this.Add("Text", "xp+46 yp+2","x Length:")
        this.length1 := this.Add("Edit", "xp+50 yp-2 vLength1 r1 w42")

		;this.Add("Text","xp+54 yp+2","Dim.:")
        this.dimensions1 := this.Add("DropDownList", "xp+54 yp+1 vdimChoice w100", this.sizesA)
        this.dimensions1.Value := 1
        this.dimensions1.OnEvent("Change", "dims1_Change")
        this.dimensions1.OnEvent("LoseFocus", "dims1_Lose")

        this.Add("Text", "xp+200 yp+2","Resolution:")
        this.resRadio11 := this.Add("Radio", "Group xp+63 yp vRes1", "360")
        this.resRadio12 := this.Add("Radio", "xp+43 yp", "600")
        this.resRadio13 := this.Add("Radio", "xp+43 yp", "720")
		this.resRadio11.Value := 1
		this.resRadio12.Value := 0
		this.resRadio13.Value := 0
		this.resRadio11.OnEvent("Click", "res1_Click")
		this.resRadio12.OnEvent("Click", "res1_Click")
		this.resRadio13.OnEvent("Click", "res1_Click")

        this.Add("Text", "xp-538 yp+30","Filename:")
        this.tiff1 := this.Add("Edit", "xp+56 yp-2 vTiffName1 r1 w525")
		tiff1Btn := this.Add("Button", "xp+535 yp-2 w35", "...")
		tiff1Btn.OnEvent("Click", "tiff1Btn_Click")   		; Call tiff1Btn_Click

		;OUT output tiff
		
		;IN Setup buttons at the bottom of the tab 1 ----------------------

		hlp1Btn := this.Add("Button", "xp-256 yp+50 w80", "&Help")
        hlp1Btn.OnEvent("Click", "hlp1Btn_Click")   			; Call hlpBtn_Click
		apply1Btn := this.Add("Button", "xp+130 w80", "&Apply")
        apply1Btn.OnEvent("Click", "apply1Btn_Click")  		; Call
		cancel1Btn := this.Add("Button", "xp+90 w80", "&Leave")
        cancel1Btn.OnEvent("Click", "cancelBtn_Click")  	; Call
		;OUT end setup buttons	
		
		;OUT Tab1

		;IN Tab(2), to call photoshop and test ----------------------------
		Tab.UseTab(2)		; =================================================

		this.ps2 := ps2Btn := this.Add("Button", "w200", "PHOTOSHOP")
        this.ps2.OnEvent("Click", "photoBtn_Click")

		this.view21 := this.Add("Button", "xp yp+60 w200", "PRE-VIEW")
        this.view21.OnEvent("Click", "viewerInBtn_Click")
		this.view22 := this.Add("Button", "xp yp+40 w200", "POST-VIEW")
        this.view22.OnEvent("Click", "viewerOutBtn_Click")

		;IN Setup buttons at the bottom of the tab 2 ----------------------

		hlp3Btn := this.Add("Button", "xp+255 yp+150 w80", "Help")
        hlp3Btn.OnEvent("Click", "hlp2Btn_Click")   	; Call hlpBtn_/ test_func_
		cancel3Btn := this.Add("Button", "xp+220 w80", "&Leave")
        cancel3Btn.OnEvent("Click", "cancelBtn_Click")  ; Call cancelBtn_Click

		;OUT

		;OUT end Tab2

		;IN Tab3 ----------------------------------------------------------
		Tab.UseTab(3)		; =================================================

		;IN Input TIF file group ------------------------------------------
		this.AddGroupBox("w624 h50 c000099", " Input TIFF file ")
        this.Add("Text", "xp+10 yp+20","Filename:")
        this.tiff3 := this.Add("Edit", "xp+58 yp-2 vTiffName3 r1 w500")
		tiffBtn := this.Add("Button", "xp+512 yp-2 w35", "...")
        tiffBtn.OnEvent("Click", "tiff3Btn_Click")   		; Call tiff3Btn_Click

		;OUT

		;IN Output bndl files group ---------------------------------------

		this.AddGroupBox("w624 h113 xp-580 yp+42 c000099", " Output BNDL files ")
        this.Add("Text","xp+10 yp+25","Number of drop sizes:")
        this.drops3 := this.Add("Edit", "xp+120 yp-3 w38")
        this.Add("UpDown", "vdrop3Choice Range1-7", 4)
        this.sufixText3 := this.Add("Text","xp+206 yp", "Channel suffixes:")
		this.sufixRadio31 := this.Add("Radio", "Group xp+90 yp vSufix3", "0123")
        this.sufixRadio32 := this.Add("Radio", "xp+55 yp", "CMYK")
		this.sufixRadio31.Value := 1
		this.sufixRadio31.Value := 0
        this.sufixRadio31.OnEvent("Click", "sufixRadio3_Click")
        this.sufixRadio32.OnEvent("Click", "sufixRadio3_Click")

		this.Add("Text","xp-471 yp+30", "Directory:")
        this.bndlDir3 := this.Add("Edit", "xp+58 yp-3 r1 vDirName3 w498")
		bndl3Btn := this.Add("Button", "xp+510 yp-2 w35", "...")
        bndl3Btn.OnEvent("Click", "bndl3Btn_Click")   		; Call bndlBtn_Click
        this.Add("Text","xp-570 yp+35", "Base Name:")
        this.bndl31 := this.Add("Edit", "xp+69 yp-3 r1 vBndlName3 w100")
        this.bndl31.OnEvent("Change", "bndl31_Change")

		;OUT

		;IN Setup buttons at the bottom of the tab 3 ----------------------

		hlp3Btn := this.Add("Button", "xp+244 yp+115 w80", "Help")
        hlp3Btn.OnEvent("Click", "hlp3Btn_Click")   	; Call hlpBtn_/ test_func_
		apply3Btn := this.Add("Button", "xp+130 w80", "Apply")
        apply3Btn.OnEvent("Click", "apply3Btn_Click")  	; Call applyBtn_Click
		cancel3Btn := this.Add("Button", "xp+90 w80", "&Leave")
        cancel3Btn.OnEvent("Click", "cancelBtn_Click")  ; Call cancelBtn_Click

		;OUT

		;IN Read default values from Registry 1 ---------------------------

		this.bitsRadio11.Value := RegRead(BundleRegKey, 'bitspp11', 0)
		this.bitsRadio12.Value := RegRead(BundleRegKey, 'bitspp12', 1)
		this.drops1.Value := RegRead(BundleRegKey, 'drops1', 4)
        this.bndl11.Value := RegRead(BundleRegKey, 'BndlIn11', "")
        this.bndl12.Value := RegRead(BundleRegKey, 'BndlIn12', "")
        this.bndl13.Value := RegRead(BundleRegKey, 'BndlIn13', "")
        this.bndl14.Value := RegRead(BundleRegKey, 'BndlIn14', "")
        this.bndl15.Value := RegRead(BundleRegKey, 'BndlIn15', "")
        this.bndl16.Value := RegRead(BundleRegKey, 'BndlIn16', "")
        this.bndl17.Value := RegRead(BundleRegKey, 'BndlIn17', "")
        this.bndl18.Value := RegRead(BundleRegKey, 'BndlIn18', "")
        this.bndlDir1.Value := RegRead(BundleRegKey, 'BndlInDir', "")
		this.tiff1.Value := RegRead(BundleRegKey, 'TiffOut', "")
        this.tiff3.Value := RegRead(BundleRegKey, 'TiffIn', "")
        this.bndl31.Value := RegRead(BundleRegKey, 'BndlOut31', "")
        this.bndlDir3.Value := RegRead(BundleRegKey, 'BndlOutDir', "")
        this.number1.Value := RegRead(BundleRegKey, 'BndlNum', 4)
		this.sufixRadio11.Value := RegRead(BundleRegKey, 'sufixRadio11', 1)
		this.sufixRadio12.Value := RegRead(BundleRegKey, 'sufixRadio12', 0)
		this.sufixRadio13.Value := RegRead(BundleRegKey, 'sufixRadio13', 0)
        this.sufixRadio31.Value := RegRead(BundleRegKey, 'sufixRadio31', 1)
        this.sufixRadio32.Value := RegRead(BundleRegKey, 'sufixRadio32', 0)
		this.PS := RegRead(BundleRegKey, 'PS', "")
		this.resRadio11.Value := RegRead(BundleRegKey, 'Resolution11', 1)
		this.resRadio12.Value := RegRead(BundleRegKey, 'Resolution12', 0)
		this.resRadio13.Value := RegRead(BundleRegKey, 'Resolution13', 0)
		this.resRadio13.Value := RegRead(BundleRegKey, 'Resolution13', 0)
		this.check1.Value := RegRead(BundleRegKey, 'check1', 1)

		this.bndlCtrls := [ this.bndl11,  this.bndl12,  this.bndl13,  this.bndl14,
							this.bndl15,  this.bndl16,  this.bndl17,  this.bndl18 ]
		this.ts := [this.t1, this.t2, this.t3, this.t4,
					this.t5, this.t6, this.t7, this.t8 ]
		
		;IN Set GUI looks based on values we have just read 

		sizesS := RegRead(BundleRegKey, 'sizes', "")
		if sizesS != "" {
			sizesS := Substr(sizesS,1,StrLen(sizesS)-1)			; strip last "!"
			this.sizesA:= StrSplit(sizesS, "!")
		}
		oldValue := RegRead(BundleRegKey, 'dimensions1', 1)
		this.update_Dims("", 0)			; Update w, l, the array sizesA and dimsList
		this.dimensions1.Value := oldValue
		this.dims1_Change("",0)

		for bndlCntrl in this.bndlCtrls
			bndlCntrl.Enabled := this.check1.Value	;OUT
		update_Suffixes(this, this.check1.Value,  this.number1.Value)
		this.number1_Change(this, 0)
		
		;OUT set GUI

    	;OUT Class Methods ====================================================

		;OUT tab3

		;IN Tab4 ----------------------------------------------------------
		Tab.UseTab(4)		; =================================================

		;IN TIF Image description group --------------------------------------
		this.AddGroupBox("w655 h50 c000099", " TIFF Image Description ")
        this.Add("Text", "xp+10 yp+20","Text:")
        this.tiffDesc4 := this.Add("Edit", "xp+32 yp-2 vTiffName4 r1 w604")
		;OUT
		
		;IN Alpha channels group ---------------------------------------------
		this.AddGroupBox("w655 h136 xp-42 yp+40 c000099", " Alpha channels ")
        this.Add("Text", "xp+10 yp+20","Canal 5:")
        this.alpha45 := this.Add("Edit", "xp+50 yp-2 vAlphaName5 r1 w200")
        this.alpha45.OnEvent("LoseFocus", "colorchan45_Lose")
		this.clrProgress45 := this.Add("Progress", "cFFA500 xp+215 w40 h24",100)
        this.colorspaces45 := this.Add("DropDownList", "xp+55 yp+1 vspace41Choice w60", this.colorsA)
        this.colorspaces45.Value := 1
        this.colorspaces45.OnEvent("Change", "colorsp45_Change")
        this.coord451 := this.Add("Edit", "xp+75 yp-1 vCoord451 r1 w50")
        this.coord452 := this.Add("Edit", "xp+60 yp   vCoord452 r1 w50")
        this.coord453 := this.Add("Edit", "xp+60 yp   vCoord453 r1 w50")
        this.coord454 := this.Add("Edit", "xp+60 yp   vCoord454 r1 w50")
        this.coord451.OnEvent("Change", "alpha451_Change")
        this.coord452.OnEvent("Change", "alpha452_Change")
        this.coord453.OnEvent("Change", "alpha453_Change")
        this.coord454.OnEvent("Change", "alpha454_Change")

        this.Add("Text", "xp-575 yp+30","Canal 6:")
        this.alpha46 := this.Add("Edit", "xp+50 yp-2 vAlphaName6 r1 w200")
        this.alpha46.OnEvent("LoseFocus", "colorchan46_Lose")
		this.clrProgress46 := this.Add("Progress", "cEE82EE xp+215 w40 h24",100)
        this.colorspaces46 := this.Add("DropDownList", "xp+55 yp+1 vspace42Choice w60", this.colorsA)
        this.colorspaces46.Value := 2
        this.colorspaces46.OnEvent("Change", "colorsp46_Change")
        this.coord461 := this.Add("Edit", "xp+75 yp-1 vCoord461 r1 w50")
        this.coord462 := this.Add("Edit", "xp+60 yp   vCoord462 r1 w50")
        this.coord463 := this.Add("Edit", "xp+60 yp   vCoord463 r1 w50")
        this.coord464 := this.Add("Edit", "xp+60 yp   vCoord464 r1 w50")
        this.coord461.OnEvent("Change", "alpha461_Change")
        this.coord462.OnEvent("Change", "alpha462_Change")
        this.coord463.OnEvent("Change", "alpha463_Change")
        this.coord464.OnEvent("Change", "alpha464_Change")
		
        this.Add("Text", "xp-575 yp+30","Canal 7:")
        this.alpha47 := this.Add("Edit", "xp+50 yp-2 vAlphaName7 r1 w200")
        this.alpha47.OnEvent("LoseFocus", "colorchan47_Lose")
		this.clrProgress47 := this.Add("Progress", "c00AA00 xp+215 w40 h24",100)
        this.colorspaces47 := this.Add("DropDownList", "xp+55 yp+1 vspace43Choice w60", this.colorsA)
        this.colorspaces47.Value := 3
        this.colorspaces47.OnEvent("Change", "colorsp47_Change")
        this.coord471 := this.Add("Edit", "xp+75 yp-1 vCoord471 r1 w50")
        this.coord472 := this.Add("Edit", "xp+60 yp   vCoord472 r1 w50")
        this.coord473 := this.Add("Edit", "xp+60 yp   vCoord473 r1 w50")
        this.coord474 := this.Add("Edit", "xp+60 yp   vCoord474 r1 w50")
        this.coord471.OnEvent("Change", "alpha471_Change")
        this.coord472.OnEvent("Change", "alpha472_Change")
        this.coord473.OnEvent("Change", "alpha473_Change")
        this.coord474.OnEvent("Change", "alpha474_Change")
		
        this.Add("Text", "xp-575 yp+30","Canal 8:")
        this.alpha48 := this.Add("Edit", "xp+50 yp-2 vAlphaName8 r1 w200")
        this.alpha48.OnEvent("LoseFocus", "colorchan48_Lose")
		this.clrProgress48 := this.Add("Progress", "cFFFFFF xp+215 w40 h24",100)
        this.colorspaces48 := this.Add("DropDownList", "xp+55 yp+1 vspace44Choice w60", this.colorsA)
        this.colorspaces48.Value := 4
        this.colorspaces48.OnEvent("Change", "colorsp48_Change")
        this.coord481 := this.Add("Edit", "xp+75 yp-1 vCoord481 r1 w50")
        this.coord482 := this.Add("Edit", "xp+60 yp   vCoord482 r1 w50")
        this.coord483 := this.Add("Edit", "xp+60 yp   vCoord483 r1 w50")
        this.coord484 := this.Add("Edit", "xp+60 yp   vCoord484 r1 w50")
        this.coord481.OnEvent("Change", "alpha481_Change")
        this.coord482.OnEvent("Change", "alpha482_Change")
        this.coord483.OnEvent("Change", "alpha483_Change")
        this.coord484.OnEvent("Change", "alpha484_Change")
		
		;OUT alpha channs

		;IN Setup buttons at the bottom of the tab 4 ----------------------

		this.AddGroupBox("w655 h50 xp-585 yp+40 c000099", " Color maps per drop size")

		hlp4Btn := this.Add("Button", "xp+325 yp+60 w80", "Help")
        hlp4Btn.OnEvent("Click", "hlp4Btn_Click")   	; Call hlpBtn_/ test_func_
		cancel4Btn := this.Add("Button", "xp+220 w80", "&Leave")
        cancel4Btn.OnEvent("Click", "cancelBtn_Click")  ; Call cancelBtn_Click
		;trialButton := this.Add("Button", "xp-400 h20 w30 Hidden", "")
		;trialButton.BackColor := "00AA00"
		;OUT bbuttons4

		;IN Read default values from Registry 4 ---------------------------

        this.tiffDesc4.Value := RegRead(BundleRegKey, 'TiffDescript', "")
        this.colorspaces45.Value := RegRead(BundleRegKey, 'colorsp5', 1)
        this.colorspaces46.Value := RegRead(BundleRegKey, 'colorsp6', 1)
        this.colorspaces47.Value := RegRead(BundleRegKey, 'colorsp7', 1)
        this.colorspaces48.Value := RegRead(BundleRegKey, 'colorsp8', 1)
        this.alpha45.Value := RegRead(BundleRegKey, 'alpha5', "Orange")
        this.alpha46.Value := RegRead(BundleRegKey, 'alpha6', "Violet")
        this.alpha47.Value := RegRead(BundleRegKey, 'alpha7', "Green")
        this.alpha48.Value := RegRead(BundleRegKey, 'alpha8', "")
        this.coord451.Value := RegRead(BundleRegKey, 'coord51', 255)		;Orange
        this.coord452.Value := RegRead(BundleRegKey, 'coord52', 165)
        this.coord453.Value := RegRead(BundleRegKey, 'coord53', 0)
        this.coord454.Value := RegRead(BundleRegKey, 'coord54', 0)
        this.coord461.Value := RegRead(BundleRegKey, 'coord61', 240)		; Violet
        this.coord462.Value := RegRead(BundleRegKey, 'coord62', 130)
        this.coord463.Value := RegRead(BundleRegKey, 'coord63', 240)
        this.coord464.Value := RegRead(BundleRegKey, 'coord64', 0)
        this.coord471.Value := RegRead(BundleRegKey, 'coord71', 0)		; Green
        this.coord472.Value := RegRead(BundleRegKey, 'coord72', 160)
        this.coord473.Value := RegRead(BundleRegKey, 'coord73', 0)
        this.coord474.Value := RegRead(BundleRegKey, 'coord74', 0)
        this.coord481.Value := RegRead(BundleRegKey, 'coord81', 255)		; White
        this.coord482.Value := RegRead(BundleRegKey, 'coord82', 255)
        this.coord483.Value := RegRead(BundleRegKey, 'coord83', 255)
        this.coord484.Value := RegRead(BundleRegKey, 'coord84', 0)
    	;OUT Registry

		;OUT tab4

        h := 346
        this.Show() ;"Hide h" (h + this.MarginY*2)) (why this here?)
    } ;end of New

  ;IN --- Tab1 B2T Class event methods ---------------------------------------

	dims1_Lose(ctrl, item) {					; B2T Change image dimensions
	}


	dims1_Change(ctrl, item) {					; B2T Change image dimensions
		RegWrite(this.dimensions1.Value, 'REG_SZ', BundleRegKey, 'dimensions1')
	    text := this.sizesA[this.dimensions1.Value]
		dims := StrSplit(text, "x", " ")
		this.width1.Value := integer(dims[1])
		this.length1.Value := integer(dims[2])
	}


	drops1_Change(ctrl, item) {
		if this.drops1.Value > 8
		   this.drops1.Value := 8
		if this.drops1.Value < 1
		   this.drops1.Value := 1
		RegWrite(this.drops1.Value, 'REG_SZ', BundleRegKey, 'drops1')
		if this.drops1.Value >3 {
			this.bitsRadio11.Value := 0
			this.bitsRadio12.Value := 1
			this.bits1_Click(ctrl, item)
		}
	}


	bits1_Click(ctrl, item) {					; B2T radio change bits per pixel
		RegWrite(this.bitsRadio11.Value, 'REG_SZ', BundleRegKey, 'bitspp11')
		RegWrite(this.bitsRadio12.Value, 'REG_SZ', BundleRegKey, 'bitspp12')
		if this.bitsRadio11.Value = 1 {
			if this.drops1.Value > 3 {
				this.drops1.Value := 3
				this.drops1_Change(ctrl, item)
			}
		}
	}


	number1_Change(ctrl, item) {				; B2T Change number of bundle files
		if this.number1.Value > 8
			this.number1.Value := 8
		number := this.number1.Value
		RegWrite(number, 'REG_SZ', BundleRegKey, "BndlNum")
		Loop 8 {		;; if (number > 5) {
			if (A_Index < 2)
				continue 			; Skip 1st file
			t := Format("t{}", A_Index)
			if (A_index < number+1) OR (number = 0) {
				this.bndlCtrls[A_index].Visible := true
				this.ts[A_index].SetFont("cBlack")
			} else {
				this.bndlCtrls[A_index].Visible := false
				this.ts[A_index].SetFont("cGray")

			}
		}
	}


	sufix1_Click(ctrl, item) {					; B2T radio change suffixes to use
		RegWrite(this.sufixRadio11.Value, 'REG_SZ', BundleRegKey, 'sufixRadio11')
		RegWrite(this.sufixRadio12.Value, 'REG_SZ', BundleRegKey, 'sufixRadio12')
		RegWrite(this.sufixRadio13.Value, 'REG_SZ', BundleRegKey, 'sufixRadio13')
		this.number1_Change(ctrl, item)
	}


	check1_Click(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'check1')

		for bndlCntrl in this.bndlCtrls
			bndlCntrl.Enabled := 1 - ctrl.Value	;OUT
		this.bndlCtrls[1].Enabled := 1
		update_Suffixes(this, this.check1.Value,  this.number1.Value)
		
	}


	res1_Click(ctrl, item) {					; B2T Res radio change suffixes to use
		RegWrite(this.resRadio11.Value, 'REG_SZ', BundleRegKey, 'Resolution11')
		RegWrite(this.resRadio12.Value, 'REG_SZ', BundleRegKey, 'Resolution12')
		RegWrite(this.resRadio13.Value, 'REG_SZ', BundleRegKey, 'Resolution13')
	}


	bndl1Btn_Click(ctrl, item) { 				; B2T Call on input bndl button
	    oldOrder := this.sufixRadio11.Value this.sufixRadio12.Value
	    oldName := this.bndlDir1.Value "\" this.bndl11.Value
		msg0 := "Select the BUNDLE file (and directory where files are stored)"
		msg1 := "Suffix is set to Alphabetic, bundle file is Numeric"
		msg2 := "Suffix is set to Numeric, bundle file is Alphabetic"
	    fName := FileSelect("1",this.bndlDir1.Value, msg0, "*.bndl; *.BNDL")
		if fName != '' { 				;AND fName != oldName {
            SplitPath fName, &InFileName1, &InDir1, &InExt1, &InNameNoExt1, &InDrive1
			order := this.sufixRadio11.Value this.sufixRadio12.Value
			len := StrLen(InFileName1) - 6
			if (order=="00" && IsDigit(SubStr(InFileName1,len+1,1))) {
				MsgBox(msg1, "WARNING", "T10 OK Iconx")
				return
			}
			if ((order=="01" OR order=="10") && !IsDigit(SubStr(InFileName1,len+1,1))) {
				MsgBox(msg2 SubStr(InFileName1,len,1), "WARNING", "T10 OK Iconx")
				return
			}
			if !FileExist(fName) {
				MsgBox(Format("Filename {} does not exist",InFileName1),
				              "WARNING", "T5 OK Iconx")
				return
			}

		    this.bndlDir1.Value := InDir1			; Update file fields on screen
		    this.bndl11.Value := InFileName1
			this.update_Dims(ctrl, item)

			this.update_bndlRegs(InDir1, InFileName1, len)
		}
	}


	tiff1Btn_Click(ctrl, item) {  				; B2T Click on output tiff button
	    TiffName1 := FileSelect(8,"C:\", "Select a TIFF file", "*.tif;*.tiff")
		if TiffName1 != '' {
		    this.tiff1.Value := TiffName1
			RegWrite(TiffName1, 'REG_SZ', BundleRegKey, 'TiffOut')
		}
	}


	apply1Btn_Click(ctrl, item) {  				; B2T Click btn to launch Bndl2Tif
		w := this.width1.Value					; TIFF width
		l := this.length1.Value					; TIFF length
		s := this.drops1.Value					; number of sizes
		c := this.number1.Value					; number of channels (files)
		tif := this.tiff1.Value
		useSuffixes := this.check1.Value
		bndl := this.bndlDir1.Value '\' this.bndl11.Value
		if StrLower(SubStr(bndl, -5)) = '.bndl'
			bndl := Substr(bndl, 1, StrLen(bndl) -7)
		sufs := this.getSuffixes(useSuffixes, this.sufixRadio11.Value, this.sufixRadio12.Value)
		allNames := ''
		files := [this.bndl11.Value, this.bndl12.Value, this.bndl13.Value,
				  this.bndl14.Value, this.bndl15.Value, this.bndl16.Value,
				  this.bndl17.Value, this.bndl18.Value ]
		if (c = 0) {						; Use names in edit boxes, ignore blanks
		    for file in files {
				if file != "" {
					fName := this.bndlDir1.Value '\' file
					if FileExist(fName)
						allNames .= ' "' fName '"'
				    else
					    MsgBox Format(" File '{}' is missing", fName), "WARNING !", "T10 OK Iconx"
				}												; OUT if
			} 													;OUT for
			if allNames = ""
				return
			cmd := Format('"bndl2tif.exe" -w{} -l{} -s{} {} "{}"',  w,l,s,allNames,tif)
		} else {									;NOT Use base name and suffixes
		    Loop c {
				if useSuffixes = 1			; autoassign sufixes
					fName := Format(bndl '_{}.bndl', sufs[A_index])
				else
					fName := this.bndlDir1.Value '\' files[A_index]
				if !FileExist(fName) {
					MsgBox Format(A_index " File '{}' is missing", fName),
								  "ERROR !", "T10 OK Iconx"
					return
				}
				allNames .= ' "' fName '"'
			}
			if useSuffixes = 1
				cmd := Format('"bndl2tif.exe" -v -w{} -l{} -s{} -c{} "{}" "{}"', w,l,s,c,bndl,tif)
				;cmd := Format('"bndl2tif.exe" -w{} -l{} -s{} "{}" "{}"', w,l,s,bndl,tif)
			else
				cmd := Format('"bndl2tif.exe" -v -w{} -l{} -s{} {} "{}"', w,l,s,allNames,tif)
		}
		MsgBox(Cmd)
		Run cmd
	}


	hlp1Btn_Click(ctrl, item) {  				; B2T/PS/T2B Help button
	    ShowHelpFile(HlpText, "BundleEditor help - Bndl2Tiff")
	}


	hlp2Btn_Click(ctrl, item) {  				; B2T/PS/T2B Help button
	    ShowHelpFile(Hlp2Text, "BundleEditor help - Photoshop")
	}


	hlp3Btn_Click(ctrl, item) {  				; B2T/PS/T2B Help button
	    ShowHelpFile(Hlp3Text, "BundleEditor help - Tiff2Bndl")
	}
	
	hlp4Btn_Click(ctrl, item) {  				; B2T/PS/T2B Help button
	    ShowHelpFile(Hlp4Text, "BundleEditor help - Tiff2Bndl")
	}

	bndl11_Lose(ctrl, item) {					; B2T Change i bundle file name
		fName :=  this.bndl11.Value
		fullName := this.bndlDir1.Value "\" fName
		if FileExist(fullName) {
			RegWrite(fName, 'REG_SZ', BundleRegKey, 'BndlIn11')
			bndlSize := FileGetSize(fullName)
			sizes := getRectangles(bndlSize*2)
			this.sizesA := []
			for key, value in sizes {
			    if (Mod(key,2)=0) 			; skip every other, it´s a pair
				    continue
				text := Format("{} x {}", value, sizes[key+1])	; w x l
			    this.sizesA.InsertAt(0, text)
			} ;OUT
			sizesS := ""
			for value in this.sizesA
				sizesS .= value "!" ;OUT
			RegWrite(sizesS, 'REG_SZ', BundleRegKey, 'sizes')
		} else {
		    if fName != "" {
				MsgBox Format(" File '{}' does not exist!", fName),
							  "WARNING !", "T10 OK Iconx"

			}
		}
	}

	bndlXX_Lose(bctrl, key) {					; B2T Change any bundle file name
		fName :=  bctrl.Value
		fullname := this.bndlDir1.Value "\" bctrl.Value
		if FileExist(fullname)
			RegWrite(bctrl.Value, 'REG_SZ', BundleRegKey, key)
		else
			MsgBox Format(" File '{}' does not exist!", fName),
						  "WARNING !", "T10 OK Iconx"
	}

	bndl12_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl12, 'BndlIn12')
	}

	bndl13_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl13, 'BndlIn13')
	}

	bndl14_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl14, 'BndlIn14')
	}

	bndl15_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl15, 'BndlIn15')
	}

	bndl16_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl16, 'BndlIn16')
	}

	bndl17_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl17, 'BndlIn17')
	}

	bndl18_Lose(ctrl, item) {					; B2T Change i bundle file name
		this.bndlXX_Lose(this.bndl18, 'BndlIn8')
	}

  ;OUT                                          ; --- B2T

  ;IN --- Tab2 &3 T2B and PS Class event methods -----------------------------

	photoBtn_Click(ctrl, item) {				; PS Launch Photoshop button
		fName := this.tiff1.Value
		if FileExist(fName) {					; with TIFF file
			exists := FileExist(this.PS)
			if exists AND GetKeyState("Control")==0 {		; Pressing Ctrl key?
			    cont := True
			} else {
			    cont := False
				if ! exists {
				    MsgBox Format("File '{}' is missing", this.PS),
						"ERROR !","T5 OK Iconx"
				}
				fName := FileSelect(8,"C:\Program Files", "Select Photoshop executable", "*.exe")
				if (fName != '') {
					cont := True						; save in Registry
					this.PS := fName
					RegWrite(fName, 'REG_SZ', BundleRegKey, 'PS')
				}										;OUT (needed by closing folder)
			}
			if cont {
				cmd := '"' this.PS '" "' fName '"'
				Run cmd
			}
		} else {
			MsgBox Format("File '{}' is missing", fName), "ERROR !","T10 OK Iconx"
		}
	}
												

	viewerInBtn_Click(ctrl, item) {				; PS Launch Viewer button
		tif := this.tiff1.Value
		if FileExist(tif) {					; with TIFF file
			cmd := '"' tif '"'
			Run cmd
		} else {
			MsgBox Format("File '{}' is missing", tif), "ERROR !","T10 OK Iconx"
		}
	}


	viewerOutBtn_Click(ctrl, item) {			; PS Launch Viewer button
		tif := this.tiff3.Value
		if FileExist(tif) {					; with TIFF file
			cmd := '"' tif '"'
			Run cmd
		} else {
			MsgBox Format("File '{}' is missing", tif), "ERROR !","T10 OK Iconx"
		}
	}


	tiff3Btn_Click(ctrl, item) {  				; T2B Click on input tiff button
		tiff3 := RegRead(BundleRegKey, 'TiffOut', "C:")
		if tiff3 != "C:" {
	        SplitPath tiff3, &InFileName1, &InDir3, &InExt3, &InNameNoExt3, &InDrive3
			tiff3 := InDir3
		}
		fName := RegRead(BundleRegKey, 'TiffIn', tiff3)
        SplitPath fName, &InFileName1, &InDir3, &InExt3, &InNameNoExt3, &InDrive3
	    TiffName3 := FileSelect(1, InDir3, "Select the dir and name of the TIFF file", "*.tif;*.tiff")
		if TiffName3 != '' {
		    this.tiff3.Value := TiffName3
			RegWrite(TiffName3, 'REG_SZ', BundleRegKey, 'TiffIn')
		}
	}


	bndl3Btn_Click(ctrl, item) {  				; T2B Click on output bndl button
		mssg := "Select directory to save the BUNDLE files"
	    DirName3 := FileSelect("D", this.bndlDir3.Value, mssg)
		if DirName3 != '' {
		    this.bndlDir3.Value := DirName3
			RegWrite(DirName3, 'REG_SZ', BundleRegKey, 'BndlOutDir')
		}
	}


	bndl31_Change(ctrl, item) {  				; T2B Change name of output bndl3
		if this.bndl31.Value != ""
			RegWrite(this.bndl31.Value, 'REG_SZ', BundleRegKey, 'BndlOut31')
	}


	apply3Btn_Click(ctrl, item) {          		; T2B Click btn to launch Tif2Bndl.
		; tif2bndl -w1000 -l500 -n5  b4.bndl output.tif
		fName := this.tiff3.Value
		bndlRoot := this.bndlDir3.Value
		bndlPrefix := this.bndl31.Value
		bndl := Format('{}\{}', bndlRoot, bndlPrefix)
		if FileExist(fName) {
			s := this.drops3.Value
			cmd := Format('"tif2bndl.exe" -v -s{} "{}" "{}"', s, fName, bndl)
			;cmd := '"tif2bndl.exe" -v -s' s ' "' fName '" ' bndlPrefix 
			MsgBox(cmd)
			Run cmd
		} else
			MsgBox Format("File '{}' is missing", fName),
						"WARNING !","T10 OK Icon!"
	}


	cancelBtn_Click(ctrl, item) {				; B2T/PS/T2B Cancel button
	    message := "Are you sure you want to leave?"
		if MsgBox(message, "Cancel" , "OKCancel Icon!") == "OK"
	        ExitApp
	}


    sufixRadio3_Click(ctrl, item) {
		value := this.sufixRadio31.Value
		RegWrite(this.sufixRadio32.Value, 'REG_SZ', BundleRegKey, 'sufixRadio32')
		RegWrite(this.sufixRadio31.Value, 'REG_SZ', BundleRegKey, 'sufixRadio31')
	}

  ;OUT											; end of T2B and PS -------
  
  ;IN --- Tab4								; Begin Settings tab4 functions

	colorsp45_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'colorsp5')
	}	
	colorsp46_Change(ctrl, item) {
	    ;MsgBox(ctrl.Value, item)
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'colorsp6')
	}
	colorsp47_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'colorsp7')
	}
	colorsp48_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'colorsp8')
	}

	alpha451_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord51')
	}
	alpha452_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord52')
	}
	alpha453_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord53')
	}
	alpha454_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord54')
	}
	alpha461_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord61')
	}
	alpha462_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord62')
	}
	alpha463_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord63')
	}
	alpha464_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord64')
	}
	alpha471_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord71')
	}
	alpha472_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord72')
	}
	alpha473_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord73')
	}
	alpha474_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord74')
	}
	alpha481_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord81')
	}
	alpha482_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord82')
	}
	alpha483_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord83')
	}
	alpha484_Change(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'coord84')
	}
	
    colorchan45_Lose(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'alpha5')
	}	
    colorchan46_Lose(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'alpha6')
	}	
    colorchan47_Lose(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'alpha7')
	}	
    colorchan48_Lose(ctrl, item) {
		RegWrite(ctrl.Value, 'REG_SZ', BundleRegKey, 'alpha8')
	}
	
  ;OUT										; end Settings tab functions
  
  ;IN --- not-event related methods ==========================================

	getSuffixes(useSuffixes, radio11Value, radio12Value) {
		if useSuffixes = 1 {			            ; autoassign sufixes
			if ( radio11Value=1 )					; Index starts with 0
				return ["0","1","2","3","4","5","6","7"]
			else {
				if (radio12Value=1 )				; Index starts with 1
					return ["1","2","3","4","5","6","7","8"]
				else
					return ["C","M","Y","K","5","6","7","8"]
			}
		} else {
		    return []
		}
	}

	update_bndlRegs(InDir1, InFileName1, len) {
		RegWrite(InDir1, 'REG_SZ', BundleRegKey, 'BndlInDir')
		RegWrite(InFileName1, 'REG_SZ', BundleRegKey, 'BndlIn1')
		if this.check1.Value = 1 {
			order := this.sufixRadio11.Value this.sufixRadio12.Value
			if (order=="00"){
			this.bndl11.Value := SubStr(InFileName1, 1, len) "C.bndl"
			this.bndl12.Value := SubStr(InFileName1, 1, len) "M.bndl"
			this.bndl13.Value := SubStr(InFileName1, 1, len) "Y.bndl"
			this.bndl14.Value := SubStr(InFileName1, 1, len) "K.bndl"
			this.bndl15.Value := SubStr(InFileName1, 1, len) "O.bndl"
			this.bndl16.Value := SubStr(InFileName1, 1, len) "G.bndl"
			this.bndl17.Value := SubStr(InFileName1, 1, len) "B.bndl"
			this.bndl18.Value := SubStr(InFileName1, 1, len) "W.bndl"
			} else {
				if (order=="01" ) {
					this.bndl11.Value := SubStr(InFileName1, 1, len) "1.bndl"
					this.bndl12.Value := SubStr(InFileName1, 1, len) "2.bndl"
					this.bndl13.Value := SubStr(InFileName1, 1, len) "3.bndl"
					this.bndl14.Value := SubStr(InFileName1, 1, len) "4.bndl"
					this.bndl15.Value := SubStr(InFileName1, 1, len) "5.bndl"
					this.bndl16.Value := SubStr(InFileName1, 1, len) "6.bndl"
					this.bndl16.Value := SubStr(InFileName1, 1, len) "7.bndl"
					this.bndl16.Value := SubStr(InFileName1, 1, len) "8.bndl"
				} else {
					this.bndl11.Value := SubStr(InFileName1, 1, len) "0.bndl"
					this.bndl12.Value := SubStr(InFileName1, 1, len) "1.bndl"
					this.bndl13.Value := SubStr(InFileName1, 1, len) "2.bndl"
					this.bndl14.Value := SubStr(InFileName1, 1, len) "3.bndl"
					this.bndl15.Value := SubStr(InFileName1, 1, len) "4.bndl"
					this.bndl16.Value := SubStr(InFileName1, 1, len) "5.bndl"
					this.bndl16.Value := SubStr(InFileName1, 1, len) "6.bndl"
					this.bndl16.Value := SubStr(InFileName1, 1, len) "7.bndl"
				}
			}
		}
		RegWrite(this.bndl11.Value, 'REG_SZ', BundleRegKey, 'BndlIn11')
		RegWrite(this.bndl12.Value, 'REG_SZ', BundleRegKey, 'BndlIn12')
		RegWrite(this.bndl13.Value, 'REG_SZ', BundleRegKey, 'BndlIn13')
		RegWrite(this.bndl14.Value, 'REG_SZ', BundleRegKey, 'BndlIn14')
		RegWrite(this.bndl15.Value, 'REG_SZ', BundleRegKey, 'BndlIn15')
		RegWrite(this.bndl16.Value, 'REG_SZ', BundleRegKey, 'BndlIn16')
		RegWrite(this.bndl16.Value, 'REG_SZ', BundleRegKey, 'BndlIn17')
		RegWrite(this.bndl16.Value, 'REG_SZ', BundleRegKey, 'BndlIn18')
	}

    update_Dims(ctrl, item) {					; Update width, length, sizesA, dims
		if this.sizesA != [""] {
			for key, value in this.sizesA {			; Delete list from dropdown
				this.dimensions1.Delete(1)
			} ;OUT
		}
		this.bndl11_Lose(ctrl, item)			; Update array sizesA
		for key, value in this.sizesA {			; Fill new list of dropdown
		    this.dimensions1.Add([value])
		} ;OUT

		this.dimensions1.Value := 1				; Choose first element
		this.dims1_Change(ctrl, item)			; Update width and length
	}

  ;OUT 											; end of non-event methods
	
}												; end of GUI subclass

	update_Suffixes(this, useSuffixes, numBndls) {
		this.sufixRadio11.Enabled := useSuffixes
		this.sufixRadio12.Enabled := useSuffixes
		this.sufixRadio13.Enabled := useSuffixes
		color := useSuffixes=1 ? "cBlack" : "cGray"
		this.sufixRadioText.SetFont(color)
	}

If (A_ScriptFullPath = A_LineFile)
    Bndl2TiffGui.Show()

;=============================================================================
; TODO: -------------------------------------------------------
;    (1) Conseguir que se genere el ejecutable!!!
;    Implementar la pestaña 4, para los settings
;    Incorporar el bitsperpixel (2/4) en el calculo del size
;    la extension .BNDL debería poder ir con mayúsculas o minúsculas
;    Si el número de Bundle Files es 0, los nombres de los bundle se han de
;      poder editar, o sea, poner el check a 1, tras guardar el valor anterior,
;      que se restaura si volvemos a poner el numero de files a >0.
;    Aviso de Overwriting del (TIF) output file.
;    Verificar que los tamaños de fichero Bundle son semejantes (lo hace el EXE)
;    Implementar NULL para poder saltarnos un canal, cuando c>0 y check1=1
;    Chequear la existencia de los directorios que se entran a mano.
;    Validación de directorio para TIF final cuando no existe
;    Gestionar control de errores (Status bar?)
;    Rellenar el texto de ayuda
; --------- ADVANCED -------------
;    La ayuda en otra ventana?, ...permite  mejor formateo
;    Lanzar el pluging de Photoshop (si fuera posible)
;    Previsualización de un canal/fichero de BNDL, en pequeño ?, más rápido
;    Tooltips ?
;    Settings?
;    drag and drop?
;    ---------------- Partially done ---------------------------
;    When tif has more than 4 colors, it has to be converted with tifficc
;	 Leer el nombre del campo en el Edit box de los bundles
;    AL poner check de sufijos, actualizar las cajas de Edit (visualizar)
;    UI Extender cajas de bundle names, quizá poner un texto (1: 2: 3:,...)
;    Decidir si apply en 1 usa los nombres en las cajas o el sufijo
;    Lanzar los programas CLI con sus parámetros, usando RunCmd
;      Redirigir el stdout o bien capturar un stream y mostrar en un GUI
;      verificar extensiones de tiff, bndl
;    Apply must check all params are OK (leer FatalError en CLIs)
;    Gestionar multiples bndls
;    Partir directorio y nombre de fichero
;    rutina de validacion en los incrementales
;	 control Incremental lxw with possible values
;    Sacar del BNDL el numero de drop sizes que se encuentran y mostarlo en el UI
;    preasignar w, l en funcion del bundle escogido
;       mirando el tamaño del fichero.
;    OwnDialogs to make them modal
;    ---------------- Completed -------------------------------
;    Verificar que existen los ficheros TIF antes de lanzar el visualizador
;    Si se pone check a 1, se desactivan los radio buttons de 0123,1234,CMYK,
;    Falta guardar el valor del check box en el <registry
;    Si el numero de bundle files se introduce a mano, no se ocultan/muestran bien
;    Al inicializar se sobreescribe el Registry con los nombres de Bundle incorrecto
;    al abrir cuando el check box de sufijos está activado...
;    Explicar en la ayuda el uso de sufijos o # canales
;    Detectar donde está guardado ejecutable de PS, ponerlo en Registry)
;    MISSING validacion de entrada manual del nombre del tif, DONE
;    MISSING all validations, 2 to 6 of bnld1x DONE
;    Salvar en Registry la resolucion del TIFF de salida
;    ojo a los directorios con espacios blancos!!! DONE
;    Si cambio Channel suffixes y luego voy a Apply, falta el bundle_4...
;    Salvar en Registry el sufijo de salida
;    Lanzar la búsqueda en el directorio...
;    Validacion fichero existe en input bundle file,
;      preasignar valores de width y length
;    Save/request vars i.n Registry
;    -----------------BNDL2TIFF--------------------------
;	 Añadir tag de la fecha del dia al TIFF
;	 Añadir el tag de Photoshop para guardar los canales alpha
;	 + Añadir Tag de ExtraSamples	(ver el DUMP del TIF)
;    + Generación del TIF con compresión (añadir ZLIB  a LIBTIFF
;    bndl2tif debe poder hacer sufijos con 0 o 1... y CMYK
;    -----------------TIFF2BNDL--------------------------
;    Uso de CMYK / 1234 / 0123, pero no en el tif2bndl!!!

;
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 09 Feb 2023, 03:25, edited 1 time in total.
Reason: Please use code tags in future posts. Thank you!

TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compiling V2 scripts

Post by TAC109 » 09 Feb 2023, 18:07

Your script is trying to interact with the v2 'dash' system. I don’t think this will be possible in a compiled program.
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

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 11 Feb 2023, 06:15

"interacts with the v2 'dash' system..."

Which means...?
What should I do, then? 'Cause it works as a command line.

TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compiling V2 scripts

Post by TAC109 » 12 Feb 2023, 19:09

I attempted to run your script, but I see that it modifies the registry and expects one or more files to be present. I then reset my machine from a recent image to remove any changes your script might have made to my system.

When you compile the script you should select a v2 base file, as your script is v2.

Compiled scripts may act differently than free-standing scripts for a variety of reasons. You will need to debug your compiled script using normal debugging methods, such as inserting commands to record the code position, etc.

Good luck!
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

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 13 Feb 2023, 20:41

HI,

I choose a V2 base, of course.
The issue is that it compiles, but when I launch the EXE, it just returns to the command prompt.
Your point of "it´s interacting with the DASH system" gave me hope, but the thing is I don´t know what should I do to get rid of that interaction I have created without knowing I was doing such a thing.

In other words, what should I do to create a compiled version that behaves (or almost) like an interpreted one?
(say, what events, structs, calls,... change the behavior of a stand-alone script?)
As it is, no debugging is needed, it works as expected and even catches possible errors (missing files, non existing dirs, ...)

Thanks for your help,
Ignacio



PS: ======================================
just for your info,

REGISTRY
my script uses the registry to keep track of the latest values assigned in the UI. So, when you launch it, it will display the values you selected last time.
All of them are under a single key of the registry: BundleRegKey := 'HKCU\Software\EFI\BundleEditor\'
If the keys don´t exist, assigns default values.
So, your system is safe, delete those keys an everything will be clean, as when you started.

INCLUDE FILES
The only files it expects are those installed by AutoHotkey itself, in the UX directory
#include "C:\Program Files\AutoHotkey\UX\inc\bounce-v1.ahk"
#include "C:\Program Files\AutoHotkey\UX\inc\ui-base.ahk"
#include "C:\Program Files\AutoHotkey\UX\ui-launcherconfig.ahk"

I may add some files for
- running Runcmd(), that does not work for me (avoid launching a CMD window, hiding it)
- enabling drag and drop files from the explorer to the UI

TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compiling V2 scripts

Post by TAC109 » 13 Feb 2023, 21:28

iruizdeconejo wrote:
13 Feb 2023, 20:41

The issue is that it compiles, but when I launch the EXE, it just returns to the command prompt.

As it is, no debugging is needed
Clearly these two statements are incompatible. You may have debugged your script when running free-standing, but clearly the compiled script requires further debugging.

I wrote:
Compiled scripts may act differently than free-standing scripts for a variety of reasons. You will need to debug your compiled script using normal debugging methods, such as inserting commands to record the code position, etc.
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

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 15 Feb 2023, 03:47

I can not run the compiled script: it just returns to the command prompt without doing anything.
Just let me know what I need to change to obtain an exe that begins execution properly, and I´ll believe in you.

I am trying to get from you specific actions, lines of my code I can act on, but have not got a single "do this" or "do that".
The most promising and closer to a fact has been "your script interacts with the DASH system"
The rest, I am sorry to say, has been generic comments that have not taken me closer to a solution. I´m a scientist, believe in facts.

Could you share with me insights of the programs you have develop, i.e., issues you had to resolve when going from script to stand-alone app? That would be a starting point.

Thanks,
Ignacio

SandyClams
Posts: 63
Joined: 02 Jul 2020, 11:55

Re: Compiling V2 scripts

Post by SandyClams » 15 Feb 2023, 10:59

@iruizdeconejo,

I tried to run your script according to the code you provided, and even went as far as editing it in various places in order to prevent its failing as a result of specific errors, but I am unable/unwilling to toil any more to get the script to successfully run. Does the script require that it be launched in a specific directory, or that other necessary files exist on the filesystem?

TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compiling V2 scripts

Post by TAC109 » 15 Feb 2023, 19:46

@iruizdeconejo
Are you the author of this script? If not I suggest you contact the script author.

Anyway, I have done some analysis of this script. Some of the standard variables that vary depending on whether the script is compiled or not are:
  • A_ScriptFullPath and A_LineFile. These variables are compared against each other at lines 141 and 1110 in your script, and near the end of ux\ui-launcherconfig.ahk which is included.
  • A_AhkPath. This variable is referenced in line 2 in ux\inc\common.ahk, which is indirectly included, and near the end of ux\ui-launcherconfig.ahk which is included.
You can check the documentation for any other standard variables that differ.

If you are the author of this script you will know what effect these references will have on the compiled script's execution.
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

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 19 Feb 2023, 20:32

Hi,
thanks for the hints. I appreciate your help a lot -- I know how cumbersome looking at somebody else´s code may be.

Yes, I am the author of the script.
It runs independently of the directory where it resides.
There are some files that belong to the last release of AHK, say those that reside in "C:\Program Files\AutoHotkey\UX"
In other words, I have not written nor edited the files under that directory. They were placed there by the installer.
I assumed they provide the functionality of the new GUI in AHK v.2.0, that is, AutoHotkeyUxGui, which is the base class of my app.

What I´ll do is to write a simplified version (currently it has several Tabs, I´ll include just one, and eliminate the rest of the code, including the registry calls, read and write as well, and see if that version compiles... and executes.

I find the documentation is a little scarce, or at least I´ve been unable to find it, and have adopted the trial and error approach...

Thanks,
Ignacio

iruizdeconejo
Posts: 9
Joined: 24 Jan 2023, 19:35

Re: Compiling V2 scripts

Post by iruizdeconejo » 01 Mar 2023, 03:48

SOLVED!!! :)

In the end the solution has been the easiest one: comment out the line that reads
If (A_ScriptFullPath = A_LineFile)
and force the execution of the script:
Bndl2TiffGui.Show()
It was somehow suggested by TAC109, :bravo: so, thanks a million!!!
Ignacio

Post Reply

Return to “Ask for Help (v2)”