Pain Posted May 27, 2008 Share Posted May 27, 2008 (edited) I need some help with this button. As you can see if you press the button once the label change to "Stop" but if you press it again nothing happen, or well it does, it change the label to "Stop" again but you won't notice anything. I want it to change back to "Start". #include <GUIConstants.au3> $Form1 = GUICreate("Status", 250, 150, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) GUICtrlCreateLabel ("STATUS: ", 50, 50) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $status= GUICtrlCreateLabel("OFF", 62, 80, 100) GUICtrlSetColor(-1,0xff0000) ; Red GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $button = GUICtrlCreateButton ("START", 165, 25, 75, 100, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button start() EndSwitch WEnd Func start() while 1 GUICtrlSetData ($button, "STOP") GUICtrlSetData ($status, "ON") GUICtrlSetFont($status, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor ($status, 0x00A400) ;Green Sleep(500) WEnd EndFunc Edited May 27, 2008 by Pain Link to comment Share on other sites More sharing options...
ChrisL Posted May 27, 2008 Share Posted May 27, 2008 Is this what your after? expandcollapse popup#include <GUIConstants.au3> $Form1 = GUICreate("Status", 250, 150, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) GUICtrlCreateLabel ("STATUS: ", 50, 50) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $status= GUICtrlCreateLabel("OFF", 62, 80, 100) GUICtrlSetColor(-1,0xff0000) ; Red GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $buttonText = "START" $button = GUICtrlCreateButton ($buttonText, 165, 25, 75, 100, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button start() EndSwitch WEnd Func start() If $buttonText = "START" then $buttonText = "STOP" GUICtrlSetData ($button, $buttonText) GUICtrlSetData ($status, "ON") GUICtrlSetFont($status, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor ($status, 0x00A400) ;Green Else $buttonText = "START" GUICtrlSetData ($button, $buttonText) GUICtrlSetData ($status, "OFF") GUICtrlSetFont($status, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor ($status, 0xff0000) ;Red EndIf EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Pain Posted May 27, 2008 Author Share Posted May 27, 2008 yea that's exactly what I was looking for, thanks alot Link to comment Share on other sites More sharing options...
Valuater Posted May 27, 2008 Share Posted May 27, 2008 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Status", 250, 150, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) GUICtrlCreateLabel("STATUS: ", 50, 50) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $status = GUICtrlCreateLabel("OFF", 62, 80, 100) GUICtrlSetColor(-1, 0xff0000) ; Red GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $button = GUICtrlCreateButton("START", 165, 25, 75, 100, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button start() EndSwitch WEnd Func start() ;While 1 If GUICtrlRead($button) = "START" Then GUICtrlSetData($button, "STOP") GUICtrlSetData($status, "ON") GUICtrlSetColor($status, 0x00A400) ;Green Else GUICtrlSetData($button, "START") GUICtrlSetData($status, "OFF") GUICtrlSetColor(-1, 0xff0000) ; Red EndIf Return ;Sleep(500) ;WEnd EndFunc ;==>start ...........Way too slow!!!... 8) Edited May 27, 2008 by Valuater Link to comment Share on other sites More sharing options...
Pain Posted May 27, 2008 Author Share Posted May 27, 2008 Valuater try click on the button 2 or 3 times and you will see that the button will become weird, just like it's always pressed... Link to comment Share on other sites More sharing options...
Valuater Posted May 27, 2008 Share Posted May 27, 2008 Valuater try click on the button 2 or 3 times and you will see that the button will become weird, just like it's always pressed... Sorry, I missed that one.. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Status", 250, 150, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) GUICtrlCreateLabel("STATUS: ", 50, 50) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $status = GUICtrlCreateLabel("OFF", 62, 80, 100) GUICtrlSetColor(-1, 0xff0000) ; Red GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $button = GUICtrlCreateButton("START", 165, 25, 75, 100, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button start() EndSwitch WEnd Func start() ;While 1 If GUICtrlRead($button) = "START" Then GUICtrlSetData($button, "STOP") GUICtrlSetData($status, "ON") GUICtrlSetColor($status, 0x00A400) ;Green Else GUICtrlSetData($button, "START") GUICtrlSetData($status, "OFF") GUICtrlSetColor($status, 0xff0000) ; Red EndIf Return ;Sleep(500) ;WEnd EndFunc ;==>start 8) 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