Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK GUI Newcomer Help


  • Please log in to reply
2 replies to this topic
Cybrpro
  • Members
  • 8 posts
  • Last active: Apr 19 2014 08:52 AM
  • Joined: 09 Jul 2009

My aim here is to kind of give others a fast track to being able to make their own simple GUIs. I will take this Basic GUI Script and explain simple as I can whats going on. Hopefully with this post, a little tinker time, and SmartGUI tool found here: www.autohotkey.com/docs/SmartGUI/ That you will be a master of the AHK GUI in no time.

Gui,2:+AlwaysOnTop
Gui,2:Add,Edit,x0 y0 w200 h20 vS 
Gui,2:Add,button, default gA1, Ok 
Gui,2:Show,,User Input
Return

A1:
Gui,2:submit,nohide
Msgbox, 262208,Title Of Msgbox,%s% 
Gui,2:destroy
return

2GuiClose:
ExitApp
 
;Hope This Helps, most every line is explained.

Gui,2:+AlwaysOnTop
;Whats Gui,2:? the 'Gui,#:' command I believe that it lets you Target specific Gui pieces for like 'Gui,2:destroy' command not needed with a simple Gui. Have I personally have not done anything with it yet at the time of writing this, just thought I would say something about it case people wondered what the...  

;AlwaysOnTop is one of many +Options you may use found in the GUI Help.

Gui,2:Add,Edit,x0 y0 w200 h20 vS 
;Above line kinda explained> Gui,#:add,edit,loc on screen xy, size object wh, v* is the variable where users input is stored.

Gui,2:Add,button, default gA1, Ok 
;whats gA1?  'g' = goto so 'A1' is the function label, don't forget a 'return' on your block or it keeps going to the next line.
;Whats the A1? just a label can be what ever you want, in this case it stands for Action1 to me. 
;you can do default or Hide default, enter performs default button action.

Gui,2:Show,,User Input
;Gui,#:Show, Options, Title> the options for show can be found on GUI Help page.

Return


A1:
Gui,2:submit,nohide
;This line submits the users input, can hide the input window or not with nohide.

Msgbox, 262208,Title Of Msgbox,%s% 
;what the? Msgbox = makes msg box, 262208 is the added value of the selected Options found in msgbox help, Title, then text to be displayed in this case variable S.

Gui,2:destroy
;Kills the Targeted Gui.

return

2GuiClose:
;closes the Gui of target #GuiClose: Remember # stuff does not even need to be there on a simple Gui so for instance Gui,2:+AlwaysOnTop becomes Gui,+AlwaysOnTop and 2GuiClose: becomes GuiClose:

ExitApp
;Exits App


col_mik
  • Members
  • 171 posts
  • Last active: Aug 29 2015 03:29 PM
  • Joined: 28 Jun 2015

Many thanks for this.  I just spent a long time trying to find out what the "2:" means in

 

Gui,2:Add,Edit,x0 y0 w200 h20 vS

 

In my case, I was trying to understanmd a script by FlyingDman, in which he uses the line ...

 

gui, Drawing: Show, , Drawing

 

... and I couldn't find any explanation for the "Drawing:" (the first one, followed by a colon).   I conclude that it is a label to differentiate between GUI's if there are more than one being used simultaneously.

 

In your example above, then, I guess that "2:" is a text label, rather than an arithmetic value.



space
  • Members
  • 520 posts
  • Last active:
  • Joined: 12 Aug 2014
If you have multiple Guis you need to be able to identify the Gui if you want to interact with it - you can give each Gui a name - which can be a number like 2: OR text like Drawing: - see http://ahkscript.org...nds/Gui.htm#New and http://ahkscript.org...ui.htm#MultiWin