RabbieBurns Posted May 22, 2008 Posted May 22, 2008 Ive made an autoit script that has 2 columns of radio buttons, say for example A -> D and 1 - > 2 , and a GO button, and I want each different compbination of rado buttons (A and 1) (A and 2) etc to run a different thing. Can anyone whose skilled with Auto it knock us up a quick template I could use please that just pops up say a msgbox saying "You chose A and 1" etc please? I cant seem to find any examples of scripts with radio buttons ilke that.. Cheers in advance!
mattx Posted May 22, 2008 Posted May 22, 2008 Ive made an autoit script that has 2 columns of radio buttons, say for example A -> D and 1 - > 2 , and a GO button, and I want each different compbination of rado buttons (A and 1) (A and 2) etc to run a different thing. Can anyone whose skilled with Auto it knock us up a quick template I could use please that just pops up say a msgbox saying "You chose A and 1" etc please? I cant seem to find any examples of scripts with radio buttons ilke that.. Cheers in advance! MsgBox(64,"Oi you !!","You chose A and 1") Use Codewizard or Koda. Should be part of the SciTE package.... http://www.autoitscript.com/autoit3/scite/
RabbieBurns Posted May 22, 2008 Author Posted May 22, 2008 I can make the textboxes fine its passing which radio buttons have been selected I cant do, sorry, didnt explain myself well again. Ill check out that link thanks.
mattx Posted May 22, 2008 Posted May 22, 2008 I can make the textboxes fine its passing which radio buttons have been selected I cant do, sorry, didnt explain myself well again. Ill check out that link thanks. You will need to create a loop and make each radio button a variable which will then have a value when its been selected: Dirty code. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Button1 Do something Case $nMsg = $Button2 Do something Endselect Wend etc....
RabbieBurns Posted May 22, 2008 Author Posted May 22, 2008 (edited) Ok thanks for the advice but I really cant get my head round it. Hope its ok to post this code #include #include #include ;Opt("MustDeclareVars", 1) ; ; Program to simplify the printing and archiving of School Reports ; ; Written by R. Reynolds, 2008 ; ; Declare all the variables Global $hGUI, $msg, $hImage, $hGraphic, $button1, $button2, $label_1, $label_2, $label_3, $optJunior, $optTransitus, $optS1, $optS2, $optS3, $optS4, $optS56, $optrep, $optatt, $iMsgBoxAnswer2, $iMsgBoxAnswer ; Create GUI $hGUI = GUICreate("School Reporting System - Version 0.1a", 550, 215) GUISetState() $filemenu = GuiCtrlCreateMenu ("File") $exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu) $helpmenu = GuiCtrlCreateMenu ("?") $helpitem = GuiCtrlCreateMenuitem ("Help",$helpmenu) $aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu) ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\badge.png") ; Draw PNG image $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) ; Loop until user exits ; Draw the Print and Save Icons $button1 = GUICtrlCreateButton ("1", 170,100,75,75,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",7) $button2 = GUICtrlCreateButton ("2", 170,10,75,75,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",17) GUISetState() $Label_1 = GuiCtrlCreateLabel("Created by Robert Reynolds", 390, 180, 150, 21, 0x1000) GUICtrlCreateGroup("Year", 280, 5, 150, 170) $optJunior = GUICtrlCreateRadio("Junior", 290, 20, 100, 20) GUICtrlSetState(-1, $GUI_CHECKED) $optTransitus = GUICtrlCreateRadio("Transitus", 290, 40, 100, 20) $optS1 = GUICtrlCreateRadio("S1", 290, 60, 100, 20) $optS2 = GUICtrlCreateRadio("S2", 290, 80, 100, 20) $optS3 = GUICtrlCreateRadio("S3", 290, 100, 120, 20) $optS4 = GUICtrlCreateRadio("S4", 290, 120, 100, 20) $optS56 = GUICtrlCreateRadio("S5 and S6", 290, 140, 130, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateGroup("Option", 420, 5, 120, 170) $optrep = GUICtrlCreateRadio("Reports", 440, 60, 100, 10) GUICtrlSetState(-1, $GUI_CHECKED) $optatt= GUICtrlCreateRadio("Attitudinals", 440, 80, 100, 10) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group While 1 $msg = GUIGetMsg() Select Case $msg = $exititem ExitLoop Case $msg = $aboutitem MsgBox(64,"School Reporting System","School Reporting System Windows Utility." & @CRLF & "" & @CRLF & "This program is designed to simplify the Printing of completed reports." & @CRLF & "" & @CRLF & "Designed By R Reynolds. May 2008") Case $msg = $helpitem MsgBox(32,"School Reporting System","This button will display some brief help about the program") ; The Save Button Case $msg = $button1 $iMsgBoxAnswer2 = MsgBox(36,"Archiving reports....","Are you sure you want to archive the complete set of Reports?") ; Case $msg = Select Case $iMsgBoxAnswer2 = 6 ;Yes MsgBox(64,"School Reporting System","Reports archived.") Case $iMsgBoxAnswer2 = 7 ;No EndSelect Case $msg = $button2 $iMsgBoxAnswer = MsgBox(36,"Printing reports....","Are you sure you want to print the complete set of Reports?") Select Case $iMsgBoxAnswer = 6 ;Yes MsgBox(64,"School Reporting System","Reports sent to the printer") ; run("cscript print_test.vbs") Case $iMsgBoxAnswer = 7 ;No EndSelect EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend ; Display the exit dialog Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52,"Close Program","Are you sure you want to exit this program?") Select Case $iMsgBoxAnswer = 6 ;Yes Case $iMsgBoxAnswer = 7 ;No ; What do I put in here to keep the program running? EndSelect ; Clean up and exit _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() GUIDelete() Exit Any chance someone could add in a bit of the missing stuff to get me going please? Edited May 22, 2008 by rreynolds24
RabbieBurns Posted June 5, 2008 Author Posted June 5, 2008 ok, scrap the last post... Can anyone post me an example of an autoit script with just simply 2 radio options, and a button, which when the button is pressed displays a different message box dependant on which radio button is selected. Thats basically the bit im stuck at in my big script so if anyone could offer a wee example script please I think I should be able to take it from there Cheers
gseller Posted June 12, 2008 Posted June 12, 2008 ok, scrap the last post... Can anyone post me an example of an autoit script with just simply 2 radio options, and a button, which when the button is pressed displays a different message box dependant on which radio button is selected. Thats basically the bit im stuck at in my big script so if anyone could offer a wee example script please I think I should be able to take it from there Cheers Here is straight out of the help file, hope it helps.. #include Opt('MustDeclareVars', 1) Example() ;------------------------------------------------------------------------------------- ; Example - Press the button to see the value of the radio boxes ; The script also detects state changes (closed/minimized/timeouts, etc). Func Example() Local $button_1, $group_1, $radio_1, $radio_2, $radio_3 Local $radioval1, $radioval2, $msg Opt("GUICoordMode", 1) GUICreate("Radio Box Demo", 400, 280) ; Create the controls $button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40) $group_1 = GUICtrlCreateGroup("Group 1", 30, 90, 165, 160) GUIStartGroup() $radio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20) $radio_2 = GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20) $radio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20) ; Init our vars that we will use to keep track of GUI events $radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button $radioval2 = 2 ; Show the GUI GUISetState() ; In this message loop we use variables to keep track of changes to the radios, another ; way would be to use GUICtrlRead() at the end to read in the state of each control While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "", "Dialog was closed") Exit Case $msg = $GUI_EVENT_MINIMIZE MsgBox(0, "", "Dialog minimized", 2) Case $msg = $GUI_EVENT_MAXIMIZE MsgBox(0, "", "Dialog restored", 2) Case $msg = $button_1 MsgBox(0, "Default button clicked", "Radio " & $radioval1) Case $msg >= $radio_1 And $msg <= $radio_3 $radioval1 = $msg - $radio_1 EndSelect WEnd EndFunc ;==>Example 1
gseller Posted June 16, 2008 Posted June 16, 2008 Not a problem, Lots of info in there, easy to miss...
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