atnextc Posted July 31, 2009 Posted July 31, 2009 (edited) Below is my code. I have run into a few problems. 1. When I take out all the stuff about Case $btnok, then the menu msgbox's work as they are supposed to, as well as the exit option under file. The way that it is now they will not work. 2. I managed to get it to where when you click on OK button and no check boxes are selected that it will MSgbox you telling you to select an option. However, when I applied the same principal to have it popup a msgbox if more than one was selected it doesn't work the way I want it to. It just msgbox's that "the selected script will now be run which is not what I want it to do. 3. If i'm wanting to have a "long list" of stuff happen for each option is it best to make that option its own .au3 then have it called via the button or is it wise to just leave it all in one script? 4. General script clean up advice as I'm sure it can be much better, "and I haven't even started on the "real meat" of this thing either." Thanks in advance for any help in these matters >_< expandcollapse popup#comments-start This script will launch a GUI asking what you want to do 1. Login to CRM 2. Close an open Case 3. Close an alert 4. Create a new case for MSS 5. Exit Written by atnextc July 30th 2009 #comments-end #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form=C:\Users\atnextc\Documents\CRM AutoIT Scripts\VIA.kxf $nMSG = GUICreate("VIA Networks CRM Helper", 547, 375, 192, 133) $mnufile = GUICtrlCreateMenu("&File") $mnuexit = GUICtrlCreateMenuItem("Exit", $mnufile) $mnuhelp = GUICtrlCreateMenu("&Help") $mnunone = GUICtrlCreateMenuItem("There Is None", $mnuhelp) $mnuabout = GUICtrlCreateMenu("&About") $mnucrm = GUICtrlCreateMenuItem("About CRM Helper", $mnuabout) $Pic1 = GUICtrlCreatePic("C:\Users\atnextc\Documents\CRM AutoIT Scripts\vialogo.jpg", 168, 32, 249, 57, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $lbl1 = GUICtrlCreateLabel("1.", 160, 160, 13, 17) $lbl2 = GUICtrlCreateLabel("2.", 160, 184, 13, 17) $lbl3 = GUICtrlCreateLabel("3.", 160, 208, 13, 17) $lbl4 = GUICtrlCreateLabel("4.", 160, 232, 13, 17) $lblcrm = GUICtrlCreateLabel("Login To CRM", 184, 160, 73, 17) $lblalert = GUICtrlCreateLabel("Close an Alert", 184, 184, 69, 17) $lblclose = GUICtrlCreateLabel("Close a Case", 184, 208, 66, 17) $lblcreate = GUICtrlCreateLabel("Create New Case", 184, 232, 87, 17) $lbl5 = GUICtrlCreateLabel("5.", 160, 256, 13, 17) $lblexit = GUICtrlCreateLabel("Exit", 184, 256, 21, 17) $lbltitle = GUICtrlCreateLabel("Please Select An Option From The List Below", 176, 112, 218, 17) $btnok = GUICtrlCreateButton("OK", 168, 304, 75, 25, $WS_GROUP) $btnexit = GUICtrlCreateButton("Exit", 288, 304, 75, 25, $WS_GROUP) $chkcrm = GUICtrlCreateCheckbox("", 288, 160, 17, 17) $chkalert = GUICtrlCreateCheckbox("", 288, 184, 17, 17) $chkclose = GUICtrlCreateCheckbox("", 288, 208, 17, 17) $chkcreate = GUICtrlCreateCheckbox("", 288, 232, 17, 17) $chkexit = GUICtrlCreateCheckbox("", 288, 256, 17, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 = 1 $nMSG = GUIGetMsg() If $nMSG = $mnufile Then $mnufile = GUICtrlCreateMenuItem($mnufile, $mnuexit) Exit EndIf If $nMSG = $mnunone Then MsgBox(0, "CRM Helper", "Sorry There Is No Help!") EndIf If $nMSG = $GUI_EVENT_CLOSE Or $nMSG = $btnexit Or $nMSG = $mnuexit Then ExitLoop If $nMSG = $mnucrm Then MsgBox(0, "About CRM Helper", "Created by atnextc") WEnd Switch GUIGetMsg() Case $chkexit If GUICtrlRead($chkexit) = $GUI_CHECKED Then GUICtrlSetData($chkexit, 'Checked') Else GUICtrlSetData($chkexit, 'Unchecked') EndIf Case $btnok $IsChecked = GUICtrlRead($chkexit) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkexit) = $GUI_UNCHECKED Then Else Exit EndIf $IsChecked = GUICtrlRead($chkalert) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkalert) = $GUI_UNCHECKED Then Else MsgBox(0, "CRM Helper", "This will close an alert in CRM!") Exit EndIf $IsChecked = GUICtrlRead($chkcrm) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkcrm) = $GUI_UNCHECKED Then Else MsgBox(0, "CRM Helper", "This will log you into CRM!") Exit EndIf $IsChecked = GUICtrlRead($chkclose) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkclose) = $GUI_UNCHECKED Then Else MsgBox(0, "CRM Helper", "This will close a case in CRM!") Exit EndIf $IsChecked = GUICtrlRead($chkcreate) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkcreate) = $GUI_UNCHECKED Then Else MsgBox(0, "CRM Helper", "This will create a new case in CRM!") Exit EndIf $IsChecked = GUICtrlRead($chkcreate) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkcreate) = $GUI_UNCHECKED Then $IsChecked = GUICtrlRead($chkclose) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkclose) = $GUI_UNCHECKED Then $IsChecked = GUICtrlRead($chkcrm) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkcrm) = $GUI_UNCHECKED Then $IsChecked = GUICtrlRead($chkexit) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkexit) = $GUI_UNCHECKED Then $IsChecked = GUICtrlRead($chkalert) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkalert) = $GUI_UNCHECKED Then MsgBox(0, "CRM Helper", "Please Select An Option!") EndIf EndIf EndIf EndIf EndIf $IsChecked = GUICtrlRead($chkcreate) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkcreate) = $GUI_CHECKED Then $IsChecked = GUICtrlRead($chkclose) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkclose) = $GUI_CHECKED Then MsgBox(0, "CRM Helper", "Please Select Only 1 Option!") $IsChecked = GUICtrlRead($chkcrm) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkcrm) = $GUI_CHECKED Then $IsChecked = GUICtrlRead($chkexit) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkexit) = $GUI_CHECKED Then $IsChecked = GUICtrlRead($chkalert) = $GUI_CHECKED ConsoleWrite($IsChecked & ', ' & Hex($GUI_CHECKED) & @CRLF) If GUICtrlRead($chkalert) = $GUI_CHECKED Then MsgBox(0, "CRM Helper", "Please Select Only 1 Option!") EndIf EndIf EndIf EndIf EndIf Case $GUI_EVENT_CLOSE Exit;Loop EndSwitch ;WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Edited August 1, 2009 by atnextc
Moderators Melba23 Posted August 1, 2009 Moderators Posted August 1, 2009 atnextc,As you only want one option to be selected at a time, I would use a group and radio buttons instead of checkboxes. You can then use a much simpler While...WEnd loop. >_< Take a look at this:expandcollapse popup#comments-start This script will launch a GUI asking what you want to do 1. Login to CRM 2. Close an open Case 3. Close an alert 4. Create a new case for MSS 5. Exit Written by atnextc July 30th 2009 #comments-end #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form=C:\Users\atnextc\Documents\CRM AutoIT Scripts\VIA.kxf $nMSG = GUICreate("VIA Networks CRM Helper", 547, 375, 192, 133) $mnufile = GUICtrlCreateMenu("&File") $mnuexit = GUICtrlCreateMenuItem("Exit", $mnufile) $mnuhelp = GUICtrlCreateMenu("&Help") $mnunone = GUICtrlCreateMenuItem("There Is None", $mnuhelp) $mnuabout = GUICtrlCreateMenu("&About") $mnucrm = GUICtrlCreateMenuItem("About CRM Helper", $mnuabout) $Pic1 = GUICtrlCreatePic("C:\Users\atnextc\Documents\CRM AutoIT Scripts\vialogo.jpg", 168, 32, 249, 57, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $lbl1 = GUICtrlCreateLabel("1.", 160, 160, 13, 17) $lbl2 = GUICtrlCreateLabel("2.", 160, 184, 13, 17) $lbl3 = GUICtrlCreateLabel("3.", 160, 208, 13, 17) $lbl4 = GUICtrlCreateLabel("4.", 160, 232, 13, 17) $lblcrm = GUICtrlCreateLabel("Login To CRM", 184, 160, 73, 17) $lblalert = GUICtrlCreateLabel("Close an Alert", 184, 184, 69, 17) $lblclose = GUICtrlCreateLabel("Close a Case", 184, 208, 66, 17) $lblcreate = GUICtrlCreateLabel("Create New Case", 184, 232, 87, 17) $lbl5 = GUICtrlCreateLabel("5.", 160, 256, 13, 17) $lblexit = GUICtrlCreateLabel("Exit", 184, 256, 21, 17) $lbltitle = GUICtrlCreateLabel("Please Select An Option From The List Below", 176, 112, 218, 17) $btnok = GUICtrlCreateButton("OK", 168, 304, 75, 25, $WS_GROUP) $btnexit = GUICtrlCreateButton("Exit", 288, 304, 75, 25, $WS_GROUP) ; Create a group so only one radio canbe selected at a time GUICtrlCreateGroup("", 275, 145, 37, 140) $chkcrm = GUICtrlCreateRadio("", 288, 160, 17, 17) $chkalert = GUICtrlCreateRadio("", 288, 184, 17, 17) $chkclose = GUICtrlCreateRadio("", 288, 208, 17, 17) $chkcreate = GUICtrlCreateRadio("", 288, 232, 17, 17) $chkexit = GUICtrlCreateRadio("", 288, 256, 17, 17) GUICtrlSetState(-1, $GUI_CHECKED) ; Set this as the default setting GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $btnexit, $mnuexit Exit Case $mnunone MsgBox(0, "CRM Helper", "Sorry There Is No Help!") Case $mnucrm MsgBox(0, "About CRM Helper", "Created by atnextc") Case $btnok ; Check which radio is selected - 1 = checked, 4 = unchecked For $iSelected_Radio = $chkcrm To $chkexit If GUICtrlRead($iSelected_Radio) = 1 Then ExitLoop ; Found the only possibilty so exit the For...Next loop Next ; Run code for selected radio Switch $iSelected_Radio Case $chkcrm MsgBox(0, "CRM Helper", "This will log you into CRM!") Exit Case $chkalert MsgBox(0, "CRM Helper", "This will close an alert in CRM!") Exit Case $chkclose MsgBox(0, "CRM Helper", "This will close a case in CRM!") Exit Case $chkcreate MsgBox(0, "CRM Helper", "This will create a new case in CRM!") Exit Case $chkexit Exit EndSwitch EndSwitch WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>TerminateAsk if anything is unclear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
atnextc Posted August 1, 2009 Author Posted August 1, 2009 Thanks works great now. I had tried radio buttons but still basically ended up where I was at with the checkboxes. I'll keep messing with it and let you know if I run into anymore problems. Oh yea, one more thing, how can I make it to where my pic I have will show up on any computer that this is run on?
AdmiralAlkex Posted August 1, 2009 Posted August 1, 2009 @atnextcTake a look at FileInstall() >_< .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
GEOSoft Posted August 1, 2009 Posted August 1, 2009 @M23 You don't need that GUICtrlCreateGroup() at all. Use GUIStartGroup() instead unless are looking to have the frame border created around group. GUIStartGroup() $chkcrm = GUICtrlCreateRadio("", 288, 160, 17, 17) $chkalert = GUICtrlCreateRadio("", 288, 184, 17, 17) $chkclose = GUICtrlCreateRadio("", 288, 208, 17, 17) $chkcreate = GUICtrlCreateRadio("", 288, 232, 17, 17) $chkexit = GUICtrlCreateRadio("", 288, 256, 17, 17) GUICtrlSetState(-1, $GUI_CHECKED) ; Set this as the default setting GUIStartGroup() ;; To end the group George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Moderators Melba23 Posted August 1, 2009 Moderators Posted August 1, 2009 GEOSoft, Thank you for that reminder. I always forget that you can do it without the border - it is age, you know. >_< M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
GEOSoft Posted August 2, 2009 Posted August 2, 2009 On 8/1/2009 at 5:49 PM, 'Melba23 said: GEOSoft,Thank you for that reminder. I always forget that you can do it without the border - it is age, you know. >_< M23Good excuse. I'll have to remember that one. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
atnextc Posted August 3, 2009 Author Posted August 3, 2009 Thanks alot for the input guys, i'll try it out and let you know if I run into anymore problems!!!
SolidSnake26 Posted August 24, 2009 Posted August 24, 2009 On 8/1/2009 at 5:43 PM, 'GEOSoft said: @M23 You don't need that GUICtrlCreateGroup() at all. Use GUIStartGroup() instead unless are looking to have the frame border created around group. GUIStartGroup() $chkcrm = GUICtrlCreateRadio("", 288, 160, 17, 17) $chkalert = GUICtrlCreateRadio("", 288, 184, 17, 17) $chkclose = GUICtrlCreateRadio("", 288, 208, 17, 17) $chkcreate = GUICtrlCreateRadio("", 288, 232, 17, 17) $chkexit = GUICtrlCreateRadio("", 288, 256, 17, 17) GUICtrlSetState(-1, $GUI_CHECKED) ; Set this as the default setting GUIStartGroup() ;; To end the group If I want to do the same with check boxes which run the selected programs in series, what should i do? thankyou
Moderators Melba23 Posted August 24, 2009 Moderators Posted August 24, 2009 SolidSnake26, On 8/24/2009 at 8:50 AM, 'SolidSnake26 said: run the selected programs in seriesThe point of using a group is to have only one selection at a time - that is why radiobuttons are the preferred control. If you want several options to run in sequence (which is how I understand your quote above), you do not need a group - you can just run through the checkboxes in turn and check their state - then run whatever is associated with that checkbox.If I have misunderstood you and this is not what you wanted to do, please give some more explanation. >_< M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
GEOSoft Posted August 24, 2009 Posted August 24, 2009 (edited) #include <ButtonConstants.au3> #include<GUIConstantsEx.au3> GUICreate("Test") GUIStartGroup() $Btn_1 = GUICtrlCreateCheckBox(" 1", 10, 10, 25, 17) $Btn_2 = GUICtrlCreateCheckBox(" 2", 10, 40, 25, 17) $Btn_3 = GUICtrlCreateCheckBox(" 3", 10, 70, 25, 17) GUIStartGroup() GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $Btn_1 To $Btn_3 For $i = $Btn_1 To $Btn_3 If $i = $Msg Then ContinueLoop If BitAND(GUICtrlRead($Msg), $GUI_CHECKED) Then GUICtrlSetState($i, $GUI_UNCHECKED) Next EndSwitch WEndEDIT: Changed the code to use BitAND() Edited August 24, 2009 by GEOSoft George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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