dickep Posted June 22, 2008 Posted June 22, 2008 Ok, I have a problem. I want to have an input box that a user can use for logging data. However, that user could change the name - all legal = but it does not change. Code of what I want to do below. Any help appreciated expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 447, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Label1 = GUICtrlCreateLabel("Log File Name: ", 64, 72, 78, 17) $Input1 = GUICtrlCreateInput("Input1", 144, 72, 121, 21) $Button1 = GUICtrlCreateButton("Start Logging", 200, 224, 75, 25, 0) GUICtrlSetOnEvent(-1, "Button1Click") $Button2 = GUICtrlCreateButton("Exit", 400, 224, 75, 25, 0) GUICtrlSetOnEvent(-1, "Button2Click") $Label2 = GUICtrlCreateLabel("Elapsed Time: ", 352, 128, 74, 17) $Label3 = GUICtrlCreateLabel("00:00:00", 424, 128, 54, 17, $SS_CENTER) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $something = True global $tStart = TimerInit() While 1 if $something Then _DoSomething() EndIf Sleep(100) WEnd Func Button1Click() if $something Then GUICtrlSetData($Button1, "Stop Logging") $something = False Else GUICtrlSetData($Button1, "Start Logging") $something = True EndIf EndFunc Func Button2Click() Exit EndFunc Func Form1Close() EndFunc Func _DoSomething() $myData = GUICtrlRead($Input1,1); get the text of the input box?? if $myData = '' Then GUICtrlSetData($Input1, "") Else GUICtrlSetData($Input1, $myData) EndIf for $x =1 to 5 GUICtrlSetData($Label3, _TicksToTime_ms(TimerDiff($tStart))) sleep(1000) next EndFunc Func _TicksToTime_ms($iTicks) Local $ihms[5], $split $iTicks = $iTicks / 1000 $ihms[1] = Int($iTicks / 3600) $iTicks = Mod($iTicks, 3600) $ihms[2] = Int($iTicks / 60) $ihms[3] = Mod($iTicks, 60) $split = StringSplit( $ihms[3], ".") $ihms[4] = $split[2] Return StringFormat( "%02i:%02i:%02i", $ihms[1], $ihms[2], $ihms[3]) EndFunc ;==>_TicksToTime_ms
rasim Posted June 22, 2008 Posted June 22, 2008 Hi! Don`t understand completely... expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt("GUIOnEventMode", 1) Global $something = False Global $tStart = TimerInit() #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 447, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Label1 = GUICtrlCreateLabel("Log File Name: ", 64, 72, 78, 17) $Input1 = GUICtrlCreateInput("Input1", 144, 72, 121, 21) $Button1 = GUICtrlCreateButton("Start Logging", 200, 224, 75, 25, 0) GUICtrlSetOnEvent(-1, "Button1Click") $Button2 = GUICtrlCreateButton("Exit", 400, 224, 75, 25, 0) GUICtrlSetOnEvent(-1, "Form1Close") $Label2 = GUICtrlCreateLabel("Elapsed Time: ", 352, 128, 74, 17) $Label3 = GUICtrlCreateLabel("00:00:00", 424, 128, 54, 17, $SS_CENTER) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 if $something Then _DoSomething() EndIf Sleep(100) WEnd Func Button1Click() if $something Then GUICtrlSetData($Button1, "Stop Logging") $something = False Else GUICtrlSetData($Button1, "Start Logging") $something = True EndIf EndFunc Func Form1Close() Exit EndFunc Func _DoSomething() $myData = GUICtrlRead($Input1) If $myData = "" Then Return False Else GUICtrlSetData($Input1, "") EndIf For $x = 1 to 5 GUICtrlSetData($Label3, _TicksToTime_ms(TimerDiff($tStart))) Sleep(1000) next EndFunc Func _TicksToTime_ms($iTicks) Local $ihms[5], $split $iTicks = $iTicks / 1000 $ihms[1] = Int($iTicks / 3600) $iTicks = Mod($iTicks, 3600) $ihms[2] = Int($iTicks / 60) $ihms[3] = Mod($iTicks, 60) $split = StringSplit( $ihms[3], ".") $ihms[4] = $split[2] Return StringFormat( "%02i:%02i:%02i", $ihms[1], $ihms[2], $ihms[3]) EndFunc ;==>_TicksToTime_ms
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