Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-08-12]

Compartir enlaces, herramientas y otros recursos de Internet que puedan ser útiles para programar en AutoHotkey

Moderator: Flipeador

User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-08-12]

13 May 2018, 21:07



Compilador en español para AutoHotkey v2

Compilador no oficial para la versión 2 de AutoHotkey, totalmente renovado, con nuevas funcionalidades y una interfaz mucho más amigable. Esta versión esta basada en el compilador Ahk2Exe de fincs.
El compilador cuenta con un procesado experimental para reducir y optimizar el código lo mejor posible, si te da error en algún script, por favor, comenta aquí con el error que te muestra el compilador y la parte de código que te está dando problemas, lo intentaré solucionar lo más pronto posible.
Image

[spoiler2=Clic para ver más imagenes]Image
Image[/spoiler2]

Puedes ver todas las nuevas características en el enlace de descarga, como así también la documentación. El compilador es el archivo Ahk2Exe.exe, no depende de ningún archivo externo, todos los demás archivos son solo para la compilación del compilador (Ahk2Exe.ahk). También se incluye una versión de 64-bit Ahk2Exe64.exe, aunque no hay ninguna diferencia con la de 32-bit.




Descarga
Para descargar el compilador dirígete a la pagina de Releases y descarga el archivo Ahk2Exe.exe. La versión por defecto es de 32-Bit.
Página oficial, código fuente y documentación en GitHub: https://github.com/flipeador/Ahk2Exe. En el código fuente se incluyen ambos archivos binarios de 32 y 64-Bit.
Para compilar es necesario tener los archivos .bin en el mismo directorio que el compilador. En ciertos casos puede que necesite ejecutar el compilador como Administrador. No es necesario tener instalado AutoHotkey para poder compilar los Scripts.
coffee
Posts: 133
Joined: 01 Apr 2017, 07:55

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

13 Jun 2018, 00:47

Estoy viendo que tu source no usa "iLib" como los otros compilers para incluir las funciones que se incluyen automaticamente (sin usar includes explicitos).

Es intencional? A lo mejor no consigo la nota en github.

Ejemplo file structure
script.ahk
Lib\ftest.ahk

script.ahk contiene

Code: Select all

ftest()
ftest.ahk contiene

Code: Select all

ftest()
{
	msgbox("Autoincluded")
}
El compiled exe de script.ahk falla, debido a que ftest.ahk no se autoincluyo. Esto es intencional?
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

13 Jun 2018, 06:39

Hola coffee,
A que otros compiladores te refieres, nunca he leído sobre esa funcionalidad. Si AHK no lo soporta, ¿Que sentido tiene que el compilador si lo haga?.
Edit: Parece que si existe esa funcionalidad, lo estaré viendo para la proxima actualización, aunque no prometo nada, no lo veo demasiado importante, lo considero de MUY baja prioridad. Gracias.

Aclaro que este compilador no esta terminado, aún faltan muchas cosas por mejorar y corregir, ya he hecho varias correcciones pero aún no actualizo en GitHub (estuve, estoy y estaré ocupado estas semanas como para seguir avanzando). En futuras versiones de AutoHotkey 2 tal vez la directiva #Include pase a trabajar con expresiones, así que habra que corregir eso.


:wave:
coffee
Posts: 133
Joined: 01 Apr 2017, 07:55

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

13 Jun 2018, 14:18

Flipeador wrote:Hola coffee,
A que otros compiladores te refieres, nunca he leído sobre esa funcionalidad. Si AHK no lo soporta, ¿Que sentido tiene que el compilador si lo haga?.
Edit: Parece que si existe esa funcionalidad, lo estaré viendo para la proxima actualización, aunque no prometo nada, no lo veo demasiado importante, lo considero de MUY baja prioridad. Gracias.
Es parte de autohotkey itself. Aparte de incluir funciones no-explicitas, tambien hace syntax checking del script para asegurarse que sea valido con respecto al ejecutable ahk que se haya usado para escribirla.
En vez de checkear syntax fija a una version de autohotkey en el compiler, Autohotkey.exe por si solo chequea que el script sea valido.
Ejemplo: si alguien escribe un script para una version hypotetica v2a098, y v2a099 cambia algo que no es compatible con v2a098, el compiler validara el script como correcto siempre y cuando el "autohotkey.exe" que este en el parent directory sea v2a098.

Peek a autohotkey source:

Code: Select all

		else if (!_tcsicmp(param, _T("/iLib"))) // v1.0.47: Build an include-file so that ahk2exe can include library functions called by the script.
		{
			++i; // Consume the next parameter too, because it's associated with this one.
			if (i >= __argc) // Missing the expected filename parameter.
				return CRITICAL_ERROR;
			// For performance and simplicity, open/create the file unconditionally and keep it open until exit.
			g_script.mIncludeLibraryFunctionsThenExit = new TextFile;
			if (!g_script.mIncludeLibraryFunctionsThenExit->Open(__targv[i], TextStream::WRITE | TextStream::EOL_CRLF | TextStream::BOM_UTF8, CP_UTF8)) // Can't open the temp file.
				return CRITICAL_ERROR;
		}

Snippet de fincs ahk2exe. Puedes ver el uso de errorstdout y el compiler chequeando el log generado por autohotkey para tirar un mensaje que el syntax es invalido.
Te puedes ahorrar el tiempo/effort de chequear manualmente que el script sea valido y dejar que el ejecutable autohotkey.exe lo haga con ilib para la version que este disponible. Es practicamente una de las razones por la cual el compiler v1 de lexikos y fincs todavia funcionan bien para compilar scripts v2 incluso con el chequeo de syntax, porque Autohotkey.exe es el que lo hace, no el compiler.

Code: Select all

	Loop, % !!IsFirstScript ; equivalent to "if IsFirstScript" except you can break from the block
	{
		static AhkPath := A_IsCompiled ? A_ScriptDir "\..\AutoHotkey.exe" : A_AhkPath
		IfNotExist, %AhkPath%
			break ; Don't bother with auto-includes because the file does not exist
		
		Util_Status("Auto-including any functions called from a library...")
		ilibfile := A_Temp "\_ilib.ahk", preprocfile := ScriptDir "\_ahk2exe.tmp~"
		IfExist, %ilibfile%, FileDelete, %ilibfile%
		IfExist, %preprocfile%, FileDelete, %preprocfile%
		AhkType := AHKType(AhkPath)
		if AhkType = FAIL
			Util_Error("Error: The AutoHotkey build used for auto-inclusion of library functions is not recognized.", 1, AhkPath)
		if AhkType = Legacy
			Util_Error("Error: Legacy AutoHotkey versions (prior to v1.1) are not allowed as the build used for auto-inclusion of library functions.", 1, AhkPath)
		tmpErrorLog := Util_TempFile()
		RunWait, "%AhkPath%" /iLib "%ilibfile%" /ErrorStdOut "%AhkScript%" 2>"%tmpErrorLog%", %FirstScriptDir%, UseErrorLevel
		FileRead,tmpErrorData,%tmpErrorLog%
		FileDelete,%tmpErrorLog%
		if (ErrorLevel = 2)
			Util_Error("Error: The script contains syntax errors.",1,tmpErrorData)
		IfExist, %ilibfile%
		{
			PreprocessScript(ScriptText, ilibfile, ExtraFiles, FileList, FirstScriptDir, Options)
			FileDelete, %ilibfile%
		}
		StringTrimRight, ScriptText, ScriptText, 1 ; remove trailing newline
	}
Peek al ilib file

Code: Select all

#Include C:\AHK\Tests\a2e\Lib\
#IncludeAgain C:\AHK\Tests\a2e\Lib\ftest.ahk
Como estas usando non-autohotkey-compatible syntax y corrigiendola con el compiler
Detectar y remover comentarios en el script. Se incluye detección de comentarios en expresiones (actualmente no soportado por AHK), por ejemplo: expr+1 /* comentario */ expr+1 --> expr+1 expr+2; comentarios en línea ; y comentarios en bloque /**/.
La inclusion del ilib file tendria que ocurrir despues de que la correccion de arriba haya occurrido. Posiblemente antes del return en la seccion "; Terminar y devolver el código procesado". Si no Autohotkey.exe devolveria error.



De todas formas dejame ver si logro hacer que funcione en tu version y ahi veras si quieres hacer el merge.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

13 Jun 2018, 14:39

No estoy en casa en este momento, no puedo comprobar nada. Aún así, ¿Cual es la ventaja de esto?, ¿No crees que utilizar Include de forma explicita reduce confusiones?.
De todas formas, cuando esté en casa lo veré bien. Lo de comprobar sintaxis utilizando la versión actual de AHK instalada no lo quise implementar en un principio porque lo veía innecesario, y complicaba el código fuente, el cual trato de mantener lo mas claro y limpio posible, además, para llevar a cabo eso, debo utilizar archivos temporales, que no me termina de convencer. Aún así, lo voy a estar revisado, aún queda MUCHO por mejorar el compilador.
Te cuento que tengo varias mejoras y correcciones ya hechas pendientes, tengo pensado reescribir la función ProcessLine y remover el "objeto cadena", cuando termine con eso actualizaré en GitHub.
coffee
Posts: 133
Joined: 01 Apr 2017, 07:55

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

14 Jun 2018, 05:48

Flipeador wrote:No estoy en casa en este momento, no puedo comprobar nada. Aún así, ¿Cual es la ventaja de esto?, ¿No crees que utilizar Include de forma explicita reduce confusiones?.
Usar include explicito a veces reduce confusion y a veces no, a veces ahorra tiempo y a veces no. Usar include explicito te obliga a incluir todo lo demas que haya en un library file, si necesitas una funcion nada mas, tienes que traer todo. Asi las funciones nunca se ejecuten, el interpreter de autohotkey les hace parsing con syntax checking y todo.
Si tienes una libreria bien modular donde bastantes de las funciones son snippets, o wrappers en sus files individuales, la inclusion manual es tediosa. Hay funciones que de por si merecen ser autoincluidas cuando son bien streamlined y self-explanatory, o cuando quieres proveer una funcionalidad default poniendolas en el standard library (lib directory in autohotkey.exe's directory), en especial WinAPI wrappers around DllCalls.
Classes, funciones co-dependientes o bien complejas, con toda la razon deberian ser incluidas explicitamente. De resto, tener que hacer muchos includes, o tener que embolsar funciones en un solo file, que trae los problemas relaciones de falta de modularidad, pierde la comodidad que esto ofrece.

Esto esta incluido en Autohotkey como una funcionalidad de comodidad (quality of life) y ya tiene tiempo incluido. A la hora de compilar no hay confusion ya que normalmente el compiler incluye todo. En dado caso no seria cuestion de "ventaja de esto" es cuestion de que si alguien desea usar tu compiler, y esta contando con la autoinclusion de funciones simples que esta documentado en el manual de autohotkey, no van a funcionar. Menciono esto ya que lo tienes publicado en tu signature i.e advertisement, asi que me imagino que quisieras que otras personas tambien lo usen. Al menos de Lexikos te haya dicho que va a quitar los autoincludes y iLib, estarias yendo contra funcionalidad documentada.
Flipeador wrote:Lo de comprobar sintaxis utilizando la versión actual de AHK instalada no lo quise implementar en un principio porque lo veía innecesario
No es la version instalada, es la version que este en el directorio arriba de ahk2exe o la que este corriendo ahk2exe (o incluyendo una nueva, la que este en el mismo directory de ahk2exe). No es la que sale en el registro.
El syntax checking es byproduct de usar /iLib para incluir autoincludes, es un bono. La syntax deberia (o tiene) que hacer matching con el interpreter de autohotkey. Autohotkey.exe hace su propio syntax checking during runtime, lo cual garantiza 100% compatibilidad de lo que escribiste, y no tienes forma de deshabilitarlo. Igual va a ir linea por linea revisando todo, asi no haya comentarios o blank lines o todo este incluido. Por lo cual en dado caso es otro "quality of life" a la hora de compilar.
Flipeador wrote:complicaba el código fuente, el cual trato de mantener lo mas claro y limpio posible, además, para llevar a cabo eso, debo utilizar archivos temporales, que no me termina de convencer. Aún así, lo voy a estar revisado, aún queda MUCHO por mejorar el compilador.
Lo de los archivos temporales lo entiendo. Hace unas horas le hice a Lexikos un commit para que permita que los scripts arrancados por StdIn, puedan usar el local library asumido en el original working directory. El behavior actual es que el a_scriptdir se pone en blanco en runtime y no se pueden cargas los libs locales usando StdIn.
Por ejemplo /iLib * te deja leer el output en StdOut, y /ErrorStdOut, te deja usar leer errores por StdErr y usando * como script path y writing a StdIn el script (NewCode variable) te deja correrla sin tener que usar para nada temporary files.

Este es el example snippet de la seccion abajo "; Terminar y devolver el código procesado" en el condicional de if (Tree == ""), que me esta funcionando a mi, sin usar ningun temp file, para que mas o menos tengas una idea. Es largo por los comentarios detallando todo, de por si no ocupa mucho espacio. Cuando tengas algun tiempo lo revisas a ver.
Usando la clase "Subprocess" de cocobelgica que estaria en su propio file en Lib e incluida al final de scriptparser.

Esta usando el pull request https://github.com/Lexikos/AutoHotkey_L/pull/102

Code: Select all

    If (Tree == "")    ; ¿estamos procesando el script principal que se va a compilar?
	{
		;// This entire behavior could be overriden by a command line switch, something like /nocheck,
		;// or a checkbox in the GUI, and it would never take place if wrapped inside an if.
		
		local ahkexe:="" ;// Will contain Autohotkey.exe after lookup (this may not be necessary, since we may already have the autohotkey.exe in a variable,
		;// but I don't know which one could be similar to the checks below for the path.).
		;// If this is done already somewhere else we can simply use that variable.

		local script_streams := "" ;// Will contains subprocess object
		local script_stderr := "" ;// Will contain the readout of stderr from subprocess object
		local script_stdout := "" ;// Will contain the readout of stdout from subprocess object

		if A_IsCompiled ;// Ahk2Exe is compiled
		{
			;// As mentioned above, we may already have the executable stored somewhere, or maybe not, so as an example, get one.
			if !FileExist(ahkexe := A_ScriptDir "\..\AutoHotkey.exe") ;// In parent dir
			&& !FileExist(ahkexe := A_ScriptDir "\AutoHotkey.exe") ;// In same dir
				ahkexe := ""
		}
		else ;// Ahk2exe is not compiled
			ahkexe := A_AhkPath ;// Use same exe that's running Ahk2Exe.ahk

		if (ahkexe)
		{
			Loop 2
			{
				;// This is done inside a loop. First time will run NewCode, get StdOut and include any missing autoincludes,
				;// but we don't grab StdErr (since missing functions are considered errors). Should be done no more than two times.
				;// Second time will rerun NewCode again after autoincludes are included, will clear out script_stdout and break out of the loop.
				;// This is done to have an up-to-date Stderr below, that  will check if there are any true syntax errors.
				;// (Functions that do not exist anywhere will error for example).
				
				;// Script streams, object from SubProcess by Cocobelgica.
				;// A modified version of Lexikos' ExecScript() can be used for smaller code, but this guarantees
				;// that no CMD window shows.
				;// Using a_space in string below to denote the separation of each element and the use of internal double quotes.
				;// /iLib * is StdOut, last * is script StdIn.
				script_streams := new SubProcess('"' ahkexe '"' . a_space . '/iLib * /ErrorStdOut *')
				script_streams.StdIn.Write(NewCode) ;// Write current, newcode i.e the new "cleaned and fixed" script
				script_streams.StdIn.Close() ;// Close StdIn so it can run.

				;// StdOut will contain the output of the iLib command. Essentially the pairs of #Include and #IncludeAgain.
				;// Do this first before checking the syntax again. Since missing function definitions (not automatically included,
				;// are considered errors and reported in stderr.
				;// We want to include all missing functions.
				if ( script_stdout := script_streams.StdOut.ReadAll() ) ;// Grab StdOut (coming from iLib)
				{
					Loop parse, script_stdout, "`r`n"
					{
						loopField:= a_loopField ;// Quality of life
						if !loopField
						{
							;// Just decrease a_index otherwise it gets all borked due to skipping new lines,
							;// where a_loopfield becomes empty, but its still counted.
							;// This way modulo function below works properly.
							--a_index
							continue
						}
						
						;// The iLib file is fixed syntax. There's no ambiguity here. It will always have the same layout.
						if (Mod(a_index, 2) != 0) ;// Number is odd (#include dir line)
						{
							A_Workingdir := RTrim(SubStr(loopField, 10), "\") ;// Right side of #Include
							;// It's a path to a directory, use it to set A_WorkingDir as is done in previous #include checks.
						}
						else if (Mod(a_index, 2) = 0) ;// Number is even (#includeagain file line)
						{
							NewCode .= PreprocessScript(SubStr(loopField, 15), Tree . "`n" . Script, FileList, Directives) . "`n"
							;// SubStr(loopField, 15) is right side of #IncludeAgain excluding space.
							;// Since the iLib file is #IncludeAgain, above PreProcessScript call doesn't check IsAlreadyIncluded()
							;// and is done unconditionally.
						}
					}
					
					script_stdout:="" ;// Blank it just in case. May not be necessary.
				}
				else
					break
			}

			;// StdErr will contain any true syntax errors, i.e the output of ErrorStdOut which is the exception autohotkey would have thrown,
			;// as checked by Autohotkey.exe. Will work across versions.
			;// If there are function calls that are not manually included and do not exist in any library, they will show here.
			;// This would be after the compiler does it's own thing (like change non-autohotkey compatible comments).
			if ( script_stderr := script_streams.StdErr.ReadAll() ) ;// Grab StdErr (coming from ErrorStdOut)
			{
				Util_Error("Script contains syntax errors with respect to the used AutoHotkey binary.", script_stderr, true)
				;// Syntax errors could be displayed as a GUI or in msgbox (as done currently, but may be be too big for msgbox if there are too many),
				;// to provide more data to the user. Or the user can simply run the ahk file, which should have been done for testing.
				;// Or perhaps the user is using the wrong binary for the syntax he's using (different minor version of autohotkey).
				;// Either way, this will check that the script has proper syntax for the chosen binary file,
				;// as error precheck, so the user doesn't have to run the compiled exe to see if its valid.
			}
		}
		
        Return {	Code: "; <COMPILER: v" . A_AhkVersion . ">`n" . Trim(NewCode, "`t`s`r`n")
					,	Directives: Directives
					,	Script: Script }
	} ;// Ending of (Tree == "")
Este es subprocess de cocobelgica, de alternativa puede ser una custom version de ExeScript() de Lexikos (en la documentacion de autohotkey)

Code: Select all

class Subprocess
{
	__New(cmd, cwd:="")
	{
		DllCall("CreatePipe", "Ptr*", stdin_read, "Ptr*", stdin_write, "Ptr", 0, "UInt", 0)
		DllCall("SetHandleInformation", "Ptr", stdin_read, "UInt", 1, "UInt", 1)
		DllCall("CreatePipe", "Ptr*", stdout_read, "Ptr*", stdout_write, "Ptr", 0, "UInt", 0)
		DllCall("SetHandleInformation", "Ptr", stdout_write, "UInt", 1, "UInt", 1)
		DllCall("CreatePipe", "Ptr*", stderr_read, "Ptr*", stderr_write, "Ptr", 0, "UInt", 0)
		DllCall("SetHandleInformation", "Ptr", stderr_write, "UInt", 1, "UInt", 1)

		static _STARTUPINFO
		if !VarSetCapacity(_STARTUPINFO)
		{
			sizeof_si := A_PtrSize==8 ? 104 : 68 ; 40 + 7*A_PtrSize + 2*(pad := A_PtrSize==8 ? 4 : 0)
			VarSetCapacity(_STARTUPINFO, sizeof_si, 0)
			NumPut(sizeof_si, _STARTUPINFO, "UInt")
			NumPut(0x100, _STARTUPINFO, A_PtrSize==8 ? 60 : 44, "UInt") ; dwFlags=STARTF_USESTDHANDLES)
		}

		NumPut(stderr_write, NumPut(stdout_write, NumPut(stdin_read, _STARTUPINFO, A_PtrSize==8 ? 80 : 56)))

		static sizeof_pi := 8 + 2*A_PtrSize
		this.SetCapacity("PROCESS_INFORMATION", sizeof_pi)
		proc_info := this.GetAddress("PROCESS_INFORMATION")

		if IsObject(cmd)
		{
			static quot := Func("Format").Bind("{1}{2}{1}", Chr(34))
			length := cmd.Length(), args := cmd, cmd := ""
			for i, arg in args
				cmd .= (InStr(arg, " ") ? quot.Call(arg) : arg) . (i<length ? " " : "")
		}

		success := DllCall("CreateProcess", "Ptr", 0, "Str", cmd, "Ptr", 0
			, "Ptr", 0, "Int", 1, "UInt", 0x8000000, "Ptr", 0, "Str", cwd=="" ? A_WorkingDir : cwd
			, "Ptr", &_STARTUPINFO, "Ptr", proc_info)
		if (!success)
			throw Exception("Failed to create process.", -1, cmd)

		this.StdIn  := new Subprocess.StreamWriter(stdin_write)
		this.StdOut := new Subprocess.StreamReader(stdout_read)
		this.StdErr := new Subprocess.StreamReader(stderr_read)

		DllCall("CloseHandle", "Ptr", stdin_read)
		DllCall("CloseHandle", "Ptr", stdout_write)
		DllCall("CloseHandle", "Ptr", stderr_write)
	}

	__Delete()
	{
		proc_info := this.GetAddress("PROCESS_INFORMATION")
		DllCall("CloseHandle", "Ptr", NumGet(proc_info + 0))         ; hProcess
		DllCall("CloseHandle", "Ptr", NumGet(proc_info + A_PtrSize)) ; hThread
	}

	__Handle[] ; hProcess
	{
		get {
			return NumGet(this.GetAddress("PROCESS_INFORMATION"))
		}
	}

	ProcessID[]
	{
		get {
			return NumGet(this.GetAddress("PROCESS_INFORMATION") + 2*A_PtrSize, "UInt") ; dwProcessId
		}
	}

	Status[] ; Running=0 , Done=1
	{
		get {
			return !(this.ExitCode == 259) ; STILL_ACTIVE=259
		}
	}

	ExitCode[] ; STILL_ACTIVE=259
	{
		get {
			if DllCall("GetExitCodeProcess", "Ptr", this.__Handle, "UInt*", exit_code)
				return exit_code
		}
	}

	Terminate(exit_code:=0)
	{
		if (exit_code == 259) ; STILL_ACTIVE
			throw Exception("Exit code 'STILL_ACTIVE' is reserved", -1, exit_code)

	; use gentler method - attempt to close window(s) first
		prev_dhw := A_DetectHiddenWindows
		DetectHiddenWindows On
		hwnd_lfw := WinExist() ; store current Last Found window

		wintitle := "ahk_pid " . this.ProcessID
		while (hwnd := WinExist(wintitle)) {
			WinClose
			if WinExist("ahk_id " . hwnd)
				WinKill
		}

		WinExist("ahk_id " . hwnd_lfw) ; restore Last Found window
		DetectHiddenWindows %prev_dhw%

	; still running, force kill
		if (this.Status == 0)
			DllCall("TerminateProcess", "Ptr", this.__Handle, "UInt", exit_code)
	}

	class Pipe
	{
		__New(handle)
		{
			this.__Handle := handle + 0
		}

		__Delete()
		{
			this.Close()
		}

		Close()
		{
			try this._Stream.Close(), this._Stream := ""
			DllCall("CloseHandle", "Ptr", this.__Handle)
		}

		_Stream := ""

		Stream[]
		{
			get {
				if (!this._Stream)
					this._Stream := FileOpen(this.__Handle, "h")
				return this._Stream
			}
		}

		Encoding[]
		{
			get {
				return this.Stream.Encoding
			}

			set {
				return this.Stream.Encoding := value
			}
		}
	}

	class StreamReader extends Subprocess.Pipe
	{
		Read(chars*)
		{
			return this.Stream.Read(chars*)
		}

		ReadLine()
		{
			return this.Stream.ReadLine()
		}

		ReadAll()
		{
			all := ""
			encoding := this.Encoding
			VarSetCapacity(data, 4096)
			while (read := this.Stream.RawRead(data, 4096))
				NumPut(0, data, read, "UShort"), all .= StrGet(&data, read, encoding)
			return all
		}

		RawRead(ByRef var_or_address, bytes)
		{
			return this.Stream.RawRead(var_or_address, bytes)
		}

		Peek(ByRef data:="", bytes:=4096, ByRef read:="", ByRef avail:="", ByRef left:="")
		{
			VarSetCapacity(data, bytes)
			return DllCall("PeekNamedPipe", "Ptr", this.__Handle, "Ptr", &data
				, "UInt", bytes, "UInt*", read, "UInt*", avail, "UInt*", left)
		}
	}

	class StreamWriter extends Subprocess.Pipe
	{
		Write(string)
		{
			return this.Stream.Write(string)
		}

		WriteLine(string)
		{
			return this.Stream.WriteLine(string)
		}

		RawWrite(ByRef var_or_address, bytes)
		{
			return this.Stream.RawWrite(var_or_address, bytes)
		}
	}
}
Si lexikos niega el commit, obviamente ya arruina lo de arriba :lol: . Lo unico que yo implemente la opcion de minificar scripts. Asi como lo tiene javascript y css, que limpian todo el file y hacen un output llamado "file.min.ext", en dado caso "file.min.ahk" con todo ya incluido para redistribution. Un script file un poco mas streamlined sin comentarios ni nada, por lo cual tmp file es el archivo minificado, y tengo no problema en que se genere.
coffee
Posts: 133
Joined: 01 Apr 2017, 07:55

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

14 Jun 2018, 16:15

This is just a bug report. En caso de que no lo hayas arreglado todavia.

El compiler no soporta comentarios de este tipo:

Code: Select all

/**
NOT
SUPPORTED BY
COMPILER
**/
Msgbox("Hello")
Msgbox("Not showing")
El compiler excluye todo bajo el block comment, i.e ninguno de los Msgbox aparecen en el script file que se incluye en el archivo binario. Ese es un block comment valido en Autohotkey.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-05-25]

14 Jun 2018, 19:47

Muchas gracias por tus comentarios coffee, tienes toda la razón y estoy totalmente de acuerdo contigo. Todo esto se implementará. It would be nice if someone could try the interface in high DPI settings.
:bravo:
El compiler no soporta comentarios de este tipo:
No lo sabía. Lo arreglaré para la próxima actualización, gracias.

Por cierto, me parece interesante tu mezcla de español e inglés (spanglish) jaja :lol:, no tengo ningún problema en que tu escribas en inglés, y sinceramente me facilitaría la lectura.
:wave:
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Ahk2Exe AHKv2 - v1.1.0.5 [2018-06-23]

23 Jun 2018, 20:47

Añadido soporte para inclusión automática de bibliotecas (incluir funciones automáticamente sin la declaración explícita de #Include).
Añadido soporte para detectar errores de sintaxis utilizando la versión actual de AutoHotkey instalada.
Añadida función OutputDebug para envíar una cadena al depurador (si existe) para su visualización.
Añadida nueva directiva ;@Ahk2Exe-AddStream.
Añadido asterisco como prefijo opcional en outfile.exe para crear el directorio si no existe.
Añadido parámetro /nocheck en la línea de comandos para desactivar la comprobación de errores de sintaxis.
Añadido intento de compatibilidad con pantallas con DPI mayor a 96 (alfa).
Añadidos códigos de error: ERROR_DEST_DIR_NOT_FOUND, ERROR_CANNOT_CREATE_DEST_DIR y ERROR_INVALID_SYNTAX.
Reescrita función ProcessLine:
  • Cambios en la detección de comentarios.
  • Cambios generales en la optimización del código.
Arregladas directivas @Ahk2Exe-Define, @Ahk2Exe-UnDef y @Ahk2Exe-If/EndIf/IfDef/IfNDef, ahora funcionan correctamente. Ver ejemplo en la documentación.
Correcciones con waterctrl.dll cuando se utilizaba Ahk2Exe.exe en una ubicación diferente.
Corregido error en la detección de comentarios en bloque reportado por coffee aquí.
Mejorada directiva ;@Ahk2Exe-PostExec.
Revisada detección de secciones de continuación.
Otras optimizaciones de código, mantenimiento trivial y correcciones de errores.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-06-23]

09 Jul 2018, 11:27

Hi Flipeador! This looks great!

Would you entertain publishing a version of this in English?
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-06-23]

10 Jul 2018, 09:42

kczx3 wrote:Would you entertain publishing a version of this in English?
Yes, I've thought about that from the beginning, it would be the best, so anyone can understand and use the compiler correctly. At the moment I'm not too interested because version 2 is still in alpha phase (then we could consider that the compiler also). I wanted to keep the Spanish language and add English (we could add more) but I do not know what is the best way to do it, I tried it but the code looked horrible, so I gave it up.
Maybe it's best to put everything in English. Keeping another same project in another language is not a good idea.
kczx3 wrote:Hi Flipeador! This looks great!
Thanks for your comment :) :wave:
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-06-23]

10 Jul 2018, 10:23

Understandable regarding v2 and it being in alpha.

I think the typical way that multiple languages are handled is via i18n. All strings are retrieved from a string table essentially via methods that pass in the select locale or language.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - v1.1.1.6 [2018-07-17]

17 Jul 2018, 13:02

Correcciones en la directiva @Ahk2Exe-PostExec.
Reescrita directiva @Ahk2Exe-AddStream.
Interfaz renovada, se ha incrementado el tamaño de la ventana y se han añadido iconos.
Corrección de posible error en WIN_7-.
Correcciones varias.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - v1.11.2.7 [2018-07-28]

28 Jul 2018, 11:22

Añadida directiva ;@Ahk2Exe-Include.
Añadido parámetro LangID en la directiva ;@Ahk2Exe-VerInfo.
Ahora es posible especificar el idioma de las propiedades en la información de la versión.
Añadidas pestañas Información de la versión y Recursos en la interfaz, junto con mejoras varias.
Corrección de error: no se restablecían los identificadores definidos por ;@Ahk2Exe-Define al comenzar una nueva compilación.
Correcciones y mejoras varias.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-08-12]

28 Mar 2019, 10:37

Any updates on an English translation?
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-08-12]

28 Mar 2019, 11:08

Hello @kczx3, I plan to rewrite part (or even all) of the code, translate everything into English and remove the 64-bit version/compatibility (since it is unnecessary). Unfortunately I've been (and i'm) very busy with other things, I'm also rewriting (as you see I love rewriting my scripts) and updating other scripts.

Some of the scripts that I am rewriting I plan to use it for the compiler.
I have also found certain problems with the current version of the compiler, such as parts of the code that throw errors, or modifications in the final code that can give undesired results, reason why such modifications should be optional.

I will be working on it these months, to fix all the errors, the translation, and to add a new tab with options that allow greater control of the final code.

:wave:
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Ahk2Exe AHKv2 - Compilador en español para AutoHotkey v2 [2018-08-12]

28 Mar 2019, 11:14

Awesome! No worries. Life is certainly busy over here too!

Return to “Otras Utilidades y Recursos”

Who is online

Users browsing this forum: No registered users and 10 guests