AutoHotkey Community

It is currently May 27th, 2012, 8:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: January 30th, 2012, 9:23 pm 
Offline

Joined: November 9th, 2011, 7:45 am
Posts: 127
Location: Altrincham
Hi guys

I have read all the documentation on radio buttons and im stuck, so I have made this simple script, to try get my head round it.

I need help putting it together, could someone please help?

Code:
Gui, Add, Text, x6 y7 w360 h30 +Center, If you 10 cows all had 10 black spot's`, how many spots are there in total?
Gui, Add, Radio, x126 y47 w100 h30 , 100 spot's
Gui, Add, Radio, x126 y87 w100 h30 , 200 spot's
Gui, Add, Button, x66 y127 w240 h60 ,Answer.
Gui, Show, x375 y245 h197 w377, New GUI Window
Return

ButtonAnswer:
MsgBox Yes, you have the correct answer

MsgBox Sorry, you need to try again

GuiClose:
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 9:34 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
You have no logic telling the computer (AHK) where and what to do.
But you tried :D
Look at the comments and colors I highlighted.

Code:
Gui, Add, Text, x6 y7 w360 h30 +Center, If you 10 cows all had 10 black spot's`, how many spots are there in total?
Gui, Add, Radio,  x126 y47  w100 h30 vcheese1, 100 spots
Gui, Add, Radio,  x126 y87  w100 h30 vcheese2, 200 spots
Gui, Add, Button, x66  y127 w240 h60 gdonkey,Answer.
Gui, Show, x375 y245 h197 w377, New GUI Window
Return

donkey:
  gui, submit, NoHide                        ; gather all the data from the GUI
                                             ;
  if (cheese1==0 && cheese2==0)              ; check if BOTH radios are unchecked
  {                                          ; ...
    Msgbox, Please choose an answer.         ; ...
    return                                   ; stop the code from going further.
  }                                          ;
                                             ;
  if (cheese1==1)                            ; if the first radio is checked ...
    MsgBox Yes, you have the correct answer  ; show the YES message
                                             ;
  if (cheese2==1)                            ; if the second is checked ...
    MsgBox Sorry, you need to try again      ; show the SORRY message.
   
Return

GuiClose:
ExitApp

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 9:35 pm 
Offline
User avatar

Joined: April 4th, 2009, 8:19 pm
Posts: 1143
Location: Croatia
Code:
Gui, Add, Text, x6 y7 w360 h30 +Center, If you 10 cows all had 10 black spot's`, how many spots are there in total?
Gui, Add, Radio, x126 y47 w100 h30 vAnswer1, 100 spot's
Gui, Add, Radio, x126 y87 w100 h30 vAnswer2, 200 spot's
Gui, Add, Button, x66 y127 w240 h60 ,Answer
Gui, Show, x375 y245 h197 w377, New GUI Window
Return

ButtonAnswer:
Gui, Submit, NoHide
Gui, +OwnDialogs
if Answer1
   MsgBox Yes, you have the correct answer
else if Answer2
   MsgBox Sorry, you need to try again
return

GuiClose:
ExitApp
EDIT: tidbit was faster :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 9:37 pm 
Offline

Joined: November 9th, 2011, 7:45 am
Posts: 127
Location: Altrincham
Thanks guys, great stuff, love the Donkey and Cheese...hahaha

Thanks again.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 12:47 pm 
Offline

Joined: November 9th, 2011, 7:45 am
Posts: 127
Location: Altrincham
Hi guys

The code above is great and works well BUT

Ive created this code below as a test, as i am a little stuck on the places remarked in the code.

Code:
Gui, Add, Text, x12 y10 w340 h40 +Center, RADIO BUTTON TEST
Gui, Add, Edit, x62 y60 w290 h20 R1 vMessage,
Gui, Add, Radio, x112 y80 w90 h20 vAnswer1, 10 Seconds
Gui, Add, Radio, x112 y100 w90 h20 vAnswer2, 15 Seconds
Gui, Add, Radio, x112 y120 w90 h20 vAnswer3, 20 Seconds
Gui, Add, Radio, x112 y140 w90 h20 vAnswer4, 25 Seconds
Gui, Add, Text, x12 y60 w50 h20 , Message:
Gui, Add, Button, x42 y170 w100 h30 , Exit
Gui, Add, Button, x202 y170 w100 h30 gCreate,Create Message
Gui, Show, w366 h229, Untitled GUI
return

T1 = 10
T2 = 15
T3 = 20
T4 = 25

T1 := T1 * 6000
T2 := T2 * 6000
T3 := T3 * 6000
T4 := T4 * 6000

Create:
gui, submit, NoHide

if (Answer1==0 && Answer2==0 && Answer3==0 && Answer4==0)
Loop
  {                                         
    Msgbox, Please choose a time.         
    return                                   
  }     

if (Answer1==0)
   ; THIS IS WHERE I AM STUCK!!!!!!!!!!!!!!!!
if (Answer1==1)
Loop
{
   sleep, %T1%
   MsgBox You selected 10 seconds
   ExitApp
}

if (Answer2==0)
   ; THIS IS WHERE I AM STUCK!!!!!!!!!!!!!!!!
if (Answer2==1)
Loop
{
   sleep, %T2%
   MsgBox You selected 15 seconds
   ExitApp
}

if (Answer3==0)
   ; THIS IS WHERE I AM STUCK!!!!!!!!!!!!!!!!
if (Answer3==1)
Loop
{
   sleep, %T3%
   MsgBox You selected 20 seconds
   ExitApp
}

if (Answer4==0)
   ; THIS IS WHERE I AM STUCK!!!!!!!!!!!!!!!!
if (Answer4==1)
Loop
{
   sleep, %T4%
   MsgBox You selected 25 seconds
   ExitApp
}

ButtonExit:
ExitApp

GuiClose:
ExitApp



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 1:10 pm 
Offline

Joined: July 10th, 2008, 8:49 am
Posts: 1865
Location: Brussels, Belgium
Really better :

Code:
T1 = 10
T2 = 15
T3 = 20
T4 = 25

T1 := T1 * 1000
T2 := T2 * 1000
T3 := T3 * 1000
T4 := T4 * 1000

Gui, Add, Text, x12 y10 w340 h40 +Center, RADIO BUTTON TEST
Gui, Add, Edit, x62 y60 w290 h20 R1 vMessage,
Gui, Add, Radio, x112 y80 w90 h20 vAnswer1, 10 Seconds
Gui, Add, Radio, x112 y100 w90 h20 vAnswer2, 15 Seconds
Gui, Add, Radio, x112 y120 w90 h20 vAnswer3, 20 Seconds
Gui, Add, Radio, x112 y140 w90 h20 vAnswer4, 25 Seconds
Gui, Add, Text, x12 y60 w50 h20 , Message:
Gui, Add, Button, x42 y170 w100 h30 , Exit
Gui, Add, Button, x202 y170 w100 h30 gCreate,Create Message
Gui, Show, w366 h229, Untitled GUI

Return

Create:
   Gui Submit, NoHide
   If (Answer1)
   {
      sleep, %T1%
      MsgBox You selected 10 seconds
      ExitApp
   } Else If (Answer2)
   {
      sleep, %T2%
      MsgBox You selected 15 seconds
      ExitApp
   } Else If (Answer3)
   {
      sleep, %T3%
      MsgBox You selected 20 seconds
      ExitApp
   } Else If (Answer4)
   {
      sleep, %T4%
      MsgBox You selected 25 seconds
      ExitApp
   } Else
   {
      Msgbox, Please choose a time.
      Return
   }
Return

ButtonExit:
ExitApp

GuiClose:
ExitApp


:)


Last edited by CodeKiller on February 7th, 2012, 1:15 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 1:12 pm 
Offline

Joined: November 9th, 2011, 7:45 am
Posts: 127
Location: Altrincham
Ah thank you Code Killer

Brilliant.

Thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 1:15 pm 
Offline

Joined: July 10th, 2008, 8:49 am
Posts: 1865
Location: Brussels, Belgium
I have made some adjustment, get the last version ;-)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 1:20 pm 
Offline

Joined: November 9th, 2011, 7:45 am
Posts: 127
Location: Altrincham
CodeKiller wrote:
I have made some adjustment, get the last version ;-)


Again, thats great, thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2012, 11:51 am 
Offline

Joined: November 9th, 2011, 7:45 am
Posts: 127
Location: Altrincham
Hi guys

Im still having issues with the radio buttons, the above code (which was a good insight on how gLabels and radios work) didnt work for my script.

So Ive cut this code out of my script and posted here.

the issue im getting is it misses out %Time2% and just carries on into code straight after the message box?

Am I missing a command to return it back to the code?

I also know it is incomplete code, thought if I got the sleep, %Time2% sorted out i would carry on coding.

Code:
Time1 = 10
Time2 = 12
Time3 = 14
Time4 = 16
Time5 = 18
Time6 = 20
Time7 = 22
Time8 = 24
Time9 = 26

Time1 := Time1 * 1000
Time2 := Time2 * 1000
Time3 := Time3 * 1000
Time4 := Time4 * 1000
Time5 := Time5 * 1000
Time6 := Time6 * 1000
Time7 := Time7 * 1000
Time8 := Time8 * 1000
Time9 := Time9 * 1000

Gui, Add, Edit, x22 y20 w50 h20 R1 vTime1, seconds
Gui, Add, Radio, x22 y40 w50 h20 vCH1PRO1, Pro 1
Gui, Add, Radio, x22 y60 w50 h20 vCH1PRO2, Pro 2
Gui, Add, Radio, x22 y80 w50 h20 vCH1PRO3, Pro 3
Gui, Add, Radio, x22 y100 w50 h20 vCH1PRO4, Pro 4
Gui, Add, Edit, x82 y20 w50 h20 R1 vTime2, seconds
Gui, Add, Radio, x82 y40 w50 h20 vCH2PRO1, Pro 1
Gui, Add, Radio, x82 y60 w50 h20 vCH2PRO2, Pro 2
Gui, Add, Radio, x82 y80 w50 h20 vCH2PRO3, Pro 3
Gui, Add, Radio, x82 y100 w50 h20 vCH2PRO4, Pro 4
Gui, Add, Edit, x142 y20 w50 h20 R1 vTime3, seconds
Gui, Add, Radio, x142 y40 w50 h20 vCH3PRO1, Pro 1
Gui, Add, Radio, x142 y60 w50 h20 vCH3PRO2, Pro 2
Gui, Add, Radio, x142 y80 w50 h20 vCH3PRO3, Pro 3
Gui, Add, Radio, x142 y100 w50 h20 vCH3PRO4, Pro 4
Gui, Add, Edit, x202 y20 w50 h20 R1 vTime4, seconds
Gui, Add, Radio, x202 y40 w50 h20 vCH4PRO1, Pro 1
Gui, Add, Radio, x202 y60 w50 h20 vCH4PRO2, Pro 2
Gui, Add, Radio, x202 y80 w50 h20 vCH4PRO3, Pro 3
Gui, Add, Radio, x202 y100 w50 h20 vCH4PRO4, Pro 4
Gui, Add, Edit, x262 y20 w50 h20 R1 vTime5, seconds
Gui, Add, Radio, x262 y40 w50 h20 vCH5PRO1, Pro 1
Gui, Add, Radio, x262 y60 w50 h20 vCH5PRO2, Pro 2
Gui, Add, Radio, x262 y80 w50 h20 vCH5PRO3, Pro 3
Gui, Add, Radio, x262 y100 w50 h20 vCH5PRO4, Pro 4
Gui, Add, Edit, x322 y20 w50 h20 R1 vTime6, seconds
Gui, Add, Radio, x322 y40 w50 h20 vCH6PRO1, Pro 1
Gui, Add, Radio, x322 y60 w50 h20 vCH6PRO2, Pro 2
Gui, Add, Radio, x322 y80 w50 h20 vCH6PRO3, Pro 3
Gui, Add, Radio, x322 y100 w50 h20 vCH6PRO4, Pro 4
Gui, Add, Edit, x382 y20 w50 h20 R1 vTime7, seconds
Gui, Add, Radio, x382 y40 w50 h20 vCH7PRO1, Pro 1
Gui, Add, Radio, x382 y60 w50 h20 vCH7PRO2, Pro 2
Gui, Add, Radio, x382 y80 w50 h20 vCH7PRO3, Pro 3
Gui, Add, Radio, x382 y100 w50 h20 vCH7PRO4, Pro 4
Gui, Add, Edit, x442 y20 w50 h20 R1 vTime8, seconds
Gui, Add, Radio, x442 y40 w50 h20 vCH8PRO1, Pro 1
Gui, Add, Radio, x442 y60 w50 h20 vCH8PRO2, Pro 2
Gui, Add, Radio, x442 y80 w50 h20 vCH8PRO3, Pro 3
Gui, Add, Radio, x442 y100 w50 h20 vCH8PRO4, Pro 4
Gui, Add, Edit, x502 y20 w50 h20 R1 vTime9, seconds
Gui, Add, Radio, x502 y40 w50 h20 vCH9PRO1, Pro 1
Gui, Add, Radio, x502 y60 w50 h20 vCH9PRO2, Pro 2
Gui, Add, Radio, x502 y80 w50 h20 vCH9PRO3, Pro 3
Gui, Add, Radio, x502 y100 w50 h20 vCH9PRO4, Pro 4
Gui, Add, Text, x22 y130 w530 h20 ,
>------>------>------>------>------>------>------>------>            TIME LINE             >------>------>------>------>------>------>------>------>
Gui, Add, Button, x122 y160 w100 h20 , Exit
Gui, Add, Button, x342 y160 w100 h20 gStart, Start Test
Gui, Show, w582 h195, Untitled GUI
return

Start:

Sleep, %Time1%
Gui Submit, NoHide
If (CH1PRO1==1)
{
   MsgBox Radio 1 was selected after %Time1% seconds
}Else if (CH1PRO2==1)
{
   MsgBox Radio 2 was selected after %Time1% seconds
}Else if (CH1PRO3==1)
{
   MsgBox Radio 3 was selected after %Time1% seconds
}Else if (CH1PRO4==1)
{
   MsgBox Radio 4 was selected after %Time1% seconds
}
   

Sleep, %Time2%
Gui Submit, NoHide
If (CH2PRO1==1)
{
   MsgBox Radio 1 was selected after %Time2% seconds
}Else if (CH2PRO2==1)
{
   MsgBox Radio 2 was selected after %Time2% seconds
}Else if (CH2PRO3==1)
{
   MsgBox Radio 3 was selected after %Time2% seconds
}Else if (CH2PRO4==1)
{
   MsgBox Radio 4 was selected after %Time2% seconds
}
return



ButtonExit:
ExitApp

GuiClose:
ExitApp


Thanks again guys in advance.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google [Bot], hyper_, immunity, migz99, sjc1000 and 76 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