brad25 Posted March 2, 2010 Share Posted March 2, 2010 hi, i need some help can someone show me how to get a checkbox to work with a button. for instants i have 2 check boxes and a button if i check 1 box and press the button i want the scrip to messagebox checkbox1 if i check both boxes i want it to say checkbox1 checkbox2 how do i do this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2010 Moderators Share Posted March 2, 2010 brad25,Here you go: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hCheck1 = GUICtrlCreateCheckbox(" Check 1", 10, 10, 200, 20) $hCheck2 = GUICtrlCreateCheckbox(" Check 1", 10, 50, 200, 20) $hButton = GUICtrlCreateButton("Press!", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If GUICtrlRead($hCheck1) = 1 Then If GUICtrlRead($hCheck2) = 1 Then MsgBox(0, "Checked", "Check 1 and Check 2") Else MsgBox(0, "Checked", "Check 1") EndIf ElseIf GUICtrlRead($hCheck2) = 1 Then MsgBox(0, "Checked", "Check 2") EndIf EndSwitch WEndAs a relative beginner (nothing wrong with that - we all started there! ) reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You might also want to look at the excellent tutorials that you will find here and here. There are even video tutorials on YouTube if you prefer watching to reading.I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. 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: Spoiler 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 Link to comment Share on other sites More sharing options...
brad25 Posted March 2, 2010 Author Share Posted March 2, 2010 ty for the help and the advice i will use them both of tehm one other question how do i set a background to the form i have a jpeg image i want to use Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2010 Moderators Share Posted March 2, 2010 brad25,Read about GUICtrlCreatePic in the Help file - but read it carefully! The page specifically mentions how to set a picture as background - so I do not want you complaining in a while that none of your controls work! 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: Spoiler 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 Link to comment Share on other sites More sharing options...
brad25 Posted March 2, 2010 Author Share Posted March 2, 2010 could you show me an example? Link to comment Share on other sites More sharing options...
martin Posted March 2, 2010 Share Posted March 2, 2010 could you show me an example?You should try writing something and try the example in the help file that M23 directed you to. But so far you have started with only asking for someone to do things for you. It is not the best way to learn IMO. Try something, struggle with it and if you can't see how to get it to do what you want then show your code and ask for advice. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2010 Moderators Share Posted March 2, 2010 brad25, I completely agree with martin. That is why I pointed you at the Help file. We will be here if you have problems. 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: Spoiler 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 Link to comment Share on other sites More sharing options...
brad25 Posted March 3, 2010 Author Share Posted March 3, 2010 ok i have been going at this for hours and cant figure it out. if i check box 1 i want it to run the loop and do the PixelGetColor but i cant get it working im guessing its because im using a if statment inside an if stament but i cant get the PixelGetColor to work without it any suggestions expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hCheck1 = GUICtrlCreateCheckbox(" button1", 10, 10, 200, 20) $hCheck2 = GUICtrlCreateCheckbox(" button2", 10, 50, 200, 20) $hButton = GUICtrlCreateButton("Press!", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If GUICtrlRead($hCheck1) = 1 then if(0xe2900e = PixelGetColor(298, 341)) Then sleep(1000) MouseClick("left", 539 , 411 ) sleep(3000) MouseClick("left", 830 , 158 ) EndIf If GUICtrlRead($hCheck2) = 1 Then If (0xe7b486 = PixelGetColor(309, 325)) Then sleep(1000) MouseClick("left", 555 , 409 ) sleep(3000) MouseClick("left", 830 , 158 ) EndIf Else EndIf ElseIf GUICtrlRead($hButton) = 0 Then MsgBox(0, "Error", "Please Check a Box") EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2010 Moderators Share Posted March 3, 2010 brad25, You have not read any of those tutorials, have you! This is the last time I will help until you show some signs of trying to learn for yourself. As you only want one selection each time, I have used RadioButtons in a Group so that they switch automatically: expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUIStartGroup() $hRadio1 = GUICtrlCreateRadio(" Button 1", 10, 10, 200, 20) $hRadio2 = GUICtrlCreateRadio(" Button 2", 10, 50, 200, 20) $hButton = GUICtrlCreateButton("Press!", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If GUICtrlRead($hRadio1) = 1 Then If PixelGetColor(298, 341) = 0xe2900e Then Sleep(1000) MouseClick("left", 539 , 411 ) sleep(3000) MouseClick("left", 830 , 158 ) EndIf ElseIf GUICtrlRead($hRadio2) = 1 Then If PixelGetColor(309, 325) = 0xe7b486 Then Sleep(1000) MouseClick("left", 555 , 409 ) Sleep(3000) MouseClick("left", 830 , 158 ) EndIf Else MsgBox(0, "Error", "Please select an option") EndIf EndSwitch WEnd Now go and do some studying! 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: Spoiler 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 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