Info Posted August 20, 2007 Share Posted August 20, 2007 (edited) #include <GuiConstants.au3> GuiCreate("MyGUI", 412, 311,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List_1 = GuiCtrlCreateList("My Coputer", 10, 10, 120, 292) GUICtrlSetData ( $List_1, "List2|List3|List4|List5") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd ExitThis is my script.Now I understand that GUICtrlSetData gets me more lines in the list.But I don't know how to do that if I hit List2 /3 /4 /5, (the lists of the GUICtrlSetData) then it opens something like MsgBox?I mean like this:Case $msg = $List2 MsgBox (0, "You hit" "You hit Line2")Edit:Auto3Lib = found nothing. =/UDF = I don't know where to go...Please stop being mad on me or something...I just got a muse to create a good program.Look what I want to do:This is my program:So I want that if I hit List 2/3/4/5... It will show me something in the right side of the program.Like this:And I don't want a TreeView instead of that List, So please, tell me what I need to do to make this. Edited August 20, 2007 by Info Link to comment Share on other sites More sharing options...
Zedna Posted August 20, 2007 Share Posted August 20, 2007 Case $msg = $List_1 MsgBox (0, "You hit" "You hit " & GUICtrlRead($List_1) ) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Info Posted August 20, 2007 Author Share Posted August 20, 2007 You're giving me a script without any explainations. How can I understand something of it? And actually, I dont want my script to be like if I hit a line it will MsgBox, I want my script to be like if I hit a line it will show something in the right side of the GUI... Please explain me what you just posted... Link to comment Share on other sites More sharing options...
Zedna Posted August 20, 2007 Share Posted August 20, 2007 You're giving me a script without any explainations.How can I understand something of it?And actually, I dont want my script to be like if I hit a line it will MsgBox,I want my script to be like if I hit a line it will show something in the right side of the GUI...Please explain me what you just posted...We are slave here just for you?Look into Autoit helpfile as I did! Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Info Posted August 20, 2007 Author Share Posted August 20, 2007 I did look in the HelpFile, but they didn't show how to make another line in the list, and 'Case' it... Link to comment Share on other sites More sharing options...
Zedna Posted August 20, 2007 Share Posted August 20, 2007 Look also on UDF section in helpfile at GuiList functions.If you need more examples, search forum or look at Auto3Lib Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Info Posted August 20, 2007 Author Share Posted August 20, 2007 Can't find =/ Link to comment Share on other sites More sharing options...
Zedna Posted August 20, 2007 Share Posted August 20, 2007 (edited) Can't find =/What?UDF = User Defined Function Below is a list of the user defined functions for catagory: GuiList ManagementForum Search is in my signatureAuto3Lib Edited August 20, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Info Posted August 20, 2007 Author Share Posted August 20, 2007 (edited) Auto3Lib = found nothing. =/UDF = I don't know where to go...Please stop being mad on me or something...I just got a muse to create a good program.Look what I want to do:This is my program:So I want that if I hit List 2/3/4/5... It will show me something in the right side of the program.Like this:And I don't want a TreeView instead of that List, So please, tell me what I need to do to make this. Edited August 20, 2007 by Info Link to comment Share on other sites More sharing options...
smashly Posted August 21, 2007 Share Posted August 21, 2007 Hi,Zedna has given more then enough of a clue..But being spoon fed is so much easier..bah#include <GuiConstants.au3> GuiCreate("MyGUI", 412, 311,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List_1 = GuiCtrlCreateList("", 10, 10, 120, 292) $Label_1 = GUICtrlCreateLabel("", 140, 10, 260, 292) ;Create a label to put the data in when $List_1 is clicked GUICtrlSetData ( $List_1, "List2|List3|List4|List5") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $List_1 ; If the $List_1 is clicked then do some action.. ; To find out which item was clicked use GUICtrlRead($List_1) $ReadTheSelectedListItem = GUICtrlRead($List_1) ; Set the label with the data read from $List_1 when it was clicked GUICtrlSetData($Label_1, "You have hit " & $ReadTheSelectedListItem & @LF & _ "Read the help file to get a better understanding" & @LF & _ "Others have likely been where your at now so..." & @LF & _ "Search the forum for those questions already asked..." & @LF & _ "Read other peoples code that's posted in the forum" & @LF & _ "Also try experimenting..." & @LF & _ "No one wants to spoon feed answers that can be found easily.") EndSelect WEnd ExitCheers Link to comment Share on other sites More sharing options...
Info Posted August 21, 2007 Author Share Posted August 21, 2007 Thanks, but I still don't understand how I target many commands to each line of the List... Link to comment Share on other sites More sharing options...
smashly Posted August 21, 2007 Share Posted August 21, 2007 Ok, here's another example , click a list item and it does the function associated with it.. expandcollapse popup#include <GuiConstants.au3> $Gui = GuiCreate("MyGUI", 412, 311,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List_1 = GuiCtrlCreateList("", 10, 10, 120, 292, $LBS_NOTIFY) $Label_1 = GUICtrlCreateLabel("Click list item to do the action", 140, 10, 260, 292) GUICtrlSetData ( $List_1, "Play Tada Sound|Open Notepad|Empty Recycle Bin|Maximize MyGUI|Exit MyGUI") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $List_1 ; If the $List_1 is clicked then do some action.. ; To find out which item was clicked use GUICtrlRead($List_1) $ReadTheSelectedListItem = GUICtrlRead($List_1) ; Set the label with the data read from $List_1 when it was clicked GUICtrlSetData($Label_1, "Last clicked item: " & "'" & $ReadTheSelectedListItem & "'") ; If Switch Case is met then do that function/command Switch $ReadTheSelectedListItem Case "Open Notepad" ;;; Do stuff ShellExecute("notepad.exe") Case "Play Tada Sound" ;;; Do stuff SoundPlay(@WindowsDir & "\media\tada.wav",1) Case "Empty Recycle Bin" ;;; Do stuff FileRecycleEmpty() Case "Maximize MyGUI" ;;; Do stuff GUISetState(@SW_MAXIMIZE, $Gui) Case "Exit MyGUI" ;;; Do stuff ExitLoop EndSwitch EndSelect WEnd Exit There are many ways to to the same thing, as Zedna pointed out you could also use some of the functions in the UDF section in the Help File to do things different ways to fit your needs. Experiment and you'll soon enough start to understand it a bit better. Cheers Link to comment Share on other sites More sharing options...
Info Posted August 21, 2007 Author Share Posted August 21, 2007 (edited) THANK YOU ALL!!! really helped me Edit: Little problem: expandcollapse popupinclude <GuiConstants.au3> $Gui = GuiCreate("MyGUI", 412, 311,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List_1 = GuiCtrlCreateList("", 10, 10, 120, 292, $LBS_NOTIFY) $Label_1 = GUICtrlCreateLabel("Click list item to do the action", 140, 10, 260, 292) GUICtrlSetData ( $List_1, "Play Tada Sound|Open Notepad|Empty Recycle Bin|Maximize MyGUI|Exit MyGUI") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $List_1; If the $List_1 is clicked then do some action.. ; To find out which item was clicked use GUICtrlRead($List_1) $ReadTheSelectedListItem = GUICtrlRead($List_1) ; Set the label with the data read from $List_1 when it was clicked GUICtrlSetData($Label_1, "Last clicked item: " & "'" & $ReadTheSelectedListItem & "'") ; If Switch Case is met then do that function/command Switch $ReadTheSelectedListItem Case "Open Notepad" ;;; Do stuff ShellExecute("notepad.exe") Case "Play Tada Sound" $B1 = GuiCtrlCreateButton("Button1", 240, 80, 120, 40);; <--------------------> I added this! SoundPlay(@WindowsDir & "\media\tada.wav",1) Case "Empty Recycle Bin" ;;; Do stuff FileRecycleEmpty() Case "Maximize MyGUI" ;;; Do stuff GUISetState(@SW_MAXIMIZE, $Gui) Case "Exit MyGUI" ;;; Do stuff ExitLoop EndSwitch EndSelect WEnd Exit You see my change? I added Button, But when running the script, it's not letting me click on it >.< like it's "un-clickable" or something. What's now? Edited August 21, 2007 by Info Link to comment Share on other sites More sharing options...
smashly Posted August 22, 2007 Share Posted August 22, 2007 (edited) A few reasons the button is non responsive after it's created... 1) The label height covers where the button is created. Fix: Set the label height to a smaller size and then the button actually show it's being mouse overed. 2a) The button when it's created doesn't have anything set to catch the message when it is clicked. Fix: Declare the $B1 variable before the button is created and give it a value of 1 Add a Case $msg = $B1 to the Select loop. 2b) The button doesn't have any action assigned to it when it's clicked Fix: add an action under the Case $msg = $B1 you created in 2a Like so.. expandcollapse popup#include <GuiConstants.au3> Global $B1 = 1 ;<--- Declare the variable , set as 1 until the button is created. $Gui = GuiCreate("MyGUI", 412, 311,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List_1 = GuiCtrlCreateList("", 10, 10, 120, 292, $LBS_NOTIFY) $Label_1 = GUICtrlCreateLabel("Click list item to do the action", 140, 10, 260, 20) ;<-The label hiehgt was covering the button GUICtrlSetData ( $List_1, "Play Tada Sound|Open Notepad|Empty Recycle Bin|Maximize MyGUI|Exit MyGUI") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $B1 ;<- You need to add this so the button will do something when it's clicked. ;;;Do Stuff GUICtrlSetData($Label_1, "Last clicked button: Minimize MyGUI") GUISetState(@SW_MINIMIZE, $Gui) Case $msg = $List_1; If the $List_1 is clicked then do some action.. ; To find out which item was clicked use GUICtrlRead($List_1) $ReadTheSelectedListItem = GUICtrlRead($List_1) ; Set the label with the data read from $List_1 when it was clicked GUICtrlSetData($Label_1, "Last clicked item: " & "'" & $ReadTheSelectedListItem & "'") ; If Switch Case is met then do that function/command Switch $ReadTheSelectedListItem Case "Open Notepad" ;;; Do stuff ShellExecute("notepad.exe") Case "Play Tada Sound" ;Do a small check and only create the button if it doesn't exist. If $B1 = 1 Then $B1 = GuiCtrlCreateButton("Minimize MyGUI", 240, 80, 120, 40);<-- The button ID will be set in $B1 variable SoundPlay(@WindowsDir & "\media\tada.wav",1) Case "Empty Recycle Bin" ;;; Do stuff FileRecycleEmpty() Case "Maximize MyGUI" ;;; Do stuff GUISetState(@SW_MAXIMIZE, $Gui) Case "Exit MyGUI" ;;; Do stuff ExitLoop EndSwitch EndSelect WEnd Exit Cheers Edited August 22, 2007 by smashly Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now