ManneMoses Posted June 16, 2015 Posted June 16, 2015 Hey there,e.g. I have a gui with one button. If i click the button it should turn transparency on and if i click it again it should turn transaprenc off, but how do i do that? or another example: If i click the button first time it should msgbox: "1" and for the second time it should say: "2", and if i click a third time it should say again 1. I do not have any answer, so can you please make an example script? Thanks in advance, and sorry for my bad english, i am german
Moderators Melba23 Posted June 16, 2015 Moderators Posted June 16, 2015 ManneMoses,One way of doing it:#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("State 1", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Switch GUICtrlRead($cButton) Case "State 1" MsgBox($MB_SYSTEMMODAL, "Pressed", "State = 1") GUICtrlSetData($cButton, "State 2") Case Else MsgBox($MB_SYSTEMMODAL, "Pressed", "State = 2") GUICtrlSetData($cButton, "State 1") EndSwitch EndSwitch WEndPlease ask if you have any questions.M23 Livingbro 1 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
ManneMoses Posted June 16, 2015 Author Posted June 16, 2015 ManneMoses,One way of doing it:#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("State 1", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Switch GUICtrlRead($cButton) Case "State 1" MsgBox($MB_SYSTEMMODAL, "Pressed", "State = 1") GUICtrlSetData($cButton, "State 2") Case Else MsgBox($MB_SYSTEMMODAL, "Pressed", "State = 2") GUICtrlSetData($cButton, "State 1") EndSwitch EndSwitch WEndPlease ask if you have any questions.M23Thank you for your quick reply, it works perfectly. But is there a way to do it without changing the buttons name?
Moderators Melba23 Posted June 16, 2015 Moderators Posted June 16, 2015 ManneMoses,Sure:#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $iState = 1 $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Press Me!", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Switch $iState Case 1 MsgBox($MB_SYSTEMMODAL, "Pressed", "State = 1") $iState = 2 Case Else MsgBox($MB_SYSTEMMODAL, "Pressed", "State = 2") $iState = 1 EndSwitch EndSwitch WEndM23P.S.When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Livingbro 1 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
ManneMoses Posted June 16, 2015 Author Posted June 16, 2015 (edited) Thanks Melba23, it works, problem solved. And sorry for my quote, i do not ask questions in the forum so often Edited June 16, 2015 by ManneMoses
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