 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
EdScriptNewbie
Joined: 20 Jan 2007 Posts: 31
|
Posted: Wed Jan 16, 2008 1:31 am Post subject: trying to create a simple pop-up box with check box items |
|
|
I want to pop up a dialog box and make multiple choices from among some check-box items.
The context will decide how many check box items the dialog box will offer, and which, if any, of the boxes will default as having been checked.
I'd like to underline a letter in each of the choice descriptions so the user can check/uncheck boxes from the keyboard with an alt keystroke ("This one").
I've played around with some of the GUI examples but i can't seem to extrapolate anything even close to this from them. Can you help me?
THANKS! _________________ ...Ed |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Wed Jan 16, 2008 2:00 am Post subject: |
|
|
| Where's your code? |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1375
|
Posted: Wed Jan 16, 2008 2:05 am Post subject: |
|
|
to look like this?
| Code: | #SingleInstance, Force
Options = Radio1,Radio2,Radio3
StringSplit, Options, Options, `,
Loop, 3
Gui, 1: Add, Radio, x80 y+10 w130 vRadioGroup%A_Index% r1 -Wrap -Multi, % Options%A_Index%
Gui, 1: Add, Button, x80 y+20 w75 gOK, &OK
Gui, 1: Show, AutoSize
Return
OK:
Gui, 1: Submit
Return |
|
|
| Back to top |
|
 |
EdScriptNewbie
Joined: 20 Jan 2007 Posts: 31
|
Posted: Wed Jan 16, 2008 6:52 pm Post subject: re: to look like this? |
|
|
Sort of, but not radio buttons, check boxes; i'm not sure how much difference that makes in how this works
I don't really understand how "GUI" works, and the documentation assumes knowledge I don't have (I never took any kind of programming 101). I learn best by looking at examples and changing things to see what happens. I wish there were many more examples like the one you provided; even then, GUI seems hard
In this case, what do these lines do?
Options = Radio1,Radio2,Radio3
StringSplit, Options, Options, `,
How does the ` in the StringSplit act as a delimiter? I don't see what in the code would cause a ` to appear in the Options string.
What if there are, say, five options in one context, and then three options in another? Would this work?
Thanks, and sorry to be so behind the curve on this. _________________ ...Ed |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1375
|
Posted: Wed Jan 16, 2008 7:35 pm Post subject: |
|
|
Ah dont worry about it. I remember when I was first learning ahk. It wasnt long ago actually, and many things seemed so hard, but i laugh if i ever look at my old posts now.
I could write you a sample using checkboxes rather than radio, but it might be a little hard for you to understand and implement.
The gist of gui is....
Write the word Gui and then you can name the gui you want to add a control to by using:
then put a comma and name the name of the control you wish to add. ie
| Code: | | Gui, 2: Add, Button |
next comes the options section:
| Code: | | Gui, 2: Add, Button, x10 y10 w75 gGo |
that handles the positioning of the control and you can have g and v "labels". By putting a g in the options followed by a word, it will automatically run a sub routine for this instance when the button is pressed. A subroutine like:
| Code: | Go:
MsgBox, Hello
Return |
There will be 1 more option for a control, and in the case of a button is the text you want on the button:
| Code: | | Gui, 2: Add, Button, x10 y10 w75 gGo, Go |
A v "label" is used the same as g, in that you just type v and then the name, but it assigns the variable you type to that control. This is so that when you submit a gui you can have all the values of the controls sent somewhere, and they are sent to their associated variables.
At the end to show a gui, you use:
to submit all the values of a gui:
| Code: | | Gui, 2: Submit[, NoHide] |
The Nohide is optional and tells the gui whther to disappear or not.
Destroy a gui and not submit its values:
| Quote: | In this case, what do these lines do?
Options = Radio1,Radio2,Radio3
StringSplit, Options, Options, `, |
Using a stringsplit is a nice way to shorten code.
So rather than writing:
| Code: | Options1 := "Radio1"
Options2 := "Radio2"
Options3 := "Radio3"
... |
you may put all the values you wish to assign in a list:
| Code: | | Options = Radio1,Radio2,Radio3 |
with a deliminator seperating them (in this case a comma)
Now when you stringsplit:
| Code: | | StringSplit, Options, Options, `, |
it splits Options up using the delimiator (a comma needs a ` preceding it as this means "take a literal comma" as you have seen commas are used to separate options, and you dont want it to think this is a new option after the comma)
So the stringsplit will put Radio1 into Options1 and Radio2 into Options2 and so on..... Options0 will contain the number of items in the array after the stringsplit......
Huh........I need a break  |
|
| Back to top |
|
 |
EdScriptNewbie
Joined: 20 Jan 2007 Posts: 31
|
Posted: Wed Jan 16, 2008 10:01 pm Post subject: Wow a GUI tutorial! |
|
|
Thanks, tic, I can't say how grateful I am for your generous and clear reply. I actually understand what you wrote, and have a good idea what to try first.
What's the reason for the 2 after some looking i found that the docs mention it under "creating multiple gui windows" but it's not clear to me here. THANKS AGAIN. _________________ ...Ed |
|
| Back to top |
|
 |
EdScriptNewbie
Joined: 20 Jan 2007 Posts: 31
|
Posted: Wed Jan 16, 2008 10:03 pm Post subject: |
|
|
Oops, that was "2:" not "2 confused smiley" _________________ ...Ed |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1375
|
Posted: Wed Jan 16, 2008 10:26 pm Post subject: |
|
|
i wrote the 2 to demonstrate how to create a second gui. by default it is 1 and so can be ommited:
| Code: |
Gui, Add, Button, x10 y10 gGo, Go |
is the same as
| Code: |
Gui, 1: Add, Button, x10 y10 gGo, Go |
and then if you want a new gui, for example the next screen in an installer, then you would create gui 2 with a whole set of new controls added to it. |
|
| Back to top |
|
 |
EdScriptNewbie
Joined: 20 Jan 2007 Posts: 31
|
Posted: Wed Jan 16, 2008 10:53 pm Post subject: |
|
|
Thanks, that makes sense. I saw a program on this board called SmartGUI by Rajat. I couldn't make heads or tails of it, but now with your explanation I might be able to figure it out. Would you recommend using it? Thanks again! _________________ ...Ed |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1375
|
Posted: Thu Jan 17, 2008 4:13 am Post subject: |
|
|
| I think lil builder is better than smartgui creator, however (and not to put anyone down that worked on either project) i think it is infinitely preferable to create a gui by just typing the code for it. it will obviously take longer to learn, but will be a very useful skill to have and will also help you problem solve in the future if youre serious about learning ahk, and there are so many optimisations and "tricks" that couldnt possibly be built into either program. |
|
| Back to top |
|
 |
EdScriptNewbie
Joined: 20 Jan 2007 Posts: 31
|
Posted: Thu Jan 17, 2008 7:10 am Post subject: |
|
|
Stands to reason. Thanks, I'll keep working at it, although I just got news of a new consulting gig with an immediate start, so my gui will be a more part time effort than I thought for a few weeks. THanks again!. ...Ed _________________ ...Ed |
|
| 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
|