AutoHotkey Community

It is currently May 26th, 2012, 10:17 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: October 23rd, 2009, 1:45 am 
I have a GUI that I've created, it has a serious of categories with check boxes.

What I wanted it to do, the user picks which categories they want to be added to the randomization, then they click start, and it will randomly select a link, from all the included categories.

Does that make sense? If not, ask for more detail.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 2:04 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
I commend you for your subject title, Very Good! :wink: :wink: :wink:

I suggest that your code collect a list of the suitable links, based on the selected catogories, count them, and then apply this command:
http://www.autohotkey.com/docs/commands/Random.htm

There may be many ways to collect the list, but further discussion probably should be based on you code.

Can you post your code with code tags please?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 2:53 am 
Leef_me wrote:
I commend you for your subject title, Very Good! :wink: :wink: :wink:
I don't understand what you mean by that.

Code:
Gui, Font, S34 CGreen, Papyrus
Gui, Add, Text, x3 y0 w310 h130 +Center, Random Link Generator
Gui, Font, S16 CGreen, Papyrus
Gui, Add, Text, x3 y140 w310 h80 +Center, Choose the lists of links you would like to add.
Gui, Font, S16 CGreen, Papyrus
Gui, Add, Checkbox, x56 y210 w190 h30 Checked, Blogs
Gui, Add, Checkbox, x56 y250 w180 h30 Checked, Game sites
Gui, Add, Checkbox, x56 y290 w140 h30 Checked, MMORPG's
Gui, Add, Checkbox, x56 y330 w160 h30 Checked, Pictures
Gui, Add, Button, x108 y370 w100 h30 , Choose!
Gui, Show, w319 h410, Test Gui
Return

GuiClose:
ExitApp


Is my GUI, I have added no code yet, as I want to think of a method before I start.

Example:
I want checkbox1 to contain the links: MyYearBook.com, Myspace.com, and Facebook.com

Checkbox2 to contain the links: Addictinggames.com, Miniclip.com, and Armorgames.com

Checkbox3 to contain the links: Worldofwarcraft.com, Ashenempires.com, Rappelz.gPotato.com

Checkbox4 to contain the links: Tinypic.com, Imageshack.us, Photobucket.com

Whenever the checkbox is checked, those links are added to the pile of links to randomize. When you click the button Choose! I want it to randomly select only ONE link out of the group of links I've selected.

I tried to set it to random a number between 1 and however many links there are and set each link to an individual number, but that means I would have to right a code for every possible outcome, which is very inconventient.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 6:42 am 
I've added a little code to my script. I've decided to go the route and hard code every possible outcome. This is what I have.

Code:
Gui, Font, S34 CGreen, Papyrus
Gui, Add, Text, x3 y0 w310 h130 +Center, Random Link Generator
Gui, Font, S16 CGreen, Papyrus
Gui, Add, Text, x3 y140 w310 h80 +Center, Choose the lists of links you would like to add.
Gui, Font, S16 CGreen, Papyrus
Gui, Add, Checkbox, x56 y210 w190 h30 Checked vblog, Blogs
Gui, Add, Checkbox, x56 y250 w180 h30 Checked vgame, Game sites
Gui, Add, Checkbox, x56 y290 w140 h30 Checked vmmo, MMORPG's
Gui, Add, Checkbox, x56 y330 w160 h30 Checked vpic, Pictures
Gui, Add, Button, x108 y370 w100 h30 , Choose
Gui, Show, w319 h410, Test Gui
Return

buttonchoose:
if(blog = 1 & game = 0 & mmo = 0 & pic = 0)

random, num, 1, 3

1 := "http://myspace.com"
2 := "http://facebook.com"
3 := "http://myyearbook.com"

msgbox, %num%
run, %num%
Return

GuiClose:
ExitApp


The messagebox keeps returning the number. I thought that it'd set the number to a website... Then I could just tell it to run that number, but it won't work that way. :(


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 6:59 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Needs help wrote:
Leef_me wrote:
I commend you for your subject title, Very Good! :wink: :wink: :wink:
I don't understand what you mean by that.


Some of the thread titles here are poorly thought out. Others well thought and others are mid-way between. Sorry to digress. :oops:

Maybe you'll like this better:



Code:
Gui, Font, S34 CGreen, Papyrus
Gui, Add, Text, x3 y0 w310 h130 +Center, Random Link Generator
Gui, Font, S16 CGreen, Papyrus
Gui, Add, Text, x3 y140 w310 h80 +Center, Choose the lists of links you would like to add.
Gui, Font, S16 CGreen, Papyrus

Gui, Add, Checkbox, x56 y210 w190 h30 vcbox1 Checked, Blogs
Gui, Add, Checkbox, x56 y250 w180 h30 vcbox2 Checked, Game sites
Gui, Add, Checkbox, x56 y290  h30 vcbox3 Checked, MMORPG's
Gui, Add, Checkbox, x56 y330 w160 h30 vcbox4 Checked, Pictures


Gui, Add, Button, x108 y370 w100 h30 vchs, Choose
Gui, Show, w319 h410, Test Gui

return

buttonchoose:

;msgbox
gui, submit, nohide

full=   ; clear the list to gather

if cbox1
   full:=       "MyYearBook.com,Myspace.com,Facebook.com,"
if cbox2
   full:=full . "Addictinggames.com,Miniclip.com,Armorgames.com,"
if cbox3
   full:=full . "Worldofwarcraft.com,Ashenempires.com,Rappelz.gPotato.com,"
if cbox4
   full:=full . "Tinypic.com,Imageshack.us,Photobucket.com,"

   full:=full . "empty" ; always one extra entry because of the trailing comma

;msgbox %full% ; the full list

Loop, parse, full, `,
{
;    MsgBox, website number %A_Index% is %A_LoopField%
    b_index:=a_index-1
}
msgbox %b_index%

Random, choice , 1, %b_index%

; msgbox %choice% ; the resulting choice number

Loop, parse, full, `,
{
;    MsgBox, website number %A_Index% is %A_LoopField%
    if (choice=a_index)
    {
   result:=A_LoopField ; the resulting website
   break
    }
}

msgbox %result%

Return

esc::
GuiClose:
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 7:42 am 
Wow, thanks a bunch. That's exactly what I was wanting. :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 8:03 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Needs help wrote:
Wow, thanks a bunch. That's exactly what I was wanting. :)
I am pleased that I could help.
Did you notice that I changed this line (because of line wrap)
Code:
Gui, Add, Checkbox, x56 y290  h30 vcbox3 Checked, MMORPG's


Also, all the checkboxes need variable names to retrieve their values.

BTW, I like that font Papyrus, that was of benefit to me. :!:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 5:16 pm 
To be completely honest, I changed the GUI up a bit again.

The Papyrus font is one of my favorite fonts to use on GUI's. :) Glad I could show you it.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, hyper_, JSLover, Leef_me, patgenn123, rbrtryn, XstatyK and 70 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group