 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Novan Leon
Joined: 29 Apr 2009 Posts: 5
|
Posted: Wed Apr 29, 2009 7:29 pm Post subject: Standard Windows Wizard Template |
|
|
I created a wizard template based on the standard Windows wizard layout used by Add Printer Wizard and other wizards throughout the OS. As far as I'm aware all the dimensions are a 100% match. You can download the script and necessary files here:
Direct Link: wizard.zip
Size: 5.46 KB
File Contents:
- wizard.ahk - Main script to use as a template for your wizard
- wizard_example.ahk - Run this and take a look at the code to see how it works
- bannerarea.bmp
- bannerleft.bmp - replace this with your own 165x314 design to customize your first and last wizard screens
- bannerlogo.bmp - Replace this with your own 49x49 logo to customize your in-between/main wizard screens
- bannerright.bmp
- divider.bmp
Below is a preview comparing the standard Windows Add Printer Wizard menus with the menus created by the above script:
Here is the code, for those interested:
| Code: | TabCount = 5
;---- There should be a title and subtitle for each tab included in the TabCount above
Tab1Title = This is the title for Tab1
Tab1Subtitle = This is the subtitle for Tab1
Tab2Title = This is the title for Tab2
Tab2Subtitle = This is the subtitle for Tab2
Tab3Title = This is the title for Tab3
Tab3Subtitle = This is the subtitle for Tab3
Tab4Title = This is the title for Tab4
Tab4Subtitle = This is the subtitle for Tab4
Tab5Title = This is the title for Tab5
Tab5Subtitle = This is the subtitle for Tab5
;---- Count down the number of tabs to create the TabList
loop %TabCount%
{
if TabList =
{
TabCounter = %TabCount%
TabList = %TabCount%
}
else
{
TabList = %TabCounter%|%TabList%
}
if TabCounter > 0
TabCounter--
}
;---- Create the tab control from the TabList generated above (size would normally be w450 h228)
gui, add, tab, w0 h0 x0 y43 -Wrap vTabID, %TabList%
;---- Create controls used on every tab except first and last
gui, tab
gui, add, picture, w497 h2 x0 y313, divider.bmp
gui, add, button, w75 h23 x251 y327 vButtonBack gButtonBack, < &Back
gui, add, button, w75 h23 x326 y327 vButtonNext gButtonNext, &Next >
gui, add, button, w75 h23 x412 y327, Cancel
gui, add, picture, w497 h60 x0 y0, bannerarea.bmp
gui, add, picture, w49 h49 x443 y5, bannerlogo.bmp
gui, font, bold
gui, add, text, w358 h16 x22 y10 vBannerTitle backgroundtrans, Banner Title
gui, font
gui, add, text, w380 h26 x44 y25 vBannerSubtitle backgroundtrans, Banner Subtitle
guicontrol, disable, ButtonBack
;---- Create controls used on the first tab
gui, tab, 1
gui, add, picture, w164 h313 x0 y0, bannerleft.bmp
gui, add, picture, w333 h313 x164 y0, bannerright.bmp
gui, font, s12 bold, Verdana
gui, add, text, w284 h59 x172 y12 vStartTitle backgroundtrans, Start Title
gui, font
gui, add, text, w284 h39 x172 y77 vStartSubtitle backgroundtrans, Start Subtitle
;---- Create controls used on the last tab (identical to first tab except for the parent tab and the title output variables)
gui, tab, %TabCount%
gui, add, picture, w164 h313 x0 y0, bannerleft.bmp
gui, add, picture, w333 h313 x164 y0, bannerright.bmp
gui, font, s12 bold, Verdana
gui, add, text, w284 h59 x172 y12 vFinishTitle backgroundtrans, Finish Title
gui, font
gui, add, text, w284 h39 x172 y77 vFinishSubtitle backgroundtrans, Finish Subtitle
;---- <START> Insert your own controls for each tab here
;---- <END> Insert your own controls for each tab here
gui, -SysMenu
gui, show, w497 h360 center, My Wizard
LoadTab(1)
return
;---- <START> Insert your own functions and subroutines for each tab here
;---- <END> Insert your own functions and subroutines for each tab here
ButtonNext:
if ActiveTab >= %TabCount%
gosub Finish
else
ActiveTab++
LoadTab(ActiveTab)
return
ButtonBack:
ActiveTab--
LoadTab(ActiveTab)
return
LoadTab(x)
{
global TabCount, ActiveTab
if x <= 1
{
x = 1
ActiveTab = 1
guicontrol, disable, ButtonBack
guicontrol, text, ButtonNext, &Next >
GoToTab(x)
LoadText(x)
}
else if x >= %TabCount%
{
x = %TabCount%
ActiveTab = %TabCount%
guicontrol, enable, ButtonBack
guicontrol, text, ButtonNext, Finish
GoToTab(x)
LoadText(x)
}
else
{
guicontrol, enable, ButtonBack
guicontrol, text, ButtonNext, &Next >
GoToTab(x)
LoadText(x)
}
}
GoToTab(x)
{
global ActiveTab
guicontrol, choose, TabID, %x%
ActiveTab = %x%
}
LoadText(x)
{
Global
y := Tab%x%Title
z := Tab%x%Subtitle
guicontrol, text, BannerTitle, %y%
guicontrol, text, BannerSubtitle, %z%
guicontrol, text, StartTitle, %y%
guicontrol, text, StartSubtitle, %z%
guicontrol, text, FinishTitle, %y%
guicontrol, text, FinishSubtitle, %z%
}
Finish:
msgbox Yay!
ButtonCancel:
GuiClose:
exitapp |
Notes:
- Change the TabCount variable at the top of the script to change the number of wizard screens, the script will automatically change the formatting for the first and last screens appropriately.
- A TabXTitle and TabXSubtitle variable will need to be defined for each screen included in the TabCount.
- Use the designated areas to add your own controls, functions and subroutines as desired.
- To add controls to each screen, use the "gui, tab, X" command where X is the number of the desired tab prior to the controls you wish to add (see wizard_example.ahk for an example of how this works).
- Replace my immature msgbox command with your own finishing command after the Finish: label.
I don't have any plans to maintain this script, but you're free to take it and do with it what you will. Thanks to Icarus' script in this thread for getting me started. I hope you find it useful. Cheers! |
|
| Back to top |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 289 Location: Sauerland
|
Posted: Wed Apr 29, 2009 7:52 pm Post subject: |
|
|
Nice idea .
I will surely use it when the time comes! |
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Tue May 25, 2010 8:23 am Post subject: |
|
|
Don't suppose there is an alternate download location for "wizard.zip" or for the example. Love the script but cant figure out how to use it, just need an example to nudge me in the right direction.
Of course I don't totally expect a reply being that this was posted a year ago, but If I get one, thanks in advance. |
|
| Back to top |
|
 |
awannaknow
Joined: 14 Jun 2009 Posts: 324
|
Posted: Tue May 25, 2010 3:32 pm Post subject: |
|
|
Up, I'm interested too... | computerspazzz wrote: | Don't suppose there is an alternate download location for "wizard.zip" or for the example. Love the script but cant figure out how to use it, just need an example to nudge me in the right direction.
Of course I don't totally expect a reply being that this was posted a year ago, but If I get one, thanks in advance. |
|
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Tue May 25, 2010 7:59 pm Post subject: How To Use the Wizard - Example & Instructions |
|
|
Hey, why not reply to my own post, right? lol. I believe I may have figured it out, its a start anyway.
Specify The Amount of Tabs(windows/steps) here
Specify the titles:
| Code: | Tab1Title = This is the title for Tab1
Tab1Subtitle = This is the subtitle for Tab1
Tab2Title = This is the title for Tab2
Tab2Subtitle = This is the subtitle for Tab2
Tab3Title = This is the title for Tab3
Tab3Subtitle = This is the subtitle for Tab3
Tab4Title = This is the title for Tab4
Tab4Subtitle = This is the subtitle for Tab4
Tab5Title = This is the title for Tab5
Tab5Subtitle = This is the subtitle for Tab5 |
Here is the example of creating a control for the steps, Page 1 has some Text, page 2 has a button which runs "DoThis"
| Code: | ;---- <START> Insert your own controls for each tab here
Gui, Tab, 1
Gui, Add, Text, x100 y100 w200 h150 gDoThis, Hello World
Gui, Tab, 2
Gui, Add, Button, x100 y100 w200 h150 gDoThis, Hello World
;---- <END> Insert your own controls for each tab here |
Then a little below that there is a spot to put in the routines to actually do stuff:
| Code: | ;---- <START> Insert your own functions and subroutines for each tab here
DoThis:
MsgBox Hello
return
;---- <END> Insert your own functions and subroutines for each tab here |
And of course you will want the Finish button (on the last page) to Do a submit so at the bottom you will find:
| Code: | Finish:
msgbox Yay!
ButtonCancel:
GuiClose:
exitapp |
You would want to change that and add a Gui, Submit (probably) and then any functions you want to the program to actually accomplish before exiting, including running another program. You may want to add a return afterwords if you don't want it to exit (use NoHide flag on Gui, Submit), if you don't it will continue onto the the "exitapp" command there at the end and exit after done.
| Code: | Finish:
Gui, Submit
;Do whatever you want to do before exiting
;If you don't want to exit, include a return, and use Gui, Sumbit, NoHide
Return |
If you plan to use this Wizard as part of another program don't forget to change all the Gui to have the 2: or an appropriate number (see http://www.autohotkey.com/docs/commands/Gui.htm#MultiWin )
I would also like to mention the images are of course missing. I might take the time to find some and post them or maybe I'll just remove them, either way it would be a pretty simple matter to select some images, name them as specified and include them in the directory with the script. I plan on using this wizard in a program I've been working on for a long time so if I make more progress I will post it.
Here is the full Code
| Code: |
#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.
TabCount = 5
;---- There should be a title and subtitle for each tab included in the TabCount above
Tab1Title = This is the title for Tab1
Tab1Subtitle = This is the subtitle for Tab1
Tab2Title = This is the title for Tab2
Tab2Subtitle = This is the subtitle for Tab2
Tab3Title = This is the title for Tab3
Tab3Subtitle = This is the subtitle for Tab3
Tab4Title = This is the title for Tab4
Tab4Subtitle = This is the subtitle for Tab4
Tab5Title = This is the title for Tab5
Tab5Subtitle = This is the subtitle for Tab5
;---- Count down the number of tabs to create the TabList
loop %TabCount%
{
if TabList =
{
TabCounter = %TabCount%
TabList = %TabCount%
}
else
{
TabList = %TabCounter%|%TabList%
}
if TabCounter > 0
TabCounter--
}
;---- Create the tab control from the TabList generated above (size would normally be w450 h228)
gui, add, tab, w0 h0 x0 y43 -Wrap vTabID, %TabList%
;---- Create controls used on every tab except first and last
gui, tab
gui, add, picture, w497 h2 x0 y313, divider.bmp
gui, add, button, w75 h23 x251 y327 vButtonBack gButtonBack, < &Back
gui, add, button, w75 h23 x326 y327 vButtonNext gButtonNext, &Next >
gui, add, button, w75 h23 x412 y327, Cancel
gui, add, picture, w497 h60 x0 y0, bannerarea.bmp
gui, add, picture, w49 h49 x443 y5, bannerlogo.bmp
gui, font, bold
gui, add, text, w358 h16 x22 y10 vBannerTitle backgroundtrans, Banner Title
gui, font
gui, add, text, w380 h26 x44 y25 vBannerSubtitle backgroundtrans, Banner Subtitle
guicontrol, disable, ButtonBack
;---- Create controls used on the first tab
gui, tab, 1
gui, add, picture, w164 h313 x0 y0, bannerleft.bmp
gui, add, picture, w333 h313 x164 y0, bannerright.bmp
gui, font, s12 bold, Verdana
gui, add, text, w284 h59 x172 y12 vStartTitle backgroundtrans, Start Title
gui, font
gui, add, text, w284 h39 x172 y77 vStartSubtitle backgroundtrans, Start Subtitle
;---- Create controls used on the last tab (identical to first tab except for the parent tab and the title output variables)
gui, tab, %TabCount%
gui, add, picture, w164 h313 x0 y0, bannerleft.bmp
gui, add, picture, w333 h313 x164 y0, bannerright.bmp
gui, font, s12 bold, Verdana
gui, add, text, w284 h59 x172 y12 vFinishTitle backgroundtrans, Finish Title
gui, font
gui, add, text, w284 h39 x172 y77 vFinishSubtitle backgroundtrans, Finish Subtitle
;---- <START> Insert your own controls for each tab here
Gui, Tab, 1
Gui, Add, Text, x100 y100 w200 h150 gDoThis, Hello World
Gui, Tab, 2
Gui, Add, Button, x100 y100 w200 h150 gDoThis, Hello World
;---- <END> Insert your own controls for each tab here
gui, -SysMenu
gui, show, w497 h360 center, My Wizard
LoadTab(1)
return
;---- <START> Insert your own functions and subroutines for each tab here
DoThis:
MsgBox Hello
return
;---- <END> Insert your own functions and subroutines for each tab here
ButtonNext:
if ActiveTab >= %TabCount%
gosub Finish
else
ActiveTab++
LoadTab(ActiveTab)
return
ButtonBack:
ActiveTab--
LoadTab(ActiveTab)
return
LoadTab(x)
{
global TabCount, ActiveTab
if x <= 1
{
x = 1
ActiveTab = 1
guicontrol, disable, ButtonBack
guicontrol, text, ButtonNext, &Next >
GoToTab(x)
LoadText(x)
}
else if x >= %TabCount%
{
x = %TabCount%
ActiveTab = %TabCount%
guicontrol, enable, ButtonBack
guicontrol, text, ButtonNext, Finish
GoToTab(x)
LoadText(x)
}
else
{
guicontrol, enable, ButtonBack
guicontrol, text, ButtonNext, &Next >
GoToTab(x)
LoadText(x)
}
}
GoToTab(x)
{
global ActiveTab
guicontrol, choose, TabID, %x%
ActiveTab = %x%
}
LoadText(x)
{
Global
y := Tab%x%Title
z := Tab%x%Subtitle
guicontrol, text, BannerTitle, %y%
guicontrol, text, BannerSubtitle, %z%
guicontrol, text, StartTitle, %y%
guicontrol, text, StartSubtitle, %z%
guicontrol, text, FinishTitle, %y%
guicontrol, text, FinishSubtitle, %z%
}
Finish:
msgbox Yay!
ButtonCancel:
GuiClose:
exitapp |
|
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Tue May 25, 2010 8:47 pm Post subject: Wizard Images |
|
|
Ok so I went ahead and made images to know what it would look like. These aren't useful in my opinion (the coloring is just for ease of seeing where is where), but will allow to easy editing (size is already in place). I might suggest changing them to png or jpg, but if you do be sure to change them in the code as well. I have included below examples of what it looks like, and a link to download the code / images. Also if you want to use them just for background you can set the images as 1pixel x 1pixel and they will be stretched to fill the whole thing.
In some cases you may want to simply remove the banner right and banner left images from the code as that is space in the first and last screen that would be used up, or you can use it for background color... or simply make your whole statement in that image.
I would also like to point out that this is just "repair" work I am doing to the actual creators project, and if he is still around, I would want him recognized for the original work, so a big Thank You to "Novan Leon".
And a Link to Download the PACK:
Download WITH Text On Images
Download WITHOUT Text On Images |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Tue May 25, 2010 9:48 pm Post subject: |
|
|
you know what
I Like It!!!!!!!!!!!!!!!!!!!
it really is a very good starting point with general purpose use and editability _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
awannaknow
Joined: 14 Jun 2009 Posts: 324
|
Posted: Wed May 26, 2010 11:03 am Post subject: |
|
|
Hi computerspazzz,
Thanks for the detailed explanation, It'll help everyone (mainly new like me) to understand code.
What I meant when I posted Up was that I was interested by what original poster Novan Leon packed in the wizard.zip :
More precisely pictures and example, because the code is in the post already :
wizard_example.ahk - Run this and take a look at the code to see how it works
bannerarea.bmp
bannerleft.bmp - replace this with your own 165x314 design to customize your first and last wizard screens
bannerlogo.bmp - Replace this with your own 49x49 logo to customize your in-between/main wizard screens
bannerright.bmp
divider.bmp
I would like to see what he did with his example and the pictures are needed for it to work.
Also it is what I tried to first do when I discovered ahk, so I can use it to install printer in a sort of portable way with deepfreeze installed, when needed : How to select folder in tree in allinone installation soft ? |
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Fri May 28, 2010 9:42 am Post subject: Help with choosing a tab |
|
|
Yeah when i was trying to get it, his hosting was down/disabled. The pictures were not showing up, nor was the download link working... didnt know if it would be coming back or not.
On another note... ive created a tabbed interface, and have not been able to figure out how to show the interface preset to a specific tab. Depending on what calls that window with the tabs I would like to have it show the correct tab. Any thoughts?
(Side note, i tried dissecting the code from above to figure out how to do it without any luck.)
| Code: | ; This is what I have so far that works great.
Gui, Add, Tab, x10 y10 w300 h300 vTabbedWin, Tab1|Tab2|Tab3
Gui, Tab, 1
Gui, Add, Text,, Hello Tab 1
Gui, Tab, 2
Gui, Add, Text,, Hello Tab 2
Gui, Tab, 3
Gui, Add, Text,, Hello Tab 3
Gui, Show,, MyTabbedUi
;This part below doesn't work, despite my attempts at replicating.
If TabID = 3 ; We are running under the assumption that TabID is 3, which i verified.
guicontrol, choose, TabbedWin, 3
return |
If anyone has any ideas it would be appreciated, thanks.[/code] |
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Fri May 28, 2010 9:47 am Post subject: More Info |
|
|
Just wanted to give anyone who checks this out the basis of where I got my info:
GuiControl, Choose, ControlID, N: Sets the selection in a ListBox, DropDownList, ComboBox, or Tab control to be the Nth entry. N should be 1 for the first entry, 2 for the second, etc (if N is not an integer, the ChooseString method described below will be used instead). Unlike Control Choose, this sub-command will not trigger any g-label associated with the control unless N is preceded by a pipe character (even then, the g-label is triggered only when the new selection is different than the old one, at least for Tab controls). For example: GuiControl, Choose, MyListBox, |3.
which came from here: http://www.autohotkey.com/docs/commands/GuiControl.htm |
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Fri May 28, 2010 9:53 am Post subject: i feel sheepish |
|
|
Sorry for that... but I figured it out right after the post (again).
| Code: | | guicontrol, 8:choose, TabID, 3 |
The UI i was working on was: Gui, 8:Add....
seems to be working now. |
|
| Back to top |
|
 |
awannaknow
Joined: 14 Jun 2009 Posts: 324
|
Posted: Fri May 28, 2010 10:01 am Post subject: Re: Help with choosing a tab |
|
|
Novan Leon could maybe reupload it if he keeps it somewhere and know where to find it back
| computerspazzz wrote: | Yeah when i was trying to get it, his hosting was down/disabled. The pictures were not showing up, nor was the download link working... didnt know if it would be coming back or not.
|
Unfortunately it too complicated for me to be of any help here . . .
| computerspazzz wrote: | On another note... ive created a tabbed interface, and have not been able to figure out how to show the interface preset to a specific tab. Depending on what calls that window with the tabs I would like to have it show the correct tab. Any thoughts?
(Side note, i tried dissecting the code from above to figure out how to do it without any luck.)
If anyone has any ideas it would be appreciated, thanks. |
|
|
| Back to top |
|
 |
Novan Leon
Joined: 29 Apr 2009 Posts: 5
|
Posted: Fri May 28, 2010 4:44 pm Post subject: |
|
|
I've received several PM's stating that they're having difficult downloading the attached zip. I'm not experiencing any issues with this and the link should remain active for a long time (I'm paying them for the hosting), so please let me know if this remains a problem.
I should also be available for help if you need it. Just send me a PM and I'll respond as soon as I'm able. |
|
| Back to top |
|
 |
computerspazzz
Joined: 25 May 2010 Posts: 22
|
Posted: Thu Jun 03, 2010 3:36 am Post subject: Pop Up on A Certain Tab |
|
|
So I have a button on a gui, that opens another gui with tabs, and so when I wanted to have a certain tab open I have the button do:
| Code: |
TabID = 2 ; Or the number of the tab you want |
Then When the GUI creation is done, right after Gui, 2:Show I Put:
| Code: | If TabID != ; If tab is not empty
guicontrol, 2:choose, WindowTabs, %TabID% ; change tab to %TabID%
TabID = ; Set TabID to empty for future calls.
|
Referenced From:
http://www.autohotkey.com/docs/commands/GuiControl.htm |
|
| Back to top |
|
 |
guest3456 Guest
|
Posted: Tue Sep 14, 2010 3:42 pm Post subject: |
|
|
| thanks, gonna mess around with this |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|