HTH: A Transpiler for AutoHotKey v1 Code into JavaScript

Post your working scripts, libraries and tools for AHK v1.1 and older
TheMaster11
Posts: 3
Joined: 22 Sep 2022, 13:39

HTH: A Transpiler for AutoHotKey v1 Code into JavaScript

07 Mar 2024, 12:31

HTH: HeavenToHell
HTH, which stands for HeavenToHell, is a dynamically typed, transpiled high-level programming language designed for simplicity, ease of use, and versatility. Inspired by the syntax of AutoHotkey, HTH offers a user-friendly environment for beginners to learn programming and build web applications quickly and easily.

With HTH, developers can write code in a straightforward and intuitive syntax, making it accessible even to those with little to no programming experience. The language is dynamically typed, allowing for flexibility in variable declarations and reducing the need for explicit type annotations.

One of the key features of HTH is it's transpilation process, which converts HTH code into JavaScript and embeds it into an HTML file. This enables applications built with HTH to be run on any device with a web browser, providing portability and accessibility.

HTH simplifies GUI development by eliminating the need for complex initialization, allowing developers to create user interfaces quickly and easily. Additionally, HTH streamlines backend connectivity with it's built-in function for sending and retrieving data from specified endpoints.

Overall, HTH is a powerful yet approachable programming language that empowers beginners to learn programming and build web applications with ease. it's simplicity, portability, and comprehensive documentation make it a valuable tool for developers of all skill levels.

https://github.com/TheMaster1127/HTH



## Usage

To use HTH HeavenToHell:

1. Ensure you have AutoHotKey V1 installed (Unless you wanna run the HTH.exe file).
2. Add your HTH code in a .hth file.
3. Open the cmd in the directory of the HTH.exe or HTH.ahk Transpiler
4. You can run HTH filename.hth or HTH.ahk filename.hth or HTH.exe filename.hth
5. You'll get index.html as output. Also if you use the function getDataFromEndpoint anywhere in the code HTH will generate a server.py file for better backend connectivity. You will need to install Python and also a Python library called Flask in order to run the generated Python backend.
6. (Optional) Open for edit index.html copy the full file do Ctrl+A then Ctrl+C
7. (Optional) Open PrettierFormatter.html
8. (Optional) Format the code and then put it it back in index.html
9. (Optional) Open the index.html

## Platform Compatibility

- HTH is compatible with Windows and can also run on Linux with the assistance of wine a program that can run most exe files on linux using wine.
- HTH only transpiles using Windows or Linux with wine since the transpiler is written in AutoHotKey and we need to run it as an exe in windows and linux with wine or .ahk in windows. Mac users STAY AWAY from HTH!!!

## Editors


This is the best editor for HTH https://github.com/TheMaster1127/SciTE4HTH

---

A simplified documentation here, but you can check the documentation here: https://github.com/TheMaster1127/HTH/wiki

For coding style, you should use Allman Style since functions won't be recognized here is an example:

Do this:

Code: Select all

nameOfFunc(a, b)
{
return a + b
}
Not this:

Code: Select all

nameOfFunc(a, b) {
return a + b
}
Also, return must be in lowercase.

So far, HTH supports:

- Gui - Buttons, Text, Edit and Picture - which will encode as base64 in the HTML file so you won't need the original picture anymore
- GuiContol
- Hotkeys but simple like you can still do almost all combinations like Ctrl+Alt+Shift+AlmostAnyKey or Shift+Up or just even one key

Code: Select all

!+^g::
Msgbox, You Clicked Ctrl+Alt+Shift+G

; We MUST put a Return with a capital letter R at the beginning of the word 'Return' otherwise it will not work. This is ONLY for the end of any label or hotkey.
Return
- Functions
- If, else, else if
- Random
- Sleep
- Msgbox
- FileRead it will hardcode the text from the path in the HTH script
- FileAppend it will download the file one time next time it will be a new file also you can only do for example: FileAppend, %yourVar%, FileName.txt you cant put vars in the filename argument
- SetTimer Note: if you put a msgbox in the timer it will not stop the execution.
- gosub
- labels here is a label:

Code: Select all

; We will go the label
gosub, Label1

; We put return in lowercase to stop the code executing after otherwise; otherwise, it will go to the label twice.
return
Label1:
MsgBox, we are in Label1

; We MUST put a Return with a capital letter R at the beginning of the word 'Return' otherwise it will not work. This is ONLY for the end of any label or hotkey.
Return

- InputBox can only pass 2 parameters here is an example:

Code: Select all

InputBox, OutputVar, Title

; please don't add more parameters or commas ","
- OnKeyPress: here is an example:

Code: Select all

OnKeyPress:
Msgbox, You Pressed %A_ThisHotkey%

; We MUST put a Return with a capital letter R at the beginning of the word 'Return' otherwise it will not work. This is ONLY for the end of any label or hotkey.
Return

- IfMsgBox after an IfMsgBox at the end, add } ; end of ifmsgbox

Example:

Code: Select all

MsgBox, 36, Title Here, Yes or No
IfMsgBox, Yes
{
	MsgBox, You clicked on Yes
} ; end of ifmsgbox

or

Code: Select all

MsgBox, 36, Title Here, Yes or No
IfMsgBox, Yes
{
	MsgBox, You clicked on Yes
}
else
{
	MsgBox, You clicked on No
} ; end of ifmsgbox
- OutputDebug (equivalent to console.log in JS)
- Loop
- Loop, Parse
- Variables and Arrays
- Simple dynamically function calls. Example: func%num%() cant do %num%func() also not func%num%name() you can only have one %var% at the end.
- Assignment operators (:=, .=, +=, -=, *=)
- Comments dont use comments in the same line as the code (Note: Comments might be translated in some cases)

Some features haven't been fully tested but should work include:

- getDataFromEndpoint(data, endpoint) this function allows you to get and send data to or from an endpoint. It will also return data. ONLY if you are running a backend which will be generated in a python file in the same dir!
- isMobileDevice will check if it's a mobile device no need for parameters
- isConnectedToBackend will checks if the webpage is using a web address starting with 'http://' or 'https://', which usually means it's connected to a server. It returns 'true' if it is connected, and 'false' if it's not.
- Abs
- ACos
- ASin
- ATan
- Ceil
- Cos
- Exp
- Floor
- Ln
- Log
- Round
- Sin
- Sqrt
- Tan
- Chr
- InStr
- RegExMatch
- GetKeyState
- StrLen
- SubStr
- Trim
- ParseInt
- StrReplace
- Mod
- Asc

Built-in Variables

- A_Index
- A_LoopField
- A_LastKey retrieves the last key pressed by the user on the page
- A_ThisHotkey retrieves the key pressed only inside a label called OnKeyPress:
- A_ScreenWidth
- A_ScreenHeight
- A_GuiControl
- A_TimeIdle
- A_TickCount
- A_Now
- A_YYYY
- A_MM
- A_DD
- A_MMMM
- A_MMM
- A_DDDD
- A_DDD
- A_Hour
- A_Min
- A_Sec
- A_Space
- A_Tab

You can check the documentation here: https://github.com/TheMaster1127/HTH/wiki

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 140 guests