-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This section provides an overview of the usage and syntax of the HTH programming language.
In HeavenToHell (HTH) programming, it is crucial to adhere to the Allman coding style to ensure code readability and avoid errors. The Allman style dictates placing curly braces on their own lines, and failure to follow this style may result in errors during execution.
nameOfFunc(a, b)
{
return a + b
}
- MUST: Use the Allman style consistently throughout your HTH code.
- WILL: Failure to use the Allman style may lead to errors during execution.
Adhering to the Allman coding style not only helps maintain clean and organized code but also ensures compatibility and error-free execution in HTH programming.
In HeavenToHell (HTH), the coding style follows the Allman style, where curly braces are placed on their own lines. Additionally, comments are denoted by a semicolon ;
for single-line comments and by using semicolon ;
for each line in multi-line comments. There are no block comments.
In HTH, variables are declared and assigned using the Allman style, and variable names follow the same conventions as in AutoHotkey. Here's how you declare and assign variables:
myNumber := 42
myString := "Hello, World!"
isFlagSet := true
HTH supports various data types, including numeric, string, and boolean types.
Control structures in HTH, including conditional statements and loops, follow the Allman style as well.
if (condition)
{
; Code block executed if condition is true
}
else
{
; Code block executed if condition is false
}
Loop
{
; Code block to be repeated
}
Functions in HTH are declared using the Allman style, and return statements are in lowercase. Here's how you declare and define functions:
nameOfFunc(a, b)
{
return a + b
}
Comments in HTH are denoted by a semicolon ;
for single-line comments and are placed on their own lines for multi-line comments.
; This is a single-line comment
/*
This is
a multi-line comment
*/
HTH is designed for simplicity and ease of use, following the Allman coding style throughout the language. It is suitable for various applications, including web development, scripting, and learning programming concepts.
Here's an example demonstrating the usage of variables, control structures, and functions in HTH:
myNumber := 42
myString := "Hello, World!"
if (myNumber > 0)
{
MsgBox, % "Number is positive: " . myNumber
}
else
{
MsgBox, % "Number is non-positive: " . myNumber
}
nameOfFunc := nameOfFunc(3, 4)
MsgBox, % "Result of nameOfFunc: " . nameOfFunc
WARNING: NEVER NAME A VARIABLE THE SAME NAME AS A FUNCTION NAME
HTH follows the Allman coding style for consistency and readability. Its simplicity and versatility make it suitable for various programming tasks.
Explore the various features offered by the HTH programming language in this section.
- GUI
- GuiControl
- Hotkeys
- Functions
- If, else, else if
- Random
- Sleep
- Msgbox
- FileRead
- FileAppend
- SetTimer
- Labels
- Gosub
- InputBox
- OnKeyPress
- Return/return
- IfMsgBox
- OutputDebug
- Loop
- Loop, Parse
- Variables and Arrays
- Run, Reload and ExitApp
- #Include (ONLY in HTH v1)
- Comments
- runPyCode and runHTML
- PlaySound
- MouseGetPos and OnMouseClick
- Title and Icon
- StoreLocally
- getUrlParams and reloadWithParams
- getDataFromAPI and getDataFromJSON
- getDataFromEndpoint
- isMobileDevice
- isConnectedToBackend
- Math Functions
- Build-in Functions
- Build-in Variables
The GUI feature in HTH allows for the creation of graphical user interfaces with elements such as buttons, text, edit fields, and pictures. Pictures whit a local path will be encoded as base64 in the HTML file (ONLY IN HTH v1), eliminating the need for the original picture file.
The Gui
command creates and manages windows and controls. Such windows can be used as data entry forms or custom user interfaces.
Gui, SubCommand, Value1, Value2, Value3
Aslo you can do
Gui 2: SubCommand, Value1, Value2, Value3
Gui 3: SubCommand, Value1, Value2, Value3
but now you have to use num:
anywhere even the GuiConrol for example
buttonSwitch1 := 0
buttonSwitch2 := 0
Gui 2: Show, x210 w500 h500
Gui 2: Add, Button, x10 y10 w300 h50 vtheButton gButton1, This is some text
Gui 3: Show, x750 w500 h500
Gui 3: Add, Button, x10 y10 w300 h50 vtheButton gButton2, This is some text
return
Button1:
buttonSwitch1++
if (buttonSwitch1 = 1)
{
GuiControl 2: Move, theButton, x10 y300 w150 h40
}
else
{
GuiControl 2: Move, theButton, x10 y10 w300 h50
buttonSwitch1 := 0
}
Return
Button2:
buttonSwitch2++
if (buttonSwitch2 = 1)
{
GuiControl 3: Move, theButton, x10 y300 w150 h40
}
else
{
GuiControl 3: Move, theButton, x10 y10 w300 h50
buttonSwitch2 := 0
}
Return
and so on but dont do 1:
since it's the defalut one.
The SubCommand
, Value1
, Value2
, and Value3
parameters are dependent upon each other, and their usage is described below.
This section provides a detailed explanation of the available SubCommands
for the Gui
command.
Gui, Show, w500 h500
Gui, Add, Text, x20 y20 w100 h20, This is a text control
Sleep, 2000
Gui, Hide
Sleep, 3000
Gui, Show
; or
Gui 2: Show, w500 h500
Gui 2: Add, Text, x20 y20 w100 h20, This is a text control
Sleep, 2000
Gui 2: Hide
Sleep, 3000
Gui 2: Show
Gui, Show, w500 h500
Gui, Add, Text, x20 y20 w100 h20, This is a text control
Sleep, 2000
Gui, Move, x50 y50
Sleep, 3000
Gui, Move, x500 y500
; or
Gui 2: Show, w500 h500
Gui 2: Add, Text, x20 y20 w100 h20, This is a text control
Sleep, 2000
Gui 2: Move, x50 y50
Sleep, 3000
Gui 2: Move, x500 y500
; Add a text control
Gui, Add, Text, x20 y20 w100 h20, This is a text control
; or
; Add a button control
Gui, Add, Button, x20 y50 w100 h30, Click me
; and more
; Set the background color of the GUI window
Gui, Color, cWhite
; Set the background color of the GUI window
Gui, Color, c121212
; or
Color := "ff0000"
Gui, Color, c%Color%
; or
randomColor := ranColor()
Gui, Color, c%randomColor%
; to append a new color you need to do Gui, Show, <and must put something here like w500 h500 or yours otherwize it will not work>
Gui, Show, w500 h500
ranColor()
{
Random, red, 0, 255
Random, green, 0, 255
Random, blue, 0, 255
; Convert each component to hexadecimal and concatenate
hexDigits := "0123456789ABCDEF"
hexRed := SubStr(hexDigits, Floor(red / 16) + 1, 1) . SubStr(hexDigits, Mod(red, 16) + 1, 1)
hexGreen := SubStr(hexDigits, Floor(green / 16) + 1, 1) . SubStr(hexDigits, Mod(green, 16) + 1, 1)
hexBlue := SubStr(hexDigits, Floor(blue / 16) + 1, 1) . SubStr(hexDigits, Mod(blue, 16) + 1, 1)
hexColor := hexRed . hexGreen . hexBlue
;MsgBox, % "Random Color: " . hexColor
return hexColor
}
If you need to use different colors with only one GUI div:
; If we will only use 1 GUI div we can just do this:
Gui, Color, c420606
Gui, Show, x10 y10 w300 h300
Gui, Add, Text, cWhite x10 y10 w100 h30, hi
; We will use Sleep for 2 seconds so we can see the change.
Sleep, 2000
; To change the color just do this:
Gui, Color, c060642
; When you do the Gui Show command, make sure to specify the coordinates; otherwise, the color won't change.
Gui, Show, x10 y10 w300 h300
If you need to use different colors with more than one GUI div:
; We need to put this only once and it's now for all colors of all GUI divs.
Gui, Color, gr-%gr%
defColor("121212")
Gui, Show, x10 y10 w300 h300
Gui, Add, Text, cWhite x10 y10 w100 h30, hi
defColor("420606")
; We don't need to do Gui, Color, gr-%gr% or even Gui 2: Color, gr-%gr%.
Gui 2: Show, x510 y510 w300 h300
Gui 2: Add, Text, cWhite x10 y10 w100 h30, hi
defColor("ff3030")
; We don't need to do Gui, Color, gr-%gr% or even Gui 2: Color, gr-%gr%.
Gui 3: Show, x10 y510 w300 h300
Gui 3: Add, Text, cWhite x10 y10 w100 h30, hi
; If you want to use a gradient as a background color, set the gr variable to the gradient of choice
gr := "linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%)"
; We don't need to do Gui, Color, gr-%gr% or even Gui 2: Color, gr-%gr%.
Gui 4: Show, x510 y10 w300 h300
Gui 4: Add, Text, cWhite x10 y10 w100 h30, hi
; We will use Sleep for 2 seconds so we can see the change.
Sleep, 2000
; If you want to change the color of an already made GUI, just do this:
defColor("30ff30")
; When you do the Gui Show command, make sure to specify the coordinates; otherwise, the color won't change.
Gui 3: Show, x10 y510 w300 h300
; We will use Sleep for 1 second so we can see the change.
Sleep, 1000
; If you want to change the gradient of an already made GUI, just do this:
gr := "linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 35%, rgba(0,212,255,1) 100%)"
; When you do the Gui Show command, make sure to specify the coordinates; otherwise, the color won't change.
Gui 4: Show, x510 y10 w300 h300
return
defColor(color)
{
; You can add "#" or the letter "c" which stands for color when using defColor(), just in case you need or want to or if you are used to it.
if (SubStr(color, 1, 1) = "#") or (SubStr(color, 1, 1) = "c")
{
StringTrimLeft, color, color, 1
}
gr := "linear-gradient(180deg, #" . color . " 0%, #" . color . " 89%)"
}
; Set the font size of the text control
; s = size
Gui, Font, s22
; or
Size := "22"
Gui, Font, s%Size%
; Set the font name of the text control
; f = font
Gui, Font, fCourier
; or
Font := "Courier"
Gui, Font, f%Font%
; Removes the border of a Gui window
Gui, Font, s20
Gui, Show, x10 y10 w500 h500
Gui, Add, Text, x10 y10 w300 h50, Gui 1
Gui 2: Show, -Border x610 y10 w500 h500
Gui 2: Add, Text, x10 y10 w300 h50, Gui 2
Sleep, 1500
; We need to add '-Border' anytime you move or show, even if you show it after a hide; otherwise, the border will be back.
Gui 2: Move, -Border x810 y10 w500 h500
We also have these new parameters for the Button and Edit ONLY:
- c = color
- bg = background color
- f = font name
- r = radius
- -Border = removes the border around the button or the edit
- gr- = gradient
Gradients are smooth color transitions used in design. You can make them easily here. Just pick colors and settings, then copy the CSS code for your website. It's a quick way to add style! Just don't copy the last semicolon
;
. Here's how it might look like:
gr := "linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%)"
; or
Gui, Color, gr-linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%)
; or
Gui, Color, gr-%gr%
;also
Gui, Add, Button, x10 y10 w140 h40 gr-%gr%
; or
Gui, Add, Edit, x10 y10 w140 h40 gr-%gr%
here is an example for all these new parameters for the Button and Edit:
gr := getRanGr()
Gui, Color, gr-%gr%
Gui, Show, +websiteMode w%A_ScreenWidth% h%A_ScreenHeight%
color1 := "121212"
color2 := "ffffff"
bgColor := "303030"
fontName := "Courier"
bgGR := "linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%)"
rad := 20
ff := " type here"
boxW := 200 + 200 + 15
boxH := 30 + 30 + 20
BoxMiddleX := (A_ScreenWidth - boxW) / 2
BoxMiddleY := (A_ScreenHeight - boxH) / 2
editX1 := 0 + BoxMiddleX
editX2 := 210 + BoxMiddleX
editY1 := 0 + BoxMiddleY
editY2 := 0 + BoxMiddleY
buttonX1 := 30 + BoxMiddleX
buttonX2 := 250 + BoxMiddleX
buttonY1 := 42 + BoxMiddleY
buttonY2 := 42 + BoxMiddleY
Gui, Font, s20
Gui, Add, Edit, x%editX1% y%editY1% w200 h30 gr-%bgGR% cffffff fCourier -border bg%bgColor% r%rad% gEdit1, %ff%
Gui, Font, s17
Gui, Add, Button, x%buttonX1% y%buttonY1% w140 h40 -border fCourier c%color2% bg%bgColor% r%rad% gButton1, Button1
Gui, Font, s20
Gui, Add, Edit, x%editX2% y%editY2% w200 h30 cffffff -border bg303030 r20 gEdit2, %ff%
Gui, Font, s17
Gui, Add, Button, x%buttonX2% y%buttonY2% w140 h40 f%fontName% -border gr-%bgGR% c%color1% bg303030 r20 gButton2, Button2
return
Edit1:
text1 := A_GuiControl
Return
Edit2:
text2 := A_GuiControl
Return
Button1:
MsgBox, % text1
Return
Button2:
MsgBox, % text2
Return
getRanGr()
{
Loop, 9
{
Random, ran%A_Index%, 0, 255
}
Random, deg, 1, 360
ranGR := "linear-gradient(" . deg . "deg, "
ranGR .= "rgba(" . ran1 . "," . ran2 . "," . ran3 . "," . 1 . ") 0%, rgba(" . ran4 . "," . ran5 . "," . ran6 . "," . 1 . ") 50%, rgba(" . ran7
ranGR .= "," . ran8 . "," . ran9 . "," . 1 . ") 100%)"
return ranGR
}
This section provides information about the controls that can be used within the Gui
command to create various elements in the graphical user interface.
- Text - Static Text element
- Button - Button you can click
- Edit - Will crete a place to enter text
- Pictire - Will display a Picture. Pictures can be encoded as base64 in the HTML file, eliminating the need for the original picture file.
- Toggle - GUI element, allowing users to toggle settings on and off using a convenient toggle slider.
- Rectangle - Gui element to draw a rectangle
- Circle - Gui element to draw a Circle
- Video - Integrated a flexible video player using Gui, Add, Player, ... capable of displaying:
- DropDownList - Adds a DropDownList control (
Gui, Add, DropDownList
) to a GUI window and make a lable (gMyDropDown
) to capture the selected option from a list of predefined choices (Option1|Option2|Option3
). - Iframe - An Iframe displays another webpage within your GUI. This can include content such as websites, forms, or videos.
- IDE - An IDE displays an Integrated Development Environment (IDE) for writing and editing code. This feature allows you to write and edit code directly within your GUI.
- YouTube videos: Simply provide the YouTube video URL to play directly within the application.
- URL videos: Play videos from any accessible URL, supporting various video formats.
- Local machine videos: Upload videos from your local machine by specifying a path, which will be encoded in a base64 string embedded in the html output.
ranGR := getRanGr()
once := 0
Gui, Font, fCourier
Gui, Color, gr-%ranGR%
Gui, Show, +WebsiteMode w%A_ScreenWidth% h3700
; 1. Text - Text element
Gui, Add, Text, x10 y10 w200 h20, This is a text element
; 2. Edit - Will create a place to enter text
Gui, Add, Edit, x10 y40 w200 h25 r10 bg121212 cffffff gEdit1, Type here...
; 3. Button - Button you can click
; Create a GUI window and add a centered button
Gui, Add, Button, x10 y80 w100 h30 r20 -Border cffffff bg121212 gButton1, Click Me
; 4. Picture - Will display a Picture. You can provide a link or it can be encoded as base64 in the HTML file.
; url
Gui, Add, Picture, x10 y120 w200 h150, https://hd.wallpaperswide.com/thumbs/windows_xp_original-t2.jpg
; a path form your computer
; ONLY WORKS IN HTH v1
Gui, Add, Picture, x10 y120 w200 h150, C:/path/to/your/your.png
; 5. Toggle - GUI element, allowing users to toggle settings on and off using a convenient toggle slider.
; toggle it on upon loading using on
Gui, Add, Toggle, x10 y280 gToggle1 vS1 on
; 6. Rectangle - GUI element to draw a rectangle
Gui, Add, Rectangle, x10 y320 w100 h50 vRect1
; you can change the color here
GuiControl, Font, Rect1, cff0000
; 7. Circle - GUI element to draw a Circle
Gui, Add, Circle, x120 y320 w50 h50 vCircle1
; you can change the color here
GuiControl, Font, Circle1, cff0000
; 8. Video - Integrated a video player using Gui, Add, Player
; from YouTube
Gui, Add, Player, x10 y380 w400 h300, https://www.youtube.com/watch?v=someyturl
; or
; form a url
Gui, Add, Player, x10 y380 w400 h300, https://www.somewebsite.com/somevideo.mp4
; or
; form your computer
; ONLY WORKS IN HTH v1
Gui, Add, Player, x10 y380 w400 h300, C:/path/to/your/your.mp4
; 9. DropDownList - Adds a DropDownList control (`Gui, Add, DropDownList`) to a GUI window and make a lable (`gMyDropDown`) to capture the selected option from a list of predefined choices (`Option1|Option2|Option3`).
Gui, Add, DropDownList, x250 y10 gMyDropDown, Option1|Option2|Option3
; 10. Iframe - An Iframe displays another webpage within your GUI. This can include content such as websites, forms, or videos.
; r = round the corners
Gui, Add, Iframe, x250 y60 w300 h300 r10, https://example.com/
Gui, Color, c121212
Gui 2: Show, -Border w500 h500
; 11. IDE - An IDE displays an Integrated Development Environment (IDE) for writing and editing code. This feature allows you to write and edit code directly within your GUI.
; l = language but by default is autohotkey
code := "msgbox, hello"
outCode := code
Gui 2: Add, IDE, x10 y10 w400 h400 gIDE1 lautohotkey, %code%
Gui 2: Add, Button, x10 y420 w140 h40 gButton2, Button 2
return
IDE1:
outCode := A_GuiControl
Return
Button2:
MsgBox, % outCode
Return
Toggle1:
toggle1value := A_GuiControl
once++
if (once > 1)
{
MsgBox, % toggle1value
}
Return
Edit1:
textFormEditBox := A_GuiControl
Return
Button1:
MsgBox, % textFormEditBox
Return
MyDropDown:
MsgBox, You selected %A_GuiControl%
Return
getRanGr()
{
Loop, 9
{
Random, ran%A_Index%, 0, 255
}
Random, deg, 1, 360
ranGR := "linear-gradient(" . deg . "deg, "
ranGR .= "rgba(" . ran1 . "," . ran2 . "," . ran3 . "," . 1 . ") 0%, rgba(" . ran4 . "," . ran5 . "," . ran6 . "," . 1 . ") 50%, rgba(" . ran7
ranGR .= "," . ran8 . "," . ran9 . "," . 1 . ") 100%)"
return ranGR
}
This section provides examples of using the Gui
command to create graphical user interfaces.
Make sure to put the Gui, Show
command on top of your script.
Example 1
Gui, Font, s20
Gui, Show, w500 h700
Gui, Add, Text, x10 y10 w150 h30, First name:
Gui, Add, Edit, x10 y40 w150 h30 gEdit1 vFirstName, First Name...
Gui, Add, Text, x10 y100 w150 h30 , Last name:
Gui, Add, Edit, x10 y130 w150 h30 gEdit2 vLastName, Last Name...
Gui, Add, Button, x10 y200 w155 h45 gButtonOK, Send
return
; You need to get the text from the edit
Edit1:
FirstName := A_GuiControl
Return
; You need to get the text from the edit
Edit2:
LastName := A_GuiControl
Return
; When you press the button
ButtonOK:
MsgBox, % "You entered " . FirstName . " " . LastName . "."
Return
Example 2
; You can pass vars as w and h
Gui 2: Show, w%A_ScreenWidth% h%A_ScreenHeight%
Gui 2: Add, Text, x10 y10 w150 h30, This is text
; or you can do
w := 500
h := 700
Gui, Show, w%w% h%h%
Gui, Add, Text, x10 y10 w150 h30, This is text
return
Example 3
; Lest use Loops to made a 3x3 button grid
; you can also change those values
rows := 3
columns := 3
; if one button is w140 h40
w := 10 + (150 * rows)
h := 10 + (50 * columns)
Gui 2: Show, w%w% h%h%
x := 10
y := 10
ButtonNum := 0
Loop, %rows%
{
Loop, %columns%
{
ButtonNum++
NameOfButton := "Button" . ButtonNum
Gui 2: Add, Button, x%x% y%y% w140 h40 gButton, %NameOfButton%
y := y + 50
}
x := x + 150
y := 10
}
return
Button:
MsgBox, You clicked on %A_GuiControl%
Return
Example 4
Gui, Show, w500 h700
onceTS1 := 0
errorSelectAobject := 0
DropList1Choise := ""
Gui, Add, Toggle, x10 y10 gTS1 vTS1 on, Wanna turn it on?
Gui, Add, DropDownList, x210 y10 h30 gDropList1 vds1 on, Select a object|sdefgh|aesdrgfh|awesdrfgh|szdf|sd
Gui, Add, Button, x10 y50 w140 h40 gButton1 vButton1, Save changes
Gui, Add, Picture, x10 y150 vImage1, https://i.ibb.co/Jpty1B8/305182938-1a0efe63-726e-49ca-a13c-d0ed627f2ea7.png
Sleep, 1500
GuiControl, Move, Image1, x50 y190
Sleep, 1500
GuiControl, Picture, Image1, https://trackmania.exchange/maps/screenshot/normal/165572
return
Button1:
if (errorSelectAobject = 1) or (DropList1Choise = "")
{
MsgBox, You havent select anything from the drop list
return
}
MsgBox, Oh you whent whit the %DropList1Choise%
Return
DropList1:
if (A_GuiControl = "Select a object")
{
MsgBox, 48, , You cannot select this since this is the name of the list!
errorSelectAobject := 1
return
}
else
{
errorSelectAobject := 0
MsgBox, You clciked %A_GuiControl%
DropList1Choise := A_GuiControl
}
Return
TS1:
onceTS1++
if (onceTS1 > 1)
{
if (A_GuiControl = 1)
{
A_GuiControl1 := "On"
}
else
{
A_GuiControl1 := "Off"
}
MsgBox, its %A_GuiControl1%
}
Return
The GuiControl
function in HeavenToHell (HTH) serves as a versatile tool for manipulating graphical user interface (GUI) elements with ease and precision. This function empowers HTH developers to dynamically adjust the properties and behaviors of GUI elements based on specific actions.
GuiControl, Action, ControlID, Param1, Param2, Param3, Param4
-
Action
: Specifies the action to be performed on the GUI control. Supported actions include:-
Move
: Move and resize the control. -
Focus
: Set focus on the control. -
Text
: Set the text content of the control. -
Picture
: Changes the image of the specified ID to a different image, provided that ONLY a URL is valid. -
Hide
: Hide the control. -
Show
: Show the control. -
Enable
: Enable the control. -
Disable
: Disable the control. -
Font
: Set the font size or color of the control.
-
-
ControlID
: The unique identifier of the GUI control to be manipulated. -
Param1
,Param2
,Param3
,Param4
: Additional parameters required for specific actions, as follows:- For
Move
:Param1
is the new X-coordinate,Param2
is the new Y-coordinate,Param3
is the new width, andParam4
is the new height of the control. - For
Text
:Param1
is the new text content of the control. - For
Font
:Param1
is the new font size in pixels and the new color in hexadecimal format (cRRGGBB).
- For
-
Move
: Moves and resizes the specified control to the provided coordinates and dimensions. -
Focus
: Sets focus on the specified control, if applicable. -
Text
: Sets the text content of the specified control to the provided value. -
Picture
: Changes the image of the specified ID to a different image, provided that ONLY a URL is valid. -
Hide
: Hides the specified control from view. -
Show
: Shows the specified control, making it visible. -
Enable
: Enables the specified control, allowing user interaction. -
Disable
: Disables the specified control, preventing user interaction. -
Font
: Sets the font size or the color of the specified control to the provided value.
; Move and resize a control with ID "myButton"
GuiControl, Move, myButton, 100, 100, 150, 50
; Set focus on an input field with ID "usernameInput"
GuiControl, Focus, usernameInput
; Changes the text content of a control or text with ID "infoLabel"
GuiControl, Text, infoLabel, Hello, World!
; Hide a control or text with ID "Button3"
GuiControl, Hide, Button3
; Show a control or text bar with ID "Button3"
GuiControl, Show, Button3
; Disable a button with ID "Button3"
GuiControl, Disable, Button3
; Enable a button with ID "Button3"
GuiControl, Enable, Button3
; Set the font size of a control or text with ID "Element2"
; s = to size
GuiControl, Font, Element2, s16
; c = to color
; Set the color of a control or text with ID "Text1"
GuiControl, Font, Text1, cFF0000
Gui, Show, w500 h700
Gui, Add, Picture, x10 y150 vImage1, https://i.ibb.co/Jpty1B8/305182938-1a0efe63-726e-49ca-a13c-d0ed627f2ea7.png
Sleep, 1500
GuiControl, Move, Image1, x50 y190
Sleep, 1500
GuiControl, Picture, Image1, https://trackmania.exchange/maps/screenshot/normal/165572
- Ensure that the specified
ControlID
exists within the GUI environment before invokingGuiControl
. - The availability of certain actions may depend on the type of control specified by
ControlID
. Ensure compatibility with the intended control type. - Parameters such as coordinates, dimensions, font size, and color are specified in pixels or hexadecimal format, as appropriate.
- Take advantage of
GuiControl
to dynamically update and manipulate GUI elements based on user interaction or application logic, enhancing the interactivity and usability of your HTH applications.
The Hotkeys
feature in HeavenToHell (HTH) allows users to define custom keyboard shortcuts that trigger specific subroutines within their applications. With Hotkeys
, developers can enhance user experience by providing convenient shortcuts for commonly used functions or commands.
Key::
; Subroutine code
Return
-
Key
: Specifies the key or key combination that triggers the action. It can include modifiers such as!
for Alt,^
for Ctrl, and+
for Shift. Additionally, it can include any combination of arrow keys (Up, Down, Left, Right).
!^+H::
MsgBox, You pressed Alt+Ctrl+Shift+H
Return
Enter::
; If we have a MsgBox inside this subroutine, we need to sleep for 10 ms otherwise the Enter key will close the MsgBox immediately.
Sleep, 10
MsgBox, You pressed Enter
Return
- Users can define multiple hotkeys by repeating the
Key::
syntax with different key combinations and subroutine codes. - Hotkeys can be used to perform various actions, such as executing functions, displaying messages, or triggering specific events within the application.
; Up arrow key
Up::
; Subroutine code
Return
; Down arrow key
Down::
; Subroutine code
Return
; Left arrow key
Left::
; Subroutine code
Return
; Right arrow key
Right::
; Subroutine code
Return
; Space key
Space::
; Subroutine code
Return
; Backspace key
Backspace::
; Subroutine code
Return
The Hotkeys
feature in HTH provides users with a simple and efficient way to define custom keyboard shortcuts that execute specific subroutines, enabling developers to create more interactive and user-friendly applications. By leveraging hotkeys, developers can enhance productivity and streamline user interactions, contributing to an improved overall user experience.
In HeavenToHell (HTH), functions are indispensable for organizing and structuring code efficiently. By encapsulating reusable blocks of code, functions enhance modularity, readability, and maintainability. Adhering to the Allman Style coding convention is crucial for defining functions in HTH, ensuring clarity and consistency in code formatting.
nameOfFunc(param1, param2, ...)
{
; Function body
return result
}
Ensure that the opening curly brace {
is placed on a new line when defining functions in HeavenToHell (HTH). Failure to adhere to this convention will result in errors, and the function will not be recognized.
-
nameOfFunc
: The name of the function, following the Allman Style convention. -
param1
,param2
, ...: Parameters that the function accepts for processing.
sum(a, b)
{
return a + b
}
- Consistent indentation and spacing within the function body enhance code readability.
- All functions in HTH are similar to JavaScript's scope, allowing them to be accessed from anywhere within the script.
- You can't declare function inside a function
In HeavenToHell (HTH), simple dynamically function calls provide a convenient way to execute functions based on dynamically generated names or values. This feature enhances flexibility and reduces redundancy in code, allowing for efficient function invocation.
To perform a simple dynamically function call in HTH, use the following syntax:
func%num%()
Where %num%
represents a dynamically generated value or variable. It's important to note that only one %var%
can be used at the end of the function name, and it must be placed at the end of the function name.
; Define dynamic functions
func1()
{
MsgBox, This is function 1
}
func2()
{
MsgBox, This is function 2
}
; Dynamically call functions based on a variable value
num := 1
; Calls func1()
func%num%()
num := 2
; Calls func2()
func%num%()
In this example, the functions func1
and func2
are defined. By using a variable num
, different functions can be dynamically called based on its value. The %num%
placeholder in the function name is replaced by the value of num
during execution, allowing for dynamic function invocation.
Simple dynamically function calls in HTH enable developers to streamline code execution, especially in scenarios where function names or values are generated dynamically.
Note: YOU CAN'T RETURN TO A VALUE. IT MUST NOT RETURN A VALUE. DON'T DO THIS:
; can't assign to a variable
outVar := func%num%(params)
Functions serve various purposes, such as mathematical calculations, data processing, and executing specific actions based on input parameters. Consider the following example illustrating the usage of a function to calculate the sum of two numbers:
; Define the sum function
sum(a, b)
{
return a + b
}
; Call the sum function with arguments
result := sum(5, 10)
; Display the result
MsgBox, The sum is: %result%
In this example, the sum
function takes two parameters a
and b
, adds them together, and returns the result. The function is called with arguments 5
and 10
, and the returned result is displayed using a message box.
Functions in HTH empower developers to structure code effectively and promote code reuse. By following the Allman Style convention and leveraging global function scope, developers can create well-organized and maintainable scripts in HeavenToHell.
The If
, else
, and else if
statements in HeavenToHell (HTH) are fundamental control structures used for making decisions and executing different blocks of code based on specified conditions. These statements provide the ability to create branching logic within scripts, enabling developers to implement conditional behavior.
if (condition)
{
; Code to execute if the condition is true
}
else if (anotherCondition)
{
; Code to execute if the first condition is false and this condition is true
}
else
{
; Code to execute if all preceding conditions are false
}
-
condition
: A Boolean expression that evaluates to either true or false. -
anotherCondition
: An additional Boolean expression used inelse if
statements.
; Example demonstrating the usage of if, else if, and else statements
x := 10
if (x > 10)
{
MsgBox, x is greater than 10
}
else if (x < 10)
{
MsgBox, x is less than 10
}
else
{
MsgBox, x is equal to 10
}
In addition to simple comparisons, HTH supports various logical operators such as &&
(logical AND), ||
(logical OR), and
, or
, and negation !
(logical NOT). These operators can be combined to form complex conditional expressions.
; Example demonstrating the usage of logical operators in conditional expressions
var1 := 3
var2 := 5
if (var1 = 3) && (var2 = 5) or (var2 != 6)
{
MsgBox, Condition is true
}
else
{
MsgBox, Condition is false
}
Additionally, functions can be used within conditional statements to evaluate conditions dynamically. The !
operator can be used to negate the result of a function call.
; Example demonstrating the usage of function calls and negation in conditional statements
if !(collision())
{
MsgBox, No collision detected
}
else
{
MsgBox, Collision detected
}
In this example, the collision
function is called within the if
statement, and its return value is negated using the !
operator. If the result of the collision
function is false (indicating no collision), the message "No collision detected" is displayed. Otherwise, if a collision is detected, the message "Collision detected" is displayed.
- It's important to properly use parentheses to ensure the desired evaluation order when combining logical operators.
- Functions can be called within conditional statements to evaluate conditions dynamically, providing flexibility in script behavior.
The If
, else if
, and else
statements, along with logical operators, provide powerful tools for implementing conditional logic in HeavenToHell (HTH) scripts. By combining these features, developers can create dynamic and responsive applications capable of handling various scenarios and user inputs effectively.
The Random
feature in HeavenToHell (HTH) enables developers to generate random numbers within specified ranges. This functionality is particularly useful for scenarios where randomness is required, such as in game development, simulations, or randomized algorithms.
Random, OutputVar, Min, Max
-
OutputVar
: The variable to store the generated random number. -
Min
: The minimum value of the range (inclusive). -
Max
: The maximum value of the range (inclusive).
; Generate a random number between 1 and 100
Random, randomNumber, 1, 100
; Display the generated random number
MsgBox, Random number: %randomNumber%
or
var1 := 1
var2 := 100
Random, OutputVar, %var1%, %var2%
; Display the generated random number
MsgBox, Random number: %OutputVar%
The Random
feature provides a simple yet effective way to introduce randomness into HTH scripts. Whether it's for generating random numbers for game mechanics, simulating probabilistic events, or implementing randomized algorithms, the Random
function offers flexibility and versatility in handling randomization requirements.
With the Random
feature in HeavenToHell (HTH), developers can easily incorporate randomness into their scripts, adding an element of unpredictability and dynamism to their applications. Whether it's for game development, simulations, or other scenarios requiring randomness, the Random
function offers a straightforward solution for generating random numbers within specified ranges.
The Sleep
feature in HeavenToHell (HTH) allows developers to introduce delays or pauses in their scripts, which can be useful for various purposes such as controlling the timing of actions, implementing animations, or simulating real-time behavior.
Sleep, Delay
-
Delay
: The duration of the pause in milliseconds. This can be an integer or a variable containing the desired delay duration.
; Pause script execution for 2 seconds (2000 milliseconds)
Sleep, 2000
The Sleep
function is commonly used when precise timing is required between consecutive actions in a script. By specifying the desired delay duration, developers can control the pace of script execution, ensuring that actions occur at the intended times.
; Example of using Sleep in a script
; This script waits for 3 seconds, then displays a message box
Sleep, 3000
MsgBox, Three seconds have passed!
In this example, the Sleep
function is used to pause the script execution for 3000 milliseconds (3 seconds) before displaying a message box.
- Be mindful of using excessive
Sleep
statements, as they can introduce unnecessary delays and impact script performance.
The Sleep
function in HeavenToHell (HTH) provides a simple yet effective way to introduce pauses or delays in scripts, allowing developers to control the timing of actions and create more dynamic and interactive applications. Whether it's for controlling animations, simulating real-time behavior, or implementing precise timing in script execution, the Sleep
function offers versatility and flexibility in managing script flow and timing.
The MsgBox
function in HeavenToHell (HTH) displays a small window containing text and one or more buttons, allowing developers to interact with users and present information effectively.
MsgBox, Text
MsgBox, Options, Title, Text, Timeout
-
Text
: The text displayed inside the message box to instruct the user or present information. -
Options
: Indicates the type of message box and the possible button combinations. If blank or omitted, it defaults to 0. See the tables below for allowed values. -
Title
: The title of the message box window. -
Timeout
(optional): Timeout in seconds. If specified, the message box will be automatically closed after the specified duration.
The Options
parameter can be a combination (sum) of values from the following groups:
-
Button Types:
- 0: OK (default)
- 1: OK/Cancel
- 2: (removed)
- 3: OK/No/Cancel
- 4: OK/No
- 5: OK/Cancel
-
Icon Types:
- 16: Stop (Error icon)
- 32: Question (Question mark icon)
- 48: Warning (Warning point icon)
- 64: Information (Information icon)
-
Default Button:
- 0: First button is default (default)
- 256: Second button is default
- 512: Third button is default
- The
MsgBox
function allows developers to create informative and interactive message boxes, providing users with necessary instructions or information. - The timeout parameter, if specified, automatically closes the message box after the specified duration, improving user experience and script flow.
; Display a simple message box with text "Hello, World!"
MsgBox, Hello, World!
; Display a message box with custom options, title, and text
MsgBox, 4, Important Message, This is an important message!
; Display a message box with timeout (5 seconds) and custom text
MsgBox, , Warning, This message will self-destruct in 5 seconds., 5
; display varables
var1 := "hello man"
MsgBox, % var1
; display varables + text
var1 := "hello man"
MsgBox, % var1 . " how are you"
;another example
; Title: Question Text: Do you wnat to leave? Buttons: OK/No Icon: Question Default Button: 2nd Timeout: 5 sec
; to get 292 we have OK/No = 4 + Icon Question = 32 + Default Button: 2nd = 256 so 4+32+256 = 292
MsgBox, 292, Question, Do you wnat to leave?, 5
IfMsgBox, OK
{
MsgBox, You clicked OK
}
else
{
MsgBox, You clicked No
} ; end of ifmsgbox
;another example
var4 := 7
var5 := 10
if (var5 > var4)
{
; Title: Error Text: % "var5 is " . var5 . " which is more than var4. var4 is " . var4 Buttons: OK Icon: Error Default Button: 1st Timeout: 10 sec
; to get 16 we have OK = 0 + Icon Error = 16 + Default Button: 1st = 0 so 0+16+0 = 16
MsgBox, 16, Error, % "var5 is " . var5 . " which is more than var4. var4 is " . var4, 10
}
By combining values from these groups, developers can customize the appearance and behavior of message boxes to suit their specific requirements.
The MsgBox
function in HeavenToHell (HTH) provides developers with a versatile tool for creating informative and interactive message boxes, enhancing user experience and facilitating communication between the script and the user. Whether it's for displaying important messages, requesting user input, or providing notifications, the MsgBox
function offers flexibility and convenience in implementing various messaging scenarios within HTH scripts.
The FileRead
feature in HeavenToHell (HTH) allows you to read the contents of a file into a variable within your script ONLY UPON TRANSPILATION. It's important to note that when using FileRead
, you must provide the filename as a literal string without using variables directly in the filename argument.
FileRead, OutputVar, FileName
-
OutputVar
: The variable to store the contents of the file. -
FileName
: The name of the file to read. This must be specified as a literal string without using variables directly in the filename argument.
; Read text content from the specified file
FileRead, FileContent, FileName.txt
; Display the content of the file
MsgBox, %FileContent%
- Ensure that the filename is provided as a literal string without using variables directly in the filename argument.
- The contents of the file are read into the specified variable (
OutputVar
), allowing you to manipulate or display the file contents as needed within your script.
By following these guidelines, you can effectively use the FileRead
feature in HeavenToHell (HTH) to read text content from external files and incorporate it into your script.
The FileAppend
feature in HeavenToHell (HTH) enables you to append text content to a file. Since HTH runs within a browser environment and cannot directly save files to the device, using FileAppend
will trigger a file download in the browser instead of directly modifying files on the device.
FileAppend, %TextToAppend%, FileName
-
TextToAppend
: The text content to append to the file. -
FileName
: The name of the file to which the text will be appended. This must be specified as a literal string without using variables directly in the filename argument.
; Append text content to the specified file
text := "hello man"
FileAppend, %text%, FileName.txt
- Since HTH runs within a browser environment and cannot directly save files to the device, using
FileAppend
will trigger a file download in the browser instead of directly modifying files on the device. - Ensure that the filename is provided as a literal string without using variables directly in the filename argument.
- The specified
TextToAppend
will be appended to the end of the file specified byFileName
.
With the FileAppend
feature in HeavenToHell (HTH), you can easily trigger file downloads in the browser by appending text content to files, facilitating tasks such as logging, data collection, and file management within your scripts.
In HeavenToHell (HTH), the SetTimer
command is used to create and control timers within the script. Timers allow developers to execute specific actions or functions at regular intervals, providing a mechanism for scheduling tasks and automating processes.
SetTimer, LabelName, Option
-
LabelName
: The name of the label or subroutine to be executed when the timer elapses. -
Option
: Specifies the interval and state of the timer. It can take one of the following values:-
Interval
: Specifies the interval in milliseconds at which the timer should elapse and trigger the execution of the specified label or subroutine. -
On
: Starts or enables the timer. -
Off
: Stops or disables the timer.
-
; Start the timer with an interval of 2000 milliseconds (2 seconds)
SetTimer, TimerLabel, 2000
; After some time or based on certain conditions, turn off the timer
; Wait for 10 seconds
Sleep, 10000
; Stop the timer
SetTimer, TimerLabel, Off
return
; Define a label to be executed by the timer
TimerLabel:
; Perform actions or execute code here
MsgBox, Timer elapsed! This is a recurring message.
Return
; Start the timer with an interval of 2000 milliseconds (2 seconds)
SetTimer, TimerLabel, 2000
; After some time or based on certain conditions, turn off the timer
; Wait for 5 seconds
Sleep, 5000
; Stop the timer
SetTimer, TimerLabel, Off
; Later, based on other conditions or user interaction, turn the timer back on
; Wait for 5 seconds
Sleep, 5000
; Restart the timer
SetTimer, TimerLabel, On
return
; Define a label to be executed by the timer
TimerLabel:
; Perform actions or execute code here
MsgBox, Timer elapsed! This is a recurring message.
Return
- Timers in HTH typically involve setting up a label or subroutine to be executed at specified intervals using the
SetTimer
command. - The
Option
parameter determines the behavior of the timer:- When
Interval
is specified, the timer will elapse at the specified interval and trigger the execution of the specified label or subroutine. - When
On
is specified, the timer is started or enabled, allowing it to trigger at the specified interval. - When
Off
is specified, the timer is stopped or disabled, preventing it from triggering until it is re-enabled using theOn
option.
- When
Timers are commonly used in scripts to perform periodic tasks, such as checking for updates, refreshing data, or triggering specific actions at regular intervals. By utilizing timers, developers can automate repetitive tasks and improve the efficiency and responsiveness of their scripts and applications.
- When using timers, ensure that the specified label or subroutine is defined and contains the necessary code to be executed when the timer elapses.
- Use caution when enabling or disabling timers dynamically during script execution to avoid unintended behavior or conflicts with other script logic.
The SetTimer
command in HTH provides a flexible and powerful way to incorporate timed events and automation into scripts, enabling developers to create more dynamic and responsive applications. By leveraging timers, developers can enhance the functionality and usability of their scripts by scheduling tasks and executing actions at specified intervals.
Labels in HeavenToHell (HTH) serve as markers within the script to designate specific sections of code for execution. They are commonly used in conjunction with Gosub
commands to redirect the script flow to the labeled sections.
Labels are defined using a colon :
followed by the label name.
Example:
LabelName:
; Code to be executed within the label
Labels are typically used in conjunction with Gosub
commands to direct the script flow to the labeled section. The Gosub
command is used to call a subroutine defined by a label.
; We will go to the label
gosub, Label1
; Use lowercase return to stop code execution after the label
return
Label1:
MsgBox, We are in Label1
; Use uppercase Return to end the label
Return
In this example, the script invokes the Gosub
command to execute the code within the Label1
section. Once the execution of the labeled code is complete, the script continues execution after the Gosub
command.
- Labels provide a means to organize and structure the script flow, making it easier to manage and maintain complex scripts.
- Always use an uppercase
Return
at the end of a label to signify its termination, ensuring proper script execution. - Labels are often utilized in combination with conditional statements and loops to control the flow of the script based on certain conditions or criteria.
For more information on Return
, refer to Return/return.
In HeavenToHell (HTH), the Gosub
command is used to call a subroutine defined by a label within the script. Subroutines are sections of code marked by labels, and the Gosub
command redirects the script flow to execute the code within the specified subroutine.
Gosub, Target
-
Target
: The name of the label marking the subroutine to be executed.
The Gosub
command is commonly used to organize code into manageable sections and facilitate code reuse by invoking specific subroutines as needed.
Consider the following example demonstrating the usage of the Gosub
command:
; Define a label marking the start of the subroutine
Subroutine1:
MsgBox, This is Subroutine 1
Return
; Define another label marking the start of another subroutine
Subroutine2:
MsgBox, This is Subroutine 2
Return
; Main script execution begins here
MsgBox, Main script execution started
; Call Subroutine1 using Gosub
Gosub, Subroutine1
; Continue main script execution after Subroutine1
MsgBox, Back to main script execution
; Call Subroutine2 using Gosub
Gosub, Subroutine2
; Continue main script execution after Subroutine2
MsgBox, Script execution completed
Main script execution started
This is Subroutine 1
Back to main script execution
This is Subroutine 2
Script execution completed
In this example, the Gosub
command is used to call two different subroutines (Subroutine1
and Subroutine2
) defined by labels within the script. The script flow is redirected to execute the code within each subroutine, and after the execution of each subroutine, the script continues execution from where the Gosub
command was called.
- Subroutines defined by labels provide a way to organize code into logical sections and improve code readability and maintainability.
- Always use an uppercase
Return
at the end of a subroutine to signify its termination, ensuring proper script execution. - The
Gosub
command is typically used within conditional statements, loops, or other control structures to direct the script flow based on certain conditions or criteria.
The InputBox
feature in HeavenToHell (HTH) allows developers to prompt users for input through a dialog box. This functionality is particularly useful for gathering user information or accepting user-defined values during script execution.
InputBox, OutputVar, Title
-
OutputVar
: The variable where the input provided by the user will be stored. -
Title
: The title or caption of the input dialog box displayed to the user.
; Prompt the user to enter their name
InputBox, UserName, Please enter your name
; Display a message box with the entered name
MsgBox, Hello, %UserName%! Welcome to HeavenToHell.
- The
InputBox
command accepts only two parameters:OutputVar
andTitle
. - Avoid using additional parameters or commas in the command.
- Variables cannot be used as titles for the input dialog box.
The InputBox
feature in HeavenToHell (HTH) provides a simple yet effective way to gather user input during script execution, enabling developers to create interactive applications and scripts with ease.
In HeavenToHell (HTH), the OnKeyPress
event is triggered when the user presses a normal key on the keyboard. This event provides a way to capture and respond to keypress events within the script.
OnKeyPress:
; Code to be executed when a key is pressed
MsgBox, You Pressed %A_ThisHotkey%
Return
The OnKeyPress
event allows developers to define specific actions or behaviors to be performed in response to user keystrokes. This can include displaying messages, performing calculations, updating variables, or triggering other events within the script.
OnKeyPress:
; Display a message indicating the key pressed by the user
MsgBox, You Pressed %A_ThisHotkey%
Return
In this example, the OnKeyPress
event is used to capture keypress events. When a key is pressed, a message box is displayed indicating the key that was pressed using the %A_ThisHotkey%
variable, which contains the name of the hotkey or key combination pressed by the user.
- Ensure to include a
Return
statement with a capital letter "R" at the end of theOnKeyPress
event block to signify its completion and prevent further execution of the script. - The
OnKeyPress
event can be used to create custom keyboard shortcuts, implement keyboard-based navigation, or handle user input in various interactive applications developed using HeavenToHell.
The OnKeyPress
event in HTH provides a versatile mechanism for responding to user keystrokes and enhancing the interactivity of scripts and applications. By capturing and processing keypress events, developers can create dynamic and responsive user experiences within their scripts.
The Return
command in HeavenToHell (HTH) serves distinct purposes based on its context within the script. It's crucial to differentiate between the uppercase Return
and lowercase return
to ensure proper script functionality and execution control.
When concluding a label, subroutine, or hotkey block, use the uppercase Return
at the end to signify its termination. This ensures clarity in script structure and prevents unexpected behavior.
Example:
Label1:
; Code for Label1
if (var1 = 5)
{
; Use lowercase return to stop label execution any further
return
}
; Use uppercase Return to end the label
Return
Place lowercase return
anywhere in the script to halt code execution after its occurrence. This is particularly useful when you want to prevent the script from proceeding further under certain conditions.
Example:
If (condition)
{
; Code to be executed if the condition is met
; Use lowercase return to stop code execution
return
}
; Code that should only run if the condition is not met
Inside functions, utilize lowercase return
to exit the function and return a value if necessary. This maintains consistency in coding style within the context of functions.
Example:
sum(a, b)
{
; Function body
return a + b
}
By understanding and applying these conventions, developers can manage script flow effectively, ensure proper termination of blocks, and enhance code readability in HeavenToHell scripts.
The IfMsgBox
command in HeavenToHell (HTH) enables conditional execution of code based on the user's response to a previous MsgBox
command. This feature is particularly useful for implementing interactive dialogs and handling user input within scripts.
IfMsgBox, ButtonName
{
; Code to be executed if the specified button was pressed
} ; end of ifmsgbox
-
ButtonName
: One of the following strings representing which button the user pressed in the most recentMsgBox
command:No
OK
Cancel
IMPORTANT: Ensure to include } ; end of ifmsgbox
at the end of each IfMsgBox
block to properly terminate the conditional statement. Failure to do so will lead to an error in the script execution.
; Prompt the user with a message box
MsgBox, 36, Title Here, OK or No
; Check the user's response
IfMsgBox, OK
{
MsgBox, You clicked on OK
} ; end of ifmsgbox
; Prompt the user with a message box
MsgBox, 36, Title Here, OK or No
; Check the user's response
IfMsgBox, OK
{
MsgBox, You clicked on OK
}
else
{
MsgBox, You clicked on No
} ; end of ifmsgbox
The IfMsgBox
command is used to determine which button the user pressed in response to a previous MsgBox
command. Based on the user's selection, the script can execute different actions or perform specific tasks.
By incorporating IfMsgBox
into scripts, developers can create interactive dialogues, prompt users for input, and respond dynamically based on user choices, enhancing the interactivity and usability of their applications in HeavenToHell (HTH) environments.
The OutputDebug
feature in HeavenToHell (HTH) provides a method for sending debug messages to the console output during script execution. This functionality is invaluable for debugging and troubleshooting scripts, allowing developers to inspect variable values, track program flow, and identify potential issues.
OutputDebug, Message
-
Message
: The message to be output to the console for debugging purposes.
; Output a debug message to the console
OutputDebug, Debugging information: Variable1=%Variable1%, Variable2=%Variable2%
The OutputDebug
command is typically used for displaying informative messages, variable values, or status updates during script execution. These messages are compiled to console.log
statements when the script is compiled to JavaScript, making it easier to debug and diagnose issues in scripts running in various environments.
The output generated by OutputDebug
can be viewed in the browser console. To access the browser console, typically press F12 in any browser and navigate to the console tab. This allows developers to monitor the debug messages and analyze script behavior during execution.
By leveraging the OutputDebug
feature, developers can streamline the debugging process, identify and resolve errors more efficiently, and ensure the smooth operation of their scripts in HeavenToHell (HTH) environments.
The Loop
feature in HeavenToHell (HTH) provides a mechanism for repeating a block of code a specified number of times or until a certain condition is met. This functionality is essential for automating repetitive tasks, iterating over data structures, and implementing various control flow structures within scripts.
Loop, Count
{
; Code block to be repeated
}
or
Loop
{
; Code block to be repeated until a condition is met
if (condition)
{
; Code to execute if the condition is true
break
}
}
-
Count
: Optional. Specifies the number of iterations to execute the loop. If omitted, the loop will continue indefinitely until abreak
statement or other termination condition is encountered.
; Loop 5 times and display a message
Loop, 5
{
MsgBox, Iteration %A_Index%
}
Iteration 1
Iteration 2
Iteration 3
Iteration 4
Iteration 5
; Loop until a condition is met
Loop
{
; Code block to be repeated
if (A_Index >= 5)
{
; Exit the loop if the condition is true
break
}
}
In this example, the loop continues indefinitely until the condition A_Index >= 5
is met. Once the condition is true, the loop terminates using the break
statement.
- The loop variable
A_Index
contains the current iteration index within the loop. - The
break
statement can be used to exit the loop prematurely based on a specific condition. - The
Loop
feature provides flexibility in controlling the flow of execution within scripts, allowing for both fixed iteration counts and dynamic termination conditions.
The Loop
feature in HeavenToHell (HTH) offers a versatile mechanism for iterating over code blocks, enabling developers to automate repetitive tasks and implement various control flow structures within their scripts.
The Loop, Parse
feature in HeavenToHell (HTH) facilitates the parsing of strings into separate elements based on a specified delimiter. This functionality is particularly useful for breaking down and processing data stored in delimited formats.
Loop, Parse, InputString, Delimiters, OmitChars
{
; Action to be performed for each parsed element
; A_Index contains the current loop iteration index
; A_LoopField contains the current parsed element
}
-
InputString
: The string to be parsed. -
Delimiters
: A string containing one or more characters used as delimiters for parsing. By default, if no delimiters are specified, each character in the input string will be treated as a separate element. -
OmitChars
: Optional. A string containing one or more characters to be omitted during parsing.
; Example input string
inputString := "Hello World"
; Parse the input string character by character
Loop, Parse, inputString
{
; A_LoopField contains the current parsed character
MsgBox, Character %A_Index%: %A_LoopField%
}
Character 1: H
Character 2: e
Character 3: l
Character 4: l
Character 5: o
Character 6:
Character 7: W
Character 8: o
Character 9: r
Character 10: l
Character 11: d
; Example input string with newline and carriage return
inputString := "Line 1`nLine 2`rLine 3"
; Parse the input string using `n` and `r` as delimiters
Loop, Parse, inputString, `n, `r
{
; A_LoopField contains the current parsed line
MsgBox, Line %A_Index%: %A_LoopField%
}
Line 1: Line 1
Line 2: Line 2
Line 3: Line 3
; Example input string with commas
var1 := "Apple,Orange,Banana"
; Parse the input string using commas as delimiters
Loop, Parse, var1, `,
{
; A_LoopField contains the current parsed element
MsgBox, Fruit %A_Index%: %A_LoopField%
}
Fruit 1: Apple
Fruit 2: Orange
Fruit 3: Banana
; Example input string with pipes
var2 := "Alpha|Beta|Gamma"
; Parse the input string using pipes as delimiters
Loop, Parse, var2, "|"
{
; A_LoopField contains the current parsed element
MsgBox, Value %A_Index%: %A_LoopField%
}
Value 1: Alpha
Value 2: Beta
Value 3: Gamma
In these examples, the Loop, Parse
feature is utilized to parse the input strings into separate elements based on the specified delimiters. Each example demonstrates parsing the input string using different delimiters (n
, r
, ,
, |
) to extract individual elements. The loop variable A_LoopField
contains the current parsed element during each iteration, andA_Index
contains the current loop iteration index.
The Loop, Parse
feature in HTH provides a convenient and efficient way to process delimited strings, making it easier to work with structured data in various applications. Whether dealing with configuration settings, text processing, or other delimited data formats, the Loop, Parse
functionality offers a powerful tool for data manipulation and extraction within HeavenToHell scripts.
Variables in HeavenToHell (HTH) are used to store and manipulate data values within scripts. They provide a means of storing information that can be referenced and modified throughout the script.
Variables in HTH are dynamically typed, meaning they can hold values of any data type without requiring explicit declaration. To assign a value to a variable, use the variable name followed by the assignment operator :=
. For example:
myNumber := 42
myString := "Hello, World!"
isFlagSet := true
HTH supports various data types for variables, including:
- Numeric: Integers, decimals, and floating-point numbers.
- String: Textual data enclosed in double quotes.
- Boolean: True or false values.
Variable names in HTH are case-insensitive and can consist of letters, digits, and underscores. However, they must begin with a letter. Descriptive names are recommended to reflect the purpose or content of the variable for better code readability. Don't declare variables with names like let, var, or const since this will result in an error upon execution.
WARNING: NEVER NAME A VARIABLE THE SAME NAME AS A FUNCTION NAME
Variables in HTH have the same scope rules as JavaScript, as HTH transpiles to JavaScript. This means:
- Global Scope: Variables declared outside of any function or block have global scope and can be accessed from anywhere within the script.
- Local Scope: Variables declared inside a function or block have local scope and are accessible only within that function or block.
; Declare and assign variables
myNumber := 42
myString := "Hello, World!"
isFlagSet := true
; Display variable values
MsgBox, % "Number: " . myNumber . "`nString: " . myString . "`nFlag: " . isFlagSet
Variables in HeavenToHell (HTH) can be utilized in various features to enhance flexibility and customization. Here's how to use variables in different contexts, ensuring to follow the specified methods:
In normal usage, variables are concatenated with other strings or values using the .
operator. Here is all the places you MUST use it.
- In MsgBox:
Specifically, in a MsgBox, we need to start with
%
just like down below. Make sure there is a space both before and after%
:
MsgBox, % "var1 is " . var1
- In declaring varibales ALL varibales are declares in this way but no need like in Msgbox to have
%
before it here is an exmpale:
; numbers
var1 := 56
; string
var2 := "this is a string"
; pass varibales
var2 := var4
; concatenated
var3 := var%numOfVar%
; concatenated this way
var%numOfVar% := 6
; more
var4 := "the var1 is = to " . var1
; or
var4 := "the var1 is = to " . var%numOfVar%
; you can also do more
var8 := var7 . " was the number of tries and we have " . %var1% . "made it and so far we have " . var%numOfVar%
In single usage, variables are enclosed within %
symbols and directly inserted into the script. For example:
Gui, Add, Text, x%x% y%y% w150 h%h%, %Text%
In this usage, variables are concatenated with other strings or values using the .
operator, but the variable value is used only once. For example:
Random, ran, hello%var1%, hello%var3%
In this usage, variables are embedded within %
symbols directly within a string to include their values. For example:
MsgBox, text and var1 is %var1%
Please note: In these examples, ensure to follow the specified methods and refrain from using other types of variable usage for consistency and compatibility within HeavenToHell (HTH).
- Variable names are case-insensitive.
- Avoid using reserved keywords as variable names to prevent conflicts.
- Ensure descriptive variable names for clarity and maintainability.
- Initialize variables before using them to avoid unexpected behavior.
Variables play a crucial role in storing and manipulating data within HeavenToHell (HTH) scripts, providing developers with the flexibility to create dynamic and interactive applications.
Arrays in HTH allow for the storage of multiple values in a single variable. Arrays can contain a mixture of integers, strings, and variable references.
; Define a variable 'ji' containing the string "mello"
ji := "mello"
; Define an array 'array' containing integers, a string, and a variable reference
array := [1, 3, 4, 5, 7, "jello", ji]
; To use the array with Loop, Parse, we need to convert it to a string, as HTH doesn't support direct array iteration
; Concatenate 'array' with a string on both sides to convert it to a string
array := "a" . array . "a"
; Trim the left and right characters from the string to remove the added characters
StringTrimRight, array, array, 1
StringTrimLeft, array, array, 1
; Now 'array' contains the string representation of the original array
all := ""
; Iterate over the elements of 'array' using commas as delimiters
Loop, Parse, array, `,
{
; Trim whitespace from the current element
element := Trim(A_LoopField)
if (RegExMatch(element, "^\\d+$"))
{
MsgBox, The element: %element% contains an integer.
; Convert the string element to an integer using ParseInt
element := ParseInt(A_LoopField)
}
else
{
MsgBox, The element: %element% contains a string.
}
all .= element . "`n"
}
StringTrimRight, all, all, 1
; Display the value of all elements
OutputDebug, %all%
; We should see:
/*
1
3
4
5
7
jello
mello
*/
This example demonstrates how to define and iterate over an array in HTH, handling both integer and string elements appropriately.
The Run
feature in HeavenToHell (HTH) enables developers to open specific websites directly from their scripts. This functionality is particularly useful for automating tasks that involve interacting with web pages.
Run, Target
-
Target
: Specifies the target URL or path of the website or application to be launched. This can be a direct URL, a variable containing the URL, or a concatenation of strings to form the URL.
; Launch the example.com website directly
Run, https://www.example.com
; Define the URL as a variable and launch it
var1 := "https://www.example.com"
Run, %var1%
; Concatenate strings to form the URL and launch it
var2 := "https://www."
var3 := "example.com"
Run, % var2 . var3
; Concatenate strings directly within the Run command
Run, % var2 . "example.com"
The Run
function provides a convenient way to open websites or launch external applications directly from HTH scripts. Developers can specify the target URL or path as a direct string, a variable containing the URL, or concatenate strings to form the URL dynamically.
; Example of launching a website using the Run function
varWebsite := "https://www.example.com"
Run, % varWebsite
In this example, the Run
function is used to launch the example.com website by passing the URL stored in the varWebsite
variable.
- Ensure that the target URL or path provided to the
Run
function is valid and accessible.
The Run
feature in HeavenToHell (HTH) offers a straightforward way to launch websites directly from scripts, providing developers with greater flexibility and automation capabilities. The Run
function simplifies the process of launching websites from within HTH scripts.
The Reload
feature in HeavenToHell (HTH) allows developers to reload the currently active webpage directly from their scripts. This functionality is particularly useful for refreshing content dynamically without manually refreshing the page.
Reload
; Reload the currently active webpage
Reload
To reload a currently active webpage, simply use the Reload
command without specifying a target.
; Reload the currently active webpage
Reload
This command will refresh the content of the webpage, allowing developers to update information dynamically.
- The
Reload
command is used to refresh the content of the currently active webpage, providing developers with the capability to update information dynamically without manual intervention.
The ExitApp
feature in HeavenToHell (HTH) allows developers to close the currently active tab or browser window directly from their scripts. This functionality is particularly useful for terminating script execution or closing browser tabs programmatically.
ExitApp
; Close the currently active tab or browser window
ExitApp
To close the currently active tab or browser window, use the ExitApp
command without specifying a target.
; Close the currently active tab or browser window
ExitApp
This command will terminate the script execution and close the tab or browser window where the script is running.
- The
ExitApp
command is used to terminate script execution and close the currently active tab or browser window, providing developers with the capability to end script operation and close the associated browsing context.
The #Include
directive in HeavenToHell (HTH) allows developers to include external scripts into their main script, enabling modularization and code reuse. This feature is particularly useful for organizing large scripts into smaller, more manageable components, as well as for incorporating libraries or utility functions.
#Include FileName
-
FileName
: The name of the.hth
script to be included. This can be a relative or absolute path to the file.
#Include myLibrary.hth
The #Include
directive is commonly used to include external script files containing functions, libraries, or utility code that can be reused across multiple scripts. By separating reusable code into separate files and including them using #Include
, developers can improve code organization, readability, and maintainability.
; Example of using #Include directive to include a library file
#Include MathLibrary.hth
; Call a function from the included library
result := Add(5, 10)
; Display the result
MsgBox, The sum is: %result%
In this example, the #Include
directive is used to include a script file named MathLibrary.hth
, which contains a function named Add
for adding two numbers. The Add
function is then called from the included library file, and the result is displayed using a message box.
- When using the
#Include
directive, ensure that the specified file path is correct and that the included file is accessible from the main script. - It's recommended to include only necessary files and avoid excessive inclusion of unnecessary scripts to maintain script performance and readability.
The #Include
directive in HeavenToHell (HTH) provides a convenient and efficient way to modularize scripts and incorporate reusable code from external libraries. By leveraging the #Include
directive, developers can enhance code organization, promote code reuse, and streamline the development process, ultimately leading to more maintainable and scalable scripts.
In HeavenToHell (HTH), comments play a vital role in enhancing code readability and providing additional context for developers.
; This is a single-line comment in HeavenToHell (HTH)
/*
this is a block comment
this is a block comment
this is a block comment
*/
Single-line comments are prefixed with a semicolon ;
and are typically placed on separate lines to ensure clarity and readability. They are used to add explanatory notes, document code behavior, or temporarily disable code segments without removing them entirely.
; Define variables
var1 := 5
; Initialize var1 with value 5
var2 := 10
; Initialize var2 with value 10
; Calculate the sum of var1 and var2
result := var1 + var2
; Store the result in the result variable
; Display the result
MsgBox, The sum is: %result%
; Show the sum in a message box
In this example, single-line comments are placed on separate lines to document variable initialization, calculation, and message display steps, providing clarity and context to the code.
Do not add comments on the same line as code statements in HeavenToHell (HTH). Placing comments inline with code is not supported.
DO NOT place comments on the same line as code statements in HeavenToHell (HTH).
- Single-line comments should be concise and focused, providing relevant information to aid in code understanding.
Comments in HeavenToHell (HTH) are invaluable tools for improving code comprehension and facilitating collaboration among developers. By leveraging single-line comments effectively, developers can create well-documented and maintainable scripts in HeavenToHell.
The runPyCode
function in HeavenToHell (HTH) executes Python code dynamically and returns computed values back to the application. Each print
statement within the Python code executed by runPyCode
will produce output displayed on a new line within the HTH environment, enhancing clarity and readability of script outputs.
result := runPyCode(PythonCode)
-
PythonCode
: A string parameter containing valid Python code to be executed.
; Example of running Python code using runPyCode and capturing return values
result1 := runPyCode("output = 'Hello, HeavenToHell!'; print(output)")
result2 := runPyCode("result = 2 + 3; print(result)")
-
result1
value:Hello, HeavenToHell!
-
result2
value:5
- Capture and utilize Python script outputs directly within HeavenToHell (HTH) environment, facilitating interactive data processing and computation.
- Each
print
statement in Python code executed viarunPyCode
results in output displayed on a new line, ensuring clear separation and readability.
- The
runPyCode
function captures and displays Pythonprint
statements on new lines within the HTH environment, maintaining clarity and structure. - Ensure Python code executed via
runPyCode
is secure and validated to prevent unintended or malicious actions. - Use
runPyCode
to integrate dynamic Python scripting capabilities seamlessly into HeavenToHell applications, promoting versatility and interactivity.
The runHTML
function in HeavenToHell (HTH) dynamically renders HTML content within the application environment, enhancing the presentation and interactivity of GUI-based applications. For details on runHTML
, refer to its dedicated section.
runHTML(parent, id, scale, leftPos, topPos, width, height, HTMLcode)
-
parent
,id
,scale
,leftPos
,topPos
,width
,height
,HTMLcode
: Parameters for creating and positioning an HTML element within the GUI.
; Example of using runHTML to render HTML content within a GUI
Gui, Show, w700 h700
; we can't do parent := Gui1 because we must specify Gui1, Gui2, and so on as the first parameter. We cannot use a different variable since the transpiler expects the first parameter to be defined explicitly.
id := "iframe1"
scale := 1.0
leftPos := 10
topPos := 10
width := 600
height := 400
HTMLcode := "<html><body style='font-size: 80px; background-color: #ffffff;'><h1>Embedded Content</h1><p style='font-size: 65px;'>This is embedded HTML content.</p></body></html>"
; We must specify Gui1, Gui2, and so on as the first parameter. We cannot use a different variable since the transpiler expects the first parameter to be defined explicitly.
runHTML(Gui1, id, scale, leftPos, topPos, width, height, HTMLcode)
- Integrate dynamic HTML elements such as maps, multimedia, or interactive forms directly into HeavenToHell (HTH) GUI applications.
- Enhance user interaction and visual presentation by updating HTML content dynamically based on application logic or user inputs.
- Ensure HTML content provided to
runHTML
is secure and properly formatted to maintain application integrity. - Adjust positioning (
leftPos
,topPos
), size (width
,height
), andscale
parameters to suit application layout and design requirements. - Utilize
runHTML
to extend functionality and enhance user experience through dynamic HTML content integration in HeavenToHell applications.
The SoundPlay
command in HeavenToHell (HTH) allows users to control audio playback and manage sound-related actions within their applications. This command is designed to be used interactively with user-triggered events, ensuring a seamless and engaging audio experience.
SoundPlay, Command, Parameter
-
Command
: Specifies the action to perform on the audio.- Possible commands include:
-
Play
: Plays audio specified by theParameter
. -
Pause
: Pauses the currently playing audio. -
Resume
: Resumes the paused audio playback. -
Stop
: Stops the currently playing audio and resets its position. -
Mute
: Mutes the audio playback. -
Unmute
: Unmutes the audio playback. -
Volume
: Sets the volume level (from 0 to 100).
-
- Possible commands include:
-
Parameter
: Specifies additional information based on theCommand
.- For
Play
command:- Provide the audio file path or a URL.
- For
Volume
command:- Specify the volume level (0 to 100).
- For
; Play audio from a URL
SoundPlay, Play, https://example.com/audio.mp3
; Play audio from your specified path (to be encoded into a Base64 string inside the .html output)
; (ONLY in HTH v1)
SoundPlay, Play, C:/path/to/your/your.mp3
; Pause audio playback
SoundPlay, Pause
; Resume paused audio
SoundPlay, Resume
; Stop audio playback
SoundPlay, Stop
; Mute audio
SoundPlay, Mute
; Unmute audio
SoundPlay, Unmute
; Set volume to 50%
SoundPlay, Volume, 50
Before using the SoundPlay
function, ensure that the user has interacted with the website interface to initialize the necessary components. Here's an example implementation:
Gui, Show, +WebsiteMode, w%A_ScreenWidth% h%A_ScreenHeight%
Gui, Font, s30
StartButtonGR := "linear-gradient(90deg, rgba(0,0,0,1) 0%, rgba(81,81,81,1) 96%)"
Gui, Add, Button, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% cffffff -Border gr-%StartButtonGR% vStartWebsiteButton gStartWebsiteButton, Press here to continue
Gui, Font, s15
return
StartWebsiteButton:
GuiControl, Hide, StartWebsiteButton
; Add your GUI elements and interactions here
; Now you can use SoundPlay function after user interaction
SoundPlay, Play, https://example.com/audio.mp3
Return
- The
SoundPlay
function in HTH is ideal for managing audio playback based on user-triggered events or interactions. - Interacting with the website before using
SoundPlay
is crucial to ensure that necessary resources are loaded and user permissions are granted for audio playback, enhancing security and user experience.
This documentation provides comprehensive guidance on utilizing the SoundPlay
command in HeavenToHell (HTH), highlighting its capabilities and best practices for integrating interactive audio playback functionalities into web applications.
The MouseGetPos
command in HeavenToHell (HTH) retrieves the current position of the mouse cursor on the screen. This command is useful for obtaining coordinates that can be used in various interactive applications and scripts.
MouseGetPos, OutputVarX, OutputVarY
-
OutputVarX
: The variable that will receive the X-coordinate of the mouse cursor. -
OutputVarY
: The variable that will receive the Y-coordinate of the mouse cursor.
; Declare variables to store mouse coordinates
MouseX := 0
MouseY := 0
; Retrieve mouse cursor position
MouseGetPos, MouseX, MouseY
; Display the mouse coordinates
MsgBox, Mouse X: %MouseX%, Mouse Y: %MouseY%
- The
MouseGetPos
command allows for precise tracking of mouse cursor positions. - Mouse coordinates obtained using
MouseGetPos
can be used to trigger specific actions based on mouse interactions within an application.
The OnMouseClick
subroutine in HeavenToHell (HTH) allows developers to handle mouse click events directly within a script, without requiring additional event handlers. This approach simplifies mouse click event management and enhances interactivity in applications.
OnMouseClick:
; Perform actions upon mouse click
MouseGetPos, x, y
MsgBox, You clicked at x: %x% y: %y%
Return
- No specific parameters are required for
OnMouseClick
itself. This subroutine automatically triggers upon any mouse click event.
; Define OnMouseClick subroutine to handle mouse click events
OnMouseClick:
; Retrieve mouse cursor position
MouseGetPos, x, y
; Display a message box with mouse click coordinates
MsgBox, You clicked at x: %x% y: %y%
Return
-
OnMouseClick
is a self-contained subroutine that triggers automatically upon any mouse click event. - Use
MouseGetPos
withinOnMouseClick
to obtain the mouse cursor position at the time of the click and perform corresponding actions based on the click location.
The following example script divides each corner of the screen into 50-pixel segments to detect mouse moves within specific regions.
; Set up a timer to continuously monitor mouse position
; Check every 100 milliseconds (0.1 seconds)
SetTimer, CheckMousePosition, 100
return
; Subroutine to check mouse position
CheckMousePosition:
MouseGetPos, x, y
; Define 50-pixel regions around each corner
CornerSize := 50
TopLeftX := 0
TopLeftY := 0
TopRightX := A_ScreenWidth - CornerSize
TopRightY := 0
BottomLeftX := 0
BottomLeftY := A_ScreenHeight - CornerSize
BottomRightX := A_ScreenWidth - CornerSize
BottomRightY := A_ScreenHeight - CornerSize
; Determine which corner the mouse is located based on mouse coordinates
if (x >= TopLeftX && x < (TopLeftX + CornerSize) && y >= TopLeftY && y < (TopLeftY + CornerSize))
{
MsgBox, You moved to the top left corner of the screen.
}
else if (x >= TopRightX && y >= TopRightY && y < (TopRightY + CornerSize))
{
MsgBox, You moved to the top right corner of the screen.
}
else if (x >= BottomLeftX && x < (BottomLeftX + CornerSize) && y >= BottomLeftY)
{
MsgBox, You moved to the bottom left corner of the screen.
}
else if (x >= BottomRightX && y >= BottomRightY)
{
MsgBox, You moved to the bottom right corner of the screen.
}
Return
- The
SetTimer
command is used to trigger theCheckMousePosition
subroutine every 100 milliseconds (0.1 seconds), allowing continuous monitoring of the mouse position. - The
MouseGetPos
command retrieves the current mouse cursor position (x
andy
coordinates). - The script defines 50-pixel regions around each corner of the screen (
TopLeft
,TopRight
,BottomLeft
,BottomRight
) to detect if the mouse is within specific areas. - Modify the
CornerSize
variable to adjust the size of the regions around each corner based on your application's requirements.
This documentation provides detailed information on MouseGetPos
, OnMouseClick
, and an additional example using SetTimer
to monitor mouse positions within specific 50-pixel regions around each corner of the screen in HeavenToHell (HTH). These commandalities enhance user interactivity and enable responsive behaviors based on mouse interactions in scripts and applications.
The Title
command in HeavenToHell (HTH) is used to set the title of the website displayed in the browser tab. This command allows developers to customize the title dynamically based on specific conditions or predefined values.
Title, NewTitle
-
NewTitle
: The new title to set for the website tab.
; Set a static title
Title, Hello World
; Set a dynamic title using a variable
title2 := "Another Title"
Title, %title2%
- The
Title
command updates the title displayed in the browser tab. - If no title is specified using
Title
, the default title is the name of the.hth
file.
The Icon
command in HeavenToHell (HTH) is used to set the icon (favicon) for the website displayed in the browser tab. This command allows developers to specify a custom icon sourced from a URL or a local file path.
Icon, IconSource
-
IconSource
: The source of the icon, which can be a URL or a local file path.
; Set the website icon from a URL
Icon, https://example.com/image.png
; Set the website icon from a local file path
; (ONLY in HTH v1)
Icon, C:/path/to/your/your.png
- If no icon is specified using
Icon
, the default icon is the HeavenToHell (HTH) logo.
- The
Icon
command sets the favicon for the website, improving its visual identity in the browser tab. - The specified icon can be sourced from a URL or a local file path, with support for Base64 encoding for local file paths within
.hth
output.
The StoreLocally
function in HeavenToHell (HTH) provides an interface to interact with the browser's local storage, allowing developers to store, retrieve, and manipulate data persistently on the client side.
StoreLocally(action, key, value)
-
action
: Specifies the action to perform on the local storage.-
e
: Check if the local storage is empty. -
r
: Retrieve data from the specifiedkey
. -
s
: Storevalue
into the specifiedkey
. -
d
: Delete data associated with the specifiedkey
. -
dALL
: Delete all data from the entire local storage.
-
-
key
: The key used to identify the data in the local storage. -
value
: (Optional) The value to store in the local storage when performing thes
action.
; Check if the local storage is empty
if !(StoreLocally("e"))
{
; Retrieve data from the "var1" key and increment it
data := ParseInt(StoreLocally("r", "var1"))
data++
; Store the updated data back into the "var1" key
StoreLocally("s", "var1", data)
}
else
{
; Initialize data if the "var1" key does not exist
data := 1
; Store the initial data into the "var1" key
StoreLocally("s", "var1", data)
}
; Display a message based on the stored data
MsgBox, This is your %data% visit!
- The
StoreLocally
function allows for common operations on the browser's local storage. - Use
action
to specify the desired operation (e
for checking emptiness,r
for retrieving,s
for storing,d
for deleting by key, anddALL
for clearing the entire local storage). - Retrieve stored data using
StoreLocally("r", key)
and store data usingStoreLocally("s", key, value)
. - Ensure proper initialization and error handling based on the expected state of local storage keys during script execution.
The getUrlParams
function in HeavenToHell (HTH) retrieves the query parameters from the current URL and returns them as a string. This function is useful for extracting and parsing parameters passed via the URL.
getUrlParams()
- A string containing the query parameters from the current URL.
; Retrieve and display URL parameters
params := getUrlParams()
if (params != "")
{
MsgBox, % params
Loop, Parse, params, "&"
{
MsgBox, % A_LoopField
}
}
- The
getUrlParams
function extracts query parameters from the current URL. - Use
Loop, Parse
to iterate through individual parameters extracted from the URL string.
The reloadWithParams
function in HeavenToHell (HTH) reloads the current webpage with specified query parameters appended to the URL. This function allows developers to dynamically update the URL parameters and trigger page reloads with new parameters.
reloadWithParams(params)
-
params
: The query parameters to append to the URL for reloading.
par := getUrlParams()
if (par != "")
{
MsgBox, % par
Loop, Parse, par, "&"
{
MsgBox, % A_LoopField
}
}
Gui, Show, w500 h500
Gui, Add, Button, x10 y10 w200 h50 gButton, Reload with params
return
Button:
; Define a random number to append as a parameter
Random, ranNum1, 1, 100
Random, ranNum2, 1, 100
; Reload the webpage with custom query parameters
reloadWithParams("?p=hello&man&15&" . ranNum1 . "&" . ranNum2)
Return
- The
reloadWithParams
function appends specified query parameters to the URL and triggers a page reload with the updated URL. - Use this function to dynamically modify URL parameters and reload the webpage based on specific actions or conditions.
The getDataFromAPI
function in HeavenToHell (HTH) performs an HTTP GET request to retrieve data from an external API endpoint and processes the response asynchronously.
getDataFromAPI(url)
-
url
: The URL of the API endpoint to request data from.
jsonOutput := getDataFromAPI("https://api.example.com/data")
- The
getDataFromAPI
function initiates an HTTP GET request to the specified API endpoint.
The getDataFromJSON
function in HeavenToHell (HTH) retrieves specific data from a JSON string using a path-like syntax to navigate nested objects and arrays.
getDataFromJSON(jsonString, path)
-
jsonString
: The JSON string containing the data to parse. -
path
: The path specifying the location of the desired data within the JSON structure.
- The value retrieved from the specified path within the JSON structure.
; get sample JSON data from the api
jsonData := getDataFromAPI("https://dummy.restapiexample.com/api/v1/employees")
; Define JSON paths to retrieve specific data
path1 := "data[11].employee_name"
path2 := "data[11].employee_salary"
path3 := "data[11].employee_age"
; Retrieve data using getDataFromJSON function and display results
MsgBox, % getDataFromJSON(jsonData, path1)
MsgBox, % getDataFromJSON(jsonData, path2)
MsgBox, % getDataFromJSON(jsonData, path3)
You can open the API URL in your web browser, then copy the JSON response from the API. Next, go to jsonpathfinder.com and paste the JSON. Then find your paths. Make sure not to copy the x.
at the beginning of the string from the JSON path.
- The
getDataFromJSON
function enables navigation through nested JSON objects using a path-like syntax. - This function simplifies data extraction from complex JSON responses retrieved from APIs or other sources.
The getDataFromEndpoint
function in HeavenToHell (HTH) facilitates the retrieval and transmission of data to or from a backend server. This function is designed to interact with a backend server assumed to be running locally or accessible via a network.
getDataFromEndpoint(data, endpoint)
-
data
: The data to be sent to the endpoint. This parameter is required, even when only retrieving data. If no data needs to be sent, an empty string or null value can be provided. -
endpoint
: The endpoint of the backend server to which the request will be made, formatted as a single slash ("/endpoint").
; Send data to the endpoint and retrieve response data
response := getDataFromEndpoint(myData, "/endpoint")
; Process the response data
MsgBox, %response%
data := "some data here"
if (isConnectedToBackend())
{
MsgBox, We are connected to a backend
MsgBox, % getDataFromEndpoint(data, "/endpoint1")
MsgBox, % getDataFromEndpoint("hejsdfbx kdjzcx kzjdx c", "/endpoint1")
sdf := "/endpoint3"
getDataFromEndpoint(data, "/endpoint2")
getDataFromEndpoint(data, sdf)
var1 := "Hello"
if (var1 = getDataFromEndpoint(data, "/endpoint4"))
{
MsgBox, yey
}
}
else
{
MsgBox, We are not connected to a backend
}
- The
getDataFromEndpoint
function interacts with a backend server, which can be running locally or accessible via a network. - It supports both sending and receiving data to and from the specified endpoint.
- The
data
parameter is required, even when only retrieving data. If no data is sent back form the backend, it will result in an error, so make sure the backend always returns something, even if it's some text otherwise, we will get an error. - The
endpoint
parameter specifies the endpoint of the backend server to which the request will be made, formatted as a single slash ("/endpoint"). - Upon execution, the function returns the response data received from the endpoint.
The getDataFromEndpoint
function provides a convenient way to interact with backend servers, facilitating various data transmission and retrieval operations for local or networked backend services.
The isMobileDevice
function in HeavenToHell (HTH) enables developers to detect whether the script is running on a mobile device. This functionality is useful for implementing device-specific behavior or optimizations in scripts intended for both desktop and mobile environments.
isMobileDevice()
- Returns
true
if the script is running on a mobile device. - Returns
false
if the script is not running on a mobile device.
if (isMobileDevice())
{
; Perform mobile-specific actions
MsgBox, Running on a mobile device!
}
else
{
; Perform desktop-specific actions
MsgBox, Running on a desktop device!
}
In this example, the isMobileDevice
function is used to determine whether the script is running on a mobile device. Depending on the result, the script executes different actions tailored to the device type.
- The
isMobileDevice
function provides a simple and reliable way to detect the device type within HeavenToHell (HTH) scripts. - Developers can use the return value of the
isMobileDevice
function to implement device-specific logic or optimizations in their scripts.
The isConnectedToBackend
function in HeavenToHell (HTH) allows developers to check whether the script is currently connected to a backend server or service. This functionality is commonly used in networked applications to determine the script's connectivity status and adjust behavior accordingly.
isConnectedToBackend()
- Returns
true
if the script is connected to the backend. - Returns
false
if the script is not connected to the backend.
if (isConnectedToBackend())
{
; Perform actions when connected to the backend
MsgBox, Connected to the backend server!
}
else
{
; Perform actions when not connected to the backend
MsgBox, Not connected to the backend server!
}
In this example, the isConnectedToBackend
function is used to determine the script's connection status to the backend server. Depending on the result, different actions are executed to handle the connectivity state.
- The
isConnectedToBackend
function provides a convenient way to check the script's connectivity status within HeavenToHell (HTH) scripts. - Developers can use the return value of the
isConnectedToBackend
function to implement appropriate actions based on the script's connection status.
A collection of mathematical functions available in HTH.
Abs: Returns the absolute value of a number.
result := Abs(number)
- number: The number for which you want to find the absolute value.
- Returns the absolute value of the input number.
absValue := Abs(-5)
MsgBox, The absolute value of -5 is %absValue%
ACos: Returns the arccosine (in radians) of a number.
result := ACos(number)
- number: The number for which you want to find the arccosine.
- Returns the arccosine of the input number in radians.
arcCos := ACos(0.5)
MsgBox, The arccosine of 0.5 is %arcCos%
ASin: Returns the arcsine (in radians) of a number.
result := ASin(number)
- number: The number for which you want to find the arcsine.
- Returns the arcsine of the input number in radians.
arcSin := ASin(0.5)
MsgBox, The arcsine of 0.5 is %arcSin%
ATan: Returns the arctangent (in radians) of a number.
result := ATan(number)
- number: The number for which you want to find the arctangent.
- Returns the arctangent of the input number in radians.
arcTan := ATan(0.5)
MsgBox, The arctangent of 0.5 is %arcTan%
Ceil: Returns the smallest integer greater than or equal to a number.
result := Ceil(number)
- number: The number for which you want to find the smallest integer greater than or equal to.
- Returns the smallest integer greater than or equal to the input number.
ceiled := Ceil(4.3)
MsgBox, The smallest integer greater than or equal to 4.3 is %ceiled%
Cos: Returns the cosine of an angle (in radians).
result := Cos(angle)
- angle: The angle (in radians) for which you want to find the cosine.
- Returns the cosine of the input angle.
cosValue := Cos(0)
MsgBox, The cosine of 0 radians is %cosValue%
Exp: Returns the value of E raised to the power of a number.
result := Exp(number)
- number: The exponent to which E is raised.
- Returns E raised to the power of the input number.
expValue := Exp(2)
MsgBox, E raised to the power of 2 is %expValue%
Floor: Returns the largest integer less than or equal to a number.
result := Floor(number)
- number: The number for which you want to find the largest integer less than or equal to.
- Returns the largest integer less than or equal to the input number.
floored := Floor(4.9)
MsgBox, The largest integer less than or equal to 4.9 is %floored%
Ln: Returns the natural logarithm of a number.
result := Ln(number)
- number: The number for which you want to find the natural logarithm.
- Returns the natural logarithm of the input number.
lnValue := Ln(2.71828)
MsgBox, The natural logarithm of 2.71828 is %lnValue%
Log: Returns the logarithm of a number to a specified base.
result := Log(number)
- number: The number for which you want to find the natural logarithm.
- Returns the natural logarithm of the input number.
logValue := Log(100)
MsgBox, The natural logarithm of 100 is %logValue%
Round: Returns the nearest integer to a number.
result := Round(number)
- number: The number to be rounded.
- Returns the nearest integer to the input number.
rounded := Round(4.6)
MsgBox, The nearest integer to 4.6 is %rounded%
Sin: Returns the sine of an angle (in radians).
result := Sin(angle)
- angle: The angle (in radians) for which you want to find the sine.
- Returns the sine of the input angle.
sinValue := Sin(0)
MsgBox, The sine of 0 radians is %sinValue%
Sqrt: Returns the square root of a number.
result := Sqrt(number)
- number: The number for which you want to find the square root.
- Returns the square root of the input number.
sqrtValue := Sqrt(9)
MsgBox, The square root of 9 is %sqrtValue%
Tan: Returns the tangent of an angle (in radians).
result := Tan(angle)
- angle: The angle (in radians) for which you want to find the tangent.
- Returns the tangent of the input angle.
tanValue := Tan(0)
MsgBox, The tangent of 0 radians is %tanValue%
A collection of Build-in Function available in HTH.
Chr: Returns the character corresponding to a specified ASCII code.
result := Chr(asciiCode)
- asciiCode: The ASCII code for which you want to retrieve the corresponding character.
- Returns the character corresponding to the input ASCII code.
character := Chr(65)
MsgBox, The character corresponding to ASCII code 65 is %character%
InStr: Returns true if a substring is found within a string; otherwise, returns false.
InStr(haystack, needle)
- haystack: The string in which you want to search for the substring.
- needle: The substring you want to find within the haystack.
- Returns true if the substring is found within the string; otherwise, returns false.
var1 := "Hello World"
if (InStr(var1, "World"))
{
MsgBox, We found `"World`" in %var1%
}
RegExMatch: Searches a string using a regular expression pattern and returns the position and length of the match.
result := RegExMatch(subject, regexPattern, outputArray)
- subject: The string you want to search using the regular expression pattern.
- regexPattern: The regular expression pattern to match against the string.
- outputArray: (Optional) An array to store the position and length of the match.
- Returns the position of the match within the string. If outputArray is provided, it also stores the position and length of the match in the specified array.
matchPosition := RegExMatch("Hello World", "World", matchArray)
MsgBox, The position of the match is %matchPosition%
GetKeyState: Retrieves the state of a key.
result := GetKeyState(keyName, mode)
- keyName: The name of the key whose state you want to retrieve.
-
mode: The mode in which to retrieve the key state.
U
for Up andD
for Down aka pressed
- Returns the state of the specified key.
SetTimer, code, 1
return
code:
if (GetKeyState("Up", "D"))
{
MsgBox, The Up key is Down exiting the subroutine
SetTimer, code, Off
}
Return
StrLen: Returns the length of a string.
result := StrLen(string)
- string: The string for which you want to find the length.
- Returns the length of the input string.
length := StrLen("Hello World")
MsgBox, The length of the string is %length%
SubStr: Returns a substring from a string.
result := SubStr(string, startPos, length)
- string: The string from which you want to extract a substring.
- startPos: The starting position of the substring.
- length: (Optional) The length of the substring to extract.
- Returns the extracted substring.
substring := SubStr("Hello World", 7)
MsgBox, The substring is %substring%
substring := SubStr("Hello World", 1, 5)
MsgBox, The first 5 characters are %substring%
Trim: Removes leading and trailing whitespace from a string.
result := Trim(string)
- string: The string from which you want to remove leading and trailing whitespace.
- Returns the string with leading and trailing whitespace removed.
trimmedString := Trim(" Hello World ")
MsgBox, The trimmed string is %trimmedString%
StrReplace: Replaces occurrences of a substring within a string.
result := StrReplace(string, find, replace)
- string: The string in which you want to replace occurrences of a substring.
- find: The substring you want to replace.
- replace: The replacement string.
- Returns the modified string with occurrences of the substring replaced.
str1 := "Hello World"
modifiedString := StrReplace(str1, "World", "Universe")
MsgBox, The modified string is %modifiedString%
Mod: Returns the remainder of a division operation.
result := Mod(dividend, divisor)
- dividend: The number to be divided.
- divisor: The number by which to divide the dividend.
- Returns the remainder of the division operation.
; Define a string with a list of numbers separated by commas
numbers := "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 33, 34, 20, 61, 100"
; Start a loop to parse each number from the string
Loop, Parse, numbers, ", "
{
; Convert the current loop field (A_LoopField) to an integer and check if it's even
if (!Mod(ParseInt(A_LoopField), 2))
{
; If the number is even, display a message box with the even number
MsgBox, % "The number " . A_LoopField . " is even"
}
else
{
; If the number is odd, display a message box with the odd number
MsgBox, The number %A_LoopField% is odd
}
}
Asc: Returns the ASCII code of a character.
result := Asc(character)
- character: The character for which you want to retrieve the ASCII code.
- Returns the ASCII code of the input character.
asciiCode := Asc("A")
MsgBox, The ASCII code of 'A' is %asciiCode%
ParseInt: Returns the parsed integer value of a string.
result := ParseInt(num)
- num: The string to parse for an integer value.
- Returns the parsed integer value of the input string. If the input is
null
, it returnsnull
.
; num with spaces and it's a string, but there are no letters so it's an int
num := " 123 "
MsgBox, Before: |%num%|
intValue := ParseInt(num)
MsgBox, After: The parsed integer value is |%intValue%|
Another example:
numbers := "45, 75, 60, 6, 10"
out := 0
Loop, Parse, numbers, `,
{
num2 := ParseInt(A_LoopField)
out := out + num2
}
MsgBox, % out
StrLower: Converts a string to lowercase.
result := StrLower(string)
- string: The string to convert to lowercase.
- Returns the lowercase version of the input string.
input := "Hello World"
lowercase := StrLower(input)
MsgBox, The lowercase version of %input% is %lowercase%
This modified section explains the usage and purpose of StrLower()
in HTH, demonstrating how to use it with an example. You can use this format to provide clear documentation for the StrLower()
function.
Build-in Variables provided by HTH for various purposes.
- A_Index
- A_LoopField
- A_LastKey
- A_ThisHotkey
- 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
A_Index: Contains the number of the current loop iteration in a loop.
Loop, 5
{
MsgBox, Loop iteration: %A_Index%
}
A_LoopField: Contains the contents of the current field (column) in a loop that is iterating over a delimited file or string.
var1 := "apple,banana,orange"
Loop, Parse, var1, `,
{
MsgBox, Current field: %A_LoopField%
}
A_LastKey: Contains the last key pressed by the user on the page.
Sleep, 2000
; Meanwhile press a key
MsgBox, Last key pressed: %A_LastKey%
A_ThisHotkey: Retrieves the key pressed only inside a label called OnKeyPress.
OnKeyPress:
MsgBox, The key pressed inside OnKeyPress: %A_ThisHotkey%
Return
A_ScreenWidth: Contains the width of the screen in pixels.
MsgBox, Screen width: %A_ScreenWidth% pixels
A_ScreenHeight: Contains the height of the screen in pixels.
MsgBox, Screen height: %A_ScreenHeight% pixels
A_GuiControl: Contains the text of the last control used in a GUI.
Gui, Show, h500 w500
Gui, Add, Button, x10 y10 w150 h40 gButtonPress, Press Me
return
ButtonPress:
MsgBox, Last control used: %A_GuiControl%
Return
A_TimeIdle: Contains the time in milliseconds that has elapsed since the last input from the user.
Sleep, 1500
; Meanwhile move you mouse or press some key or do nothing
MsgBox, Time idle: %A_TimeIdle% milliseconds
A_TickCount: Contains the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC.
StartTime := A_TickCount
; code here
Sleep, 1500
ElapsedTime := A_TickCount - StartTime
ms := ElapsedTime
; Calculate the components
hours := Floor(ms / 3600000)
ms := Mod(ms, 3600000)
minutes := Floor(ms / 60000)
ms := Mod(ms, 60000)
seconds := Floor(ms / 1000)
milliseconds := Mod(ms, 1000)
; Display the result
ElapsedTime123 := ""
ElapsedTime123 .= hours . "h " . minutes . "m " . seconds . "s " . milliseconds . "ms"
MsgBox, % ElapsedTime123
A_Now: Contains the current local time in "Month/Day/Year, Hour:Minute:Second AM/PM" format.
MsgBox, Current local time: %A_Now%
A_YYYY: Contains the current year in four digits.
MsgBox, Current year: %A_YYYY%
A_MM: Contains the current month in two digits.
MsgBox, Current month: %A_MM%
A_DD: Contains the current day of the month in two digits.
MsgBox, Current day: %A_DD%
A_MMMM: Contains the full name of the current month.
MsgBox, Full name of current month: %A_MMMM%
A_MMM: Contains the abbreviated name of the current month.
MsgBox, Abbreviated name of current month: %A_MMM%
A_DDDD: Contains the full name of the current day of the week.
MsgBox, Full name of current day: %A_DDDD%
A_DDD: Contains the abbreviated name of the current day of the week.
MsgBox, Abbreviated name of current day: %A_DDD%
A_Hour: Contains the current hour in two digits (24-hour format).
MsgBox, Current hour: %A_Hour%
A_Min: Contains the current minute in two digits.
MsgBox, Current minute: %A_Min%
A_Sec: Contains the current second in two digits.
MsgBox, Current second: %A_Sec%
A_Space: Represents the space key.
MsgBox, Hello%A_Space%man
A_Tab: Represents the tab key.
;Press F12 in your browser to see the result in the console of your browser.
OutPutdebug, |%A_Tab%Hello man|
Learn about the backend architecture and Python integration in the HTH programming language here.
HTH streamlines backend connectivity with its built-in function called getDataFromEndpoint()
, enabling developers to easily send and retrieve data from a specified endpoint with just one function call.
When you run your HTH code, you'll get index.html
as output. Additionally, if you use the function getDataFromEndpoint()
anywhere in the code, HTH will generate a server.py
file for better backend connectivity.
To run the generated Python backend, you'll need to:
- Install Python on your system.
- Install the Flask library for Python.
Here's a step-by-step guide to getting started with backend development in HTH using Python:
- Write your HTH code, making use of the
getDataFromEndpoint()
function to interact with the backend. - Run your HTH code.
- Once executed, you'll find an
index.html
file as output. - Locate the
server.py
file generated by HTH if you've used thegetDataFromEndpoint()
function. (ONLY in HTH v1) - Ensure Python and Flask are installed on your system.
- Run the
server.py
file using Python. - Your Python backend is now running and ready to handle requests from your HTH frontend.
By integrating Python with HTH, developers can leverage the power of Python's extensive libraries and frameworks for building robust backend systems while enjoying the simplicity and ease of use of the HTH programming language.
Discover the recommended code editor for working with the HTH programming language.
Check out the best editor for HTH at https://github.com/TheMaster1127/SciTE4HTH
View a showcase of programs created using the HTH programming language, demonstrating its capabilities.
Check out this type racer written in HTH at https://github.com/TheMaster1127/HTH/blob/main/test.hth