AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

logical problem with a menu

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
franky
Guest





PostPosted: Sat Sep 08, 2007 7:20 am    Post subject: logical problem with a menu Reply with quote

Hello everybody.
I would like to make a menu with a listbox.
But when i choose a choice of my menu, the script always take the first choice, why ?
This is my script here :
Code:

begin:
Gui, Destroy
Gui, add, listbox, vChoice, 1. first choice|2. second choice|3. third choice
Gui, Add, Button, Default, OK
Gui, show,, menu with a listbox
Return
ButtonOK:
Gui, Submit
Gui, Destroy
If Choice := 1
Gui, Add, Text,, the first choice is selected
If Choice := 2
Gui, Add, Text, the second choice is selected
If Choice := 3
Gui, Add, Text, the third choice is selected
Gui, Add, Text,, do you want to redo from start, yes or no,
Gui, Add, Text,, you have to click on the Yes Button or No button or by pressing the Y key for yes or N key for no
Gui, Add, Button, yes, &yes
Gui, Add, Button, no, &no
Gui, Show,, last choice selected
Return
Buttonyes:
Goto begin
Return
Buttonno:
ExitApp
Return

[Moderator's note - added code tags]
Back to top
Freighter



Joined: 07 Sep 2006
Posts: 64

PostPosted: Sat Sep 08, 2007 8:17 am    Post subject: Reply with quote

lets see
you need AltSubmit in the listbox options so the variable will be the row # instead of the text
Code:
Gui, add, listbox, vChoice AltSubmit, 1. first choice|2. second choice|3. third choice

the if statements dont work with the := they need normal =

Code:
If Choice = 1
you forgot a comma in the 2nd and 3rd gui, add 's
Gui, Add, Text, , the second choice is selected
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 846
Location: London, UK

PostPosted: Sat Sep 08, 2007 8:20 am    Post subject: Reply with quote

Please place all code in code boxes
Code:
 [code][/code]


Code:
 Gui, Destroy
Gui, add, listbox, vChoice altsubmit , 1. first choice|2. second choice|3. third choice
Gui, Add, Button, Default, OK
Gui, show,, menu with a listbox
Return
ButtonOK:
Gui, Submit
Gui, Destroy
If Choice = 1
Gui, Add, Text,, the first choice is selected
If Choice = 2
Gui, Add, Text, the second choice is selected
If Choice = 3
Gui, Add, Text, the third choice is selected
Gui, Add, Text,, do you want to redo from start, yes or no,
Gui, Add, Text,, you have to click on the Yes Button or No button or by pressing the Y key for yes or N key for no
Gui, Add, Button, yes, &yes
Gui, Add, Button, no, &no
Gui, Show,, last choice selected
Return
Buttonyes:
Goto begin
Return
Buttonno:
ExitApp
Return

try that I removed the : from the if statements. Also added the altsubmit property to the listbox.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
franky
Guest





PostPosted: Sat Sep 08, 2007 5:55 pm    Post subject: script to make a menu with a listbox who works Reply with quote

Thank you.
Because of you i have a script who works !
I didn't know the AltSubmit parameter.
Sorry but i don't know the HTML CODE to make a link to copy to the

clipboard
So i write here the correct script and i appended something :
begin:
Code:
Gui, Destroy
Gui, add, listbox, vChoice AltSubmit, 1. first choice|2. second

choice|3. third choice
Gui, Add, Text,, you can press a number on the keyboard
Gui, Add, Button, Default, OK
Gui, show,, menu with a listbox
Return
ButtonOK:
Gui, Submit
Gui, Destroy
If Choice = 1
Gui, Add, Text,, the first choice is selected
If Choice = 2
Gui, Add, Text,, the second choice is selected
If Choice = 3
Gui, Add, Text,, the third choice is selected
if (Choice <1) or (Choice > 3)
Gui, Add, Text,, you press a wrong number on the keyboard
Gui, Add, Text,, do you want to redo from start, yes or no,
Gui, Add, Text,, you have to click on the Yes Button or No button or by

pressing the Y key for yes or N key for no
Gui, Add, Button, yes, &yes
Gui, Add, Button, no, &no
Gui, Show,, last choice selected
Return
Buttonyes:
Goto begin
Return
Buttonno:
ExitApp
Return
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 5880

PostPosted: Sat Sep 08, 2007 6:03 pm    Post subject: Reply with quote

franky, please use code tags in future. Smile
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Sun Sep 09, 2007 5:18 am    Post subject: Reply with quote

franky, they are BBCode code tags, not HTML.

they are made like this

Code:

[code]
;put your code here
[/code]

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group