Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

AutoHotkey: Resize gui form of an AutoHotkey script

Hello experts,

I have the following AutoHotkey script:

;========================================
;Gui: Calculate Distance Speed Time (DST)
;========================================




<^>!d:: ; hotkey is AltGr+D - make it whatever you want
DSTtitle:="Distance Speed Time Calculator"
If (WinExist(DSTtitle))
{
  Gui,+OwnDialogs
  MsgBox,4112,Error,%DSTtitle% dialog is already open
  Return
}
Gui,New,,%DSTtitle%
Gui,Font,s12 w1000
Gui,Add,Text,,Enter two of the three items below and click the Calculate button
Gui,Add,Text,,Distance (KM):
Gui,Add,Edit,vDistance x+10 yp
Gui,Add,Text,xm,Speed (KM/Hour):
Gui,Add,Edit,vSpeed x+10 yp
Gui,Add,Text,xm,Time (Minutes):
Gui,Add,Edit,vTime x+10 yp
Gui,Add,Text
Gui,Add,Button,xm gButtonCalculateDST Default,&Calculate
Gui,Add,Button,x+10 gButtonExitDST,E&xit
Gui,Show
Return


ButtonCalculateDST:
Gui,+OwnDialogs
Gui,Submit,NoHide
If (Distance="")
{
  ; calculate Distance from Speed and Time
  Time:=Time/60 ; convert minutes to hours
  Distance:=Format("{:.2f}",Speed*Time)
  GuiControl,,Distance,%Distance%
  Return
}
Else
If (Speed="")
{
  ; calculate Speed from Distance and Time
  Time:=Time/60 ; convert minutes to hours
  Speed:=Format("{:.2f}",Distance/Time)
  GuiControl,,Speed,%Speed%
  Return
}
Else
If (Time="")
{
  ; calculate Time from Distance and Speed
  Time:=Format("{:.2f}",60*(Distance/Speed))
  GuiControl,,Time,%Time%
  Return
}
MsgBox,4144,Error,One of the three values must be blank/empty/null
Return


ButtonExitDST:
Gui,Destroy
Return


;====================================
;Gui: Calculate BMI
;====================================


<^>!):: ; hotkey is AltGr+B - make it whatever you want
BMItitle:="Body Mass Index"
If (WinExist(BMItitle))
{
  Gui,+OwnDialogs
  MsgBox,4112,Error,%BMItitle% dialog is already open
  Return
}
Gui,New,,%BMItitle%
Gui,Add,Text,,Enter your weight in kilograms:
Gui,Add,Edit,vWeight x+10 yp
Gui,Add,Text,xm,Enter your height in meters:
Gui,Add,Edit,vHeight x+10 yp
Gui,Add,Text
Gui,Add,Text,xm,Your BMI is:
Gui,Add,Edit,vBMI x+10 yp
Gui,Add,Text
Gui,Add,Button,xm gButtonCalculateBMI Default,&Calculate
Gui,Add,Button,x+10 gButtonExitBMI,E&xit
Gui,Show
Return


ButtonCalculateBMI:
Gui,+OwnDialogs
Gui,Submit,NoHide
If (Weight="") or (Height="")
{
  MsgBox,4144,Error,You must enter Weight and Height
  Return
}
If Weight is not number
{
  MsgBox,4144,Error,Weight must be a number
  Return
}
If Height is not number
{
  MsgBox,4144,Error,Height must be a number
  Return
}
If (Weight<=0) or (Height<=0)
{
  MsgBox,4144,Error,Weight and Height must both be positive numbers
  Return
}
BMI:=Format("{:.2f}",(Weight/(Height*Height)))
GuiControl,,BMI,%BMI%
Return


ButtonExitBMI:
Gui,Destroy
Return

Open in new window

The first AutoHotkey script has a better size letter and instructions are bold.

I was wondering how can I have the same for the second script.


Thank you for your help.

SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're welcome, Luis. Here's an explanation of those parameters in the Gui,Font statement. The value following the "s" is the font size in points. For example, this means a font size of 12 points:

s12

The value following the "w" is the font weight (boldness), which is a number between 1 and 1000, where 400 is a "normal" weight and 700 is a "bold" weight. For example, this is the boldest font possible:

w1000

Putting those two together, you get this:

Gui,Font,s12 w1000

That's a very bold, 12-point font. I hope this helps you to understand why it works for you. Regards, Joe
Avatar of Luis Diaz

ASKER

Noted, very helpful explanation. Thank you again Joe.