I have read a few times about the Format function in AHK but I can't practically make it to use and here's a case where I need to understand it better.
I'm trying to display a clean multi-line tooltip that shows some calculations.
The alignement of a invisible column is really important to make it consistent and look good.
Now all I have to solve the problem is guessing how many spaces it needs to display aligned.
Would someone please provide me with an example of how to properly format this kind of multi-line tooltip please ?
I'd really appreciate it.
Here's my example code that should run and display what I currently got:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force ; Prevent double execution of this script
#Persistent
; Faking what are normally dynamic variables (changing with different calculations)
OverRowNumber := 1
, Qt_1 := 2
, Mt_1 := 100
, RawTs_1 := 4.35
, RawTq_1 := 8.68
; Prepare the values to display in the tooltip
, Ligne_Quantite := Qt_%OverRowNumber%
, Ligne_PrixUnitaire := Mt_%OverRowNumber%
, Ligne_TPSUnitaire := RawTs_%OverRowNumber%
, Ligne_TVQUnitaire := RawTq_%OverRowNumber%
, Ligne_TotalHorsTx := (Ligne_PrixUnitaire - (Ligne_TPSUnitaire + Ligne_TVQUnitaire)) * Ligne_Quantite
, Ligne_TotalTPS := Ligne_TPSUnitaire * Ligne_Quantite
, Ligne_TotalTVQ := Ligne_TVQUnitaire * Ligne_Quantite
, Ligne_TotalAvecTx := Ligne_PrixUnitaire * Ligne_Quantite
; Tooltip to format :
, TT_Tip := "Calcul ligne #"OverRowNumber " :"
. "`n`n Sous-total hors taxes : " Ligne_TotalHorsTx " $ ( $ " Ligne_PrixUnitaire " * Quantité = $ " Ligne_TotalAvecTx " - Taxes )"
. "`n + TPS : " Ligne_TotalTPS " $ ( $ " Ligne_TPSUnitaire " * Quantité )"
. "`n + TVQ : " Ligne_TotalTVQ " $ ( $ " Ligne_TVQUnitaire " * Quantité )"
. "`n ________________________________________________________________________________________________________________________"
. "`n Sous-total avec taxes : " Ligne_TotalAvecTx " $"
ToolTip, % TT_Tip, % A_ScreenWidth//3, % A_ScreenHeight // 2.5 ; Show the ToolTip
SetTimer, ToolTipOff, -4000 ; Set the Timer to automatically turn off tooltip after number of ms ;*[Untitled1]
Return
ToolTipOff:
Tooltip ; Off
ExitApp