newsak2005 Posted August 13, 2011 Share Posted August 13, 2011 OneTouchButtonexpandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $hForm = GUICreate("OneTouchButton", 308, 95, -1, -1) $Button = GUICtrlCreateButton("Button1", 112, 56, 75, 25, $WS_GROUP) GUICtrlSetCursor(-1, 0) $Label = GUICtrlCreateLabel("Clicked Report", 110, 16, 100, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button If $nMsg = $Button Then GUICtrlSetData($Label, "You Clicked..Button1") GUISetBkColor(0xFF0000) GUICtrlSetData($Button, "Button2") ;add statement1 here. While 1 $msg = GUIGetMsg() If $msg = -3 Then Exit If $msg = $Button Then GUICtrlSetData($Label, "You Clicked..Button2") GUISetBkColor(0x00FF00) GUICtrlSetData($Button, "Button3") ;add statement2 here. ExitLoop EndIf WEnd Do $msg = GUIGetMsg() If $msg = -3 Then Exit If $msg = $Button Then GUICtrlSetData($Label, "You Clicked..Button3") GUISetBkColor(0x0000FF) GUICtrlSetData($Button, "Button1") ;add statement3 here. ExitLoop EndIf Until False EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 13, 2011 Moderators Share Posted August 13, 2011 newsak2005,Simpler to use a Switch to do this: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $hForm = GUICreate("OneTouchButton", 308, 95, -1, -1) $Button = GUICtrlCreateButton("Button 1", 112, 56, 75, 25) $Label = GUICtrlCreateLabel("Clicked Report", 90, 16, 110, 17, $SS_CENTER) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button Switch GUICtrlRead($Button) Case "Button 1" GUICtrlSetData($Label, "You Clicked..Button 1 ") GUISetBkColor(0xFFCCCC) GUICtrlSetData($Button, "Button 2") Case "Button 2" GUICtrlSetData($Label, "You Clicked..Button 2") GUISetBkColor(0xCCFFCC) GUICtrlSetData($Button, "Button 3") Case "Button 3" GUICtrlSetData($Label, "You Clicked..Button 3") GUISetBkColor(0xCCCCFF) GUICtrlSetData($Button, "Button 1") EndSwitch EndSwitch WEndM23 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...
newsak2005 Posted August 13, 2011 Author Share Posted August 13, 2011 Melba23 Thanks. Your script. Link to comment Share on other sites More sharing options...
newsak2005 Posted August 13, 2011 Author Share Posted August 13, 2011 Use Select Case. Melba23. Borrowing the idea of......... #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $hForm = GUICreate("OneTouchButton", 308, 95, -1, -1) $Button = GUICtrlCreateButton("Button 1", 112, 56, 75, 25) $Label = GUICtrlCreateLabel("Clicked Report", 90, 16, 110, 17, $SS_CENTER) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button $iButton = GUICtrlRead($Button) Select Case $iButton="Button 1" GUICtrlSetData($Label, "You Clicked..Button 1 ") GUISetBkColor(0xFFCCCC) GUICtrlSetData($Button, "Button 2") Case $iButton="Button 2" GUICtrlSetData($Label, "You Clicked..Button 2") GUISetBkColor(0xCCFFCC) GUICtrlSetData($Button, "Button 3") Case $iButton="Button 3" GUICtrlSetData($Label, "You Clicked..Button 3") GUISetBkColor(0xCCCCFF) GUICtrlSetData($Button, "Button 1") EndSelect EndSwitch WEnd Link to comment Share on other sites More sharing options...
newsak2005 Posted August 13, 2011 Author Share Posted August 13, 2011 Use include GuiButton.au3 With _GUICtrlButton_GetText() #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #Include <GuiButton.au3> $hForm = GUICreate("OneTouchButton", 308, 95, -1, -1) $Button = GUICtrlCreateButton("Button 1", 112, 56, 75, 25) $Label = GUICtrlCreateLabel("Clicked Report", 90, 16, 110, 17, $SS_CENTER) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button Switch _GUICtrlButton_GetText($Button) Case "Button 1" GUICtrlSetData($Label, "You Clicked.."& _GUICtrlButton_GetText($Button)) GUISetBkColor(0xFFCCCC) GUICtrlSetData($Button, "Button 2") Case "Button 2" GUICtrlSetData($Label, "You Clicked.."& _GUICtrlButton_GetText($Button)) GUISetBkColor(0xCCFFCC) GUICtrlSetData($Button, "Button 3") Case "Button 3" GUICtrlSetData($Label, "You Clicked.."& _GUICtrlButton_GetText($Button)) GUISetBkColor(0xCCCCFF) GUICtrlSetData($Button, "Button 1") EndSwitch EndSwitch WEnd Link to comment Share on other sites More sharing options...
newsak2005 Posted August 13, 2011 Author Share Posted August 13, 2011 Use Library Include expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #Include <GuiButton.au3> $hForm = GUICreate("OneTouchButton", 308, 95, -1, -1) $Button = GUICtrlCreateButton("Button 1", 112, 56, 75, 25) $Label = GUICtrlCreateLabel("Clicked Report", 90, 16, 110, 17, $SS_CENTER) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button Switch GUICtrlButton_GetText($Button) Case "Button 1" GUICtrlSetData($Label, "You Clicked.."& GUICtrlButton_GetText($Button)) GUISetBkColor(0xFFCCCC) GUICtrlSetData($Button, "Button 2") Case "Button 2" GUICtrlSetData($Label, "You Clicked.."& GUICtrlButton_GetText($Button)) GUISetBkColor(0xCCFFCC) GUICtrlSetData($Button, "Button 3") Case "Button 3" GUICtrlSetData($Label, "You Clicked.."& GUICtrlButton_GetText($Button)) GUISetBkColor(0xCCCCFF) GUICtrlSetData($Button, "Button 1") EndSwitch EndSwitch WEnd Func GUICtrlButton_GetText($hWnd) If $Debug_Btn Then __UDF_ValidateClassName($hWnd, $__BUTTONCONSTANT_ClassName) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If WinAPI_IsClassName($hWnd, $__BUTTONCONSTANT_ClassName) Then Return WinAPI_GetWindowText($hWnd) Return "" EndFunc Func WinAPI_IsClassName($hWnd, $sClassName) Local $sSeparator = Opt("GUIDataSeparatorChar") Local $aClassName = StringSplit($sClassName, $sSeparator) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $sClassCheck = WinAPI_GetClassName($hWnd) For $x = 1 To UBound($aClassName) - 1 If StringUpper(StringMid($sClassCheck, 1, StringLen($aClassName[$x]))) = StringUpper($aClassName[$x]) Then Return True Next Return False EndFunc Func WinAPI_GetWindowText($hWnd) Local $aResult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hWnd, "wstr", "", "int", 4096) If @error Then Return SetError(@error, @extended, "") Return SetExtended($aResult[0], $aResult[2]) EndFunc Func WinAPI_GetClassName($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $aResult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hWnd, "wstr", "", "int", 4096) If @error Then Return SetError(@error, @extended, False) Return SetExtended($aResult[0], $aResult[2]) EndFunc 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