ju4711 Posted October 2, 2017 Share Posted October 2, 2017 Hello Guys. I want to create a little programm where you can make messageboxes and save them (for people who dont know how to do that themself :3). I have some kinda radio field buttons to decide what icon the messagebox should show. With the inputboxes, i do it like this: $FinalTitle = GUICtrlRead($Title) $FinalMessage = GUICtrlRead($Message) MsgBox($FinalIcon,$FinalTitle,$FinalMessage) But for some reason the one with the icon does not work properly: $FinalIcon = If GUICtrlRead($Error) = 1 Then <syntax error> GUICtrlSetData($FinalIcon,16) Please help me, im a noob Link to comment Share on other sites More sharing options...
Danp2 Posted October 2, 2017 Share Posted October 2, 2017 24 minutes ago, ju4711 said: $FinalIcon = If GUICtrlRead($Error) = 1 Then This isn't valid syntax. You should probably look into Select...Case...EndSelect in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
BigDaddyO Posted October 2, 2017 Share Posted October 2, 2017 are you trying to do something like the CodeWizard that is available in the Full Scite install under the Tools menu? Also, what Danp2 said is correct. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 2, 2017 Moderators Share Posted October 2, 2017 @ju4711 it is a bit difficult to ascertain what you are trying to do from such a small non-runnable snippet. You appear to be trying to read from a control on your GUI named $Error, but you're leaving us to guess whether this is an input, a combo box, etc. How about helping us help you and posting your code, or at least a runnable reproducer? ju4711 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
ju4711 Posted October 2, 2017 Author Share Posted October 2, 2017 Well , youre right. I will just copy and paste the whole script in here: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("My MsgBox", 654, 221, 174, 117) $Exit = GUICtrlCreateMenu("&Exit") $Credits = GUICtrlCreateMenu("&Credits") $Help = GUICtrlCreateMenu("&Help") $Generate = GUICtrlCreateButton("Generate", 248, 128, 155, 49) $Error = GUICtrlCreateRadio("Error (Icon)", 32, 48, 115, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Warning = GUICtrlCreateRadio("Warning (Icon)", 32, 96, 115, 17) $Information = GUICtrlCreateRadio("Information (Icon)", 32, 144, 115, 17) $Title = GUICtrlCreateInput("Type in your title here.", 248, 48, 153, 21) $Message = GUICtrlCreateInput("Type in your message here.", 248, 88, 153, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #NoTrayIcon While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Generate $FinalIcon = If GUICtrlRead($Error) = $GUI_CHECKED Then GUICtrlSetData($FinalIcon,16) GUICtrlRead($FinalIcon) $FinalTitle = GUICtrlRead($Title) $FinalMessage = GUICtrlRead($Message) MsgBox($FinalIcon,$FinalTitle,$FinalMessage) Okay, i hope you can work with that xd ^^. $Error for example is just the radio field button to choose an icon and $FinalError is that what comes out from "GuiCtrlRead" Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 2, 2017 Moderators Share Posted October 2, 2017 Better, but still confusing. You have an IF with no EndIF. So, if $Error is checked, do you want to perform one of the actions below, or all of them? GUICtrlSetData($FinalIcon,16) GUICtrlRead($FinalIcon) $FinalTitle = GUICtrlRead($Title) $FinalMessage = GUICtrlRead($Message) MsgBox($FinalIcon,$FinalTitle,$FinalMessage) ju4711 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
ju4711 Posted October 2, 2017 Author Share Posted October 2, 2017 oh. Well, if $Error is checked, the programm should change the data of $FinalIcon to 16 so that the msgbox showes the right icon. I guess that would mean... After the "GuiCtrlRead($FinalIcon)" there should be an Endif. (Im not sure tbh :/) Link to comment Share on other sites More sharing options...
kylomas Posted October 3, 2017 Share Posted October 3, 2017 ju4711, Is this what you are trying to do...? expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> ; *** End added by AutoIt3Wrapper *** #include <WindowsConstants.au3> #AutoIt3Wrapper_Add_Constants=n #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("My MsgBox", 654, 221, 174, 117) $Exit = GUICtrlCreateMenu("&Exit") $Credits = GUICtrlCreateMenu("&Credits") $Help = GUICtrlCreateMenu("&Help") $Generate = GUICtrlCreateButton("Generate", 248, 128, 155, 49) $Error = GUICtrlCreateRadio("Error (Icon)", 32, 48, 115, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Warning = GUICtrlCreateRadio("Warning (Icon)", 32, 96, 115, 17) $Information = GUICtrlCreateRadio("Information (Icon)", 32, 144, 115, 17) $Title = GUICtrlCreateInput("Type in your title here.", 248, 48, 153, 21) $Message = GUICtrlCreateInput("Type in your message here.", 248, 88, 153, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #NoTrayIcon Local $finalicon While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Generate If GUICtrlRead($Error) = $GUI_CHECKED Then $finalicon = 16 If GUICtrlRead($Warning) = $GUI_CHECKED Then $finalicon = 48 If GUICtrlRead($Information) = $GUI_CHECKED Then $finalicon = 64 $FinalTitle = GUICtrlRead($Title) $FinalMessage = GUICtrlRead($Message) MsgBox($finalicon, $FinalTitle, $FinalMessage) EndSwitch WEnd kylomas ju4711 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ju4711 Posted October 3, 2017 Author Share Posted October 3, 2017 Thank you very much. I appreciate it 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