NutherNoob Posted January 20, 2007 Share Posted January 20, 2007 Hi everyone. I'm at a deadend with this script atm (trying to get each numbered Eg. to countdown, then start the next Eg.) and I feel its gotten abit out of hand. Can all the $vars be tidied up somehow as I want to have say 10 of these and its giving me a headache This may make it abit easier for me on the next step: countdown loop (which I have some idea of achieving). Thanx in advance. #include <GUIConstants.au3> ;master gui vars $master_gui_width = 320 $master_gui_hight = 250 $gui_master_x_start = 700 $gui_master_y_start = 120 ; variables group $default_group_width = 230 $x_var_group = 5 $y_var_group = 10 $var_group_width = $default_group_width $var_group_hight = $master_gui_hight - 100 ;positions vars group $pdefault_group_width = ($master_gui_width - $default_group_width) $px_var_group = 237 $py_var_group = 10 $pvar_group_width = $pdefault_group_width -10 $pvar_group_hight = $master_gui_hight - 100 ; = END DEFINE VARIABLES ; ===== START MASTER GUI GUICreate("=- Test -=", $master_gui_width, $master_gui_hight , $gui_master_x_start, $gui_master_y_start, -1) GUISetState () WinSetOnTop("=- Test -=", "", 1) ; MENU GuiCtrlCreateMenu("Menu &One") GuiCtrlCreateMenu("Menu &Two") GUICtrlCreateGroup ("Times", $x_var_group , $y_var_group , $var_group_width , $var_group_hight) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group GUICtrlCreateGroup ("Positions", $px_var_group , $py_var_group , $pvar_group_width , $pvar_group_hight) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group ;Hrs, secs title $widthCell=100 GUICtrlCreateLabel ("Hrs. Mins. Secs.", 50 , 40, $widthCell) ;1st eg and pos. $widthCellb=40 $diff=27 GUICtrlCreateLabel ("Eg 1.", $x_var_group +2, $y_var_group +$diff*2, $widthCellb) ; $hrs1=GUICtrlCreateInput ("", 50, ($y_var_group +$diff*2)-3, 18, 17,$ES_NUMBER) ; hrs $mins1=GUICtrlCreateInput ("", 79, ($y_var_group +$diff*2)-3, 18, 17, $ES_NUMBER) ;mins $secs1=GUICtrlCreateInput ("", 108, ($y_var_group +$diff*2)-3, 18, 17, $ES_NUMBER) ;secs $Conv1=GUICtrlCreateButton ("Convert", 137, ($y_var_group +$diff*2)-3, 45, 17) ;convert button $ttl1=GUICtrlCreateInput ("", 190, ($y_var_group +$diff*2)-3, 40, 17, $ES_NUMBER) ;secsttl $xy1=GUICtrlCreateButton("Click", 255, ($y_var_group +$diff*2)-3, 40, 17) ;2nd eg and pos. GUICtrlCreateLabel ("Eg 2.", $x_var_group +2, $y_var_group +$diff*3, $widthCellb) ; $hrs2=GUICtrlCreateInput ("", 50, ($y_var_group +$diff*3)-3, 18, 17, $ES_NUMBER) ; hrs $mins2=GUICtrlCreateInput ("", 79, ($y_var_group +$diff*3)-3, 18, 17, $ES_NUMBER) ;mins $secs2=GUICtrlCreateInput ("", 108, ($y_var_group +$diff*3)-3, 18, 17, $ES_NUMBER) ;secs $Conv2=GUICtrlCreateButton ("Convert", 137, ($y_var_group +$diff*3)-3, 45, 17) ;convert button $ttl2=GUICtrlCreateInput ("", 190, ($y_var_group +$diff*3)-3, 40, 17, $ES_NUMBER) ;secsttl $xy2=GUICtrlCreateButton("Click", 255, ($y_var_group +$diff*3)-3, 40, 17) ;3rd eg and pos. GUICtrlCreateLabel ("Eg 3.", $x_var_group +2, $y_var_group +$diff*4, $widthCellb) ; $hrs3=GUICtrlCreateInput ("", 50, ($y_var_group +$diff*4)-3, 18, 17, $ES_NUMBER) ; hrs $mins3=GUICtrlCreateInput ("", 79, ($y_var_group +$diff*4)-3, 18, 17, $ES_NUMBER) ;mins $secs3=GUICtrlCreateInput ("", 108, ($y_var_group +$diff*4)-3, 18, 17, $ES_NUMBER) ;secs $Conv3=GUICtrlCreateButton ("Convert", 137, ($y_var_group +$diff*4)-3, 45, 17) ;convert button $ttl3=GUICtrlCreateInput ("", 190, ($y_var_group +$diff*4)-3, 40, 17, $ES_NUMBER) ;secsttl $xy3=GUICtrlCreateButton("Click", 255, ($y_var_group +$diff*4)-3, 40, 17) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Conv1 $convsec1=(GuiCtrlRead($hrs1)*3600)+(GuiCtrlRead($mins1)*60)+GuiCtrlRead($secs1) GUICtrlSetData ($ttl1, $convsec1) Case $msg = $Conv2 $convsec2=(GuiCtrlRead($hrs2)*3600)+(GuiCtrlRead($mins2)*60)+GuiCtrlRead($secs2) GUICtrlSetData ($ttl2, $convsec2) Case $Msg = $Conv3 $convsec3=(GuiCtrlRead($hrs3)*3600)+(GuiCtrlRead($mins3)*60)+GuiCtrlRead($secs3) GUICtrlSetData ($ttl3, $convsec3) EndSelect WEnd Link to comment Share on other sites More sharing options...
NutherNoob Posted January 20, 2007 Author Share Posted January 20, 2007 Should have been more explicit; I'd like the $vars: $hrs,$mins,$secs,$conv1 etc cleaned up as there'll be about 10 Eg.'s I want to add. Cheers Link to comment Share on other sites More sharing options...
BigDod Posted January 20, 2007 Share Posted January 20, 2007 When you post script could you please use [ autoit ] Script [ /autoit ] without the spaces, as this makes it easier to read. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
NutherNoob Posted January 20, 2007 Author Share Posted January 20, 2007 Sorry will try again...... expandcollapse popup#include <GUIConstants.au3> ;master gui vars $master_gui_width = 320 $master_gui_hight = 250 $gui_master_x_start = 700 $gui_master_y_start = 120 ; variables group $default_group_width = 230 $x_var_group = 5 $y_var_group = 10 $var_group_width = $default_group_width $var_group_hight = $master_gui_hight - 100 ;positions vars group $pdefault_group_width = ($master_gui_width - $default_group_width) $px_var_group = 237 $py_var_group = 10 $pvar_group_width = $pdefault_group_width -10 $pvar_group_hight = $master_gui_hight - 100 ; = END DEFINE VARIABLES ; ===== START MASTER GUI GUICreate("=- Test -=", $master_gui_width, $master_gui_hight , $gui_master_x_start, $gui_master_y_start, -1) GUISetState () WinSetOnTop("=- Test -=", "", 1) ; MENU GuiCtrlCreateMenu("Menu &One") GuiCtrlCreateMenu("Menu &Two") GUICtrlCreateGroup ("Times", $x_var_group , $y_var_group , $var_group_width , $var_group_hight) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group GUICtrlCreateGroup ("Positions", $px_var_group , $py_var_group , $pvar_group_width , $pvar_group_hight) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group ;Hrs, secs title $widthCell=100 GUICtrlCreateLabel ("Hrs. Mins. Secs.", 50 , 40, $widthCell) ;1st eg and pos. $widthCellb=40 $diff=27 GUICtrlCreateLabel ("Eg 1.", $x_var_group +2, $y_var_group +$diff*2, $widthCellb) ; $hrs1=GUICtrlCreateInput ("", 50, ($y_var_group +$diff*2)-3, 18, 17,$ES_NUMBER) ; hrs $mins1=GUICtrlCreateInput ("", 79, ($y_var_group +$diff*2)-3, 18, 17, $ES_NUMBER) ;mins $secs1=GUICtrlCreateInput ("", 108, ($y_var_group +$diff*2)-3, 18, 17, $ES_NUMBER) ;secs $Conv1=GUICtrlCreateButton ("Convert", 137, ($y_var_group +$diff*2)-3, 45, 17) ;convert button $ttl1=GUICtrlCreateInput ("", 190, ($y_var_group +$diff*2)-3, 40, 17, $ES_NUMBER) ;secsttl $xy1=GUICtrlCreateButton("Click", 255, ($y_var_group +$diff*2)-3, 40, 17) ;2nd eg and pos. GUICtrlCreateLabel ("Eg 2.", $x_var_group +2, $y_var_group +$diff*3, $widthCellb) ; $hrs2=GUICtrlCreateInput ("", 50, ($y_var_group +$diff*3)-3, 18, 17, $ES_NUMBER) ; hrs $mins2=GUICtrlCreateInput ("", 79, ($y_var_group +$diff*3)-3, 18, 17, $ES_NUMBER) ;mins $secs2=GUICtrlCreateInput ("", 108, ($y_var_group +$diff*3)-3, 18, 17, $ES_NUMBER) ;secs $Conv2=GUICtrlCreateButton ("Convert", 137, ($y_var_group +$diff*3)-3, 45, 17) ;convert button $ttl2=GUICtrlCreateInput ("", 190, ($y_var_group +$diff*3)-3, 40, 17, $ES_NUMBER) ;secsttl $xy2=GUICtrlCreateButton("Click", 255, ($y_var_group +$diff*3)-3, 40, 17) ;3rd eg and pos. GUICtrlCreateLabel ("Eg 3.", $x_var_group +2, $y_var_group +$diff*4, $widthCellb) ; $hrs3=GUICtrlCreateInput ("", 50, ($y_var_group +$diff*4)-3, 18, 17, $ES_NUMBER) ; hrs $mins3=GUICtrlCreateInput ("", 79, ($y_var_group +$diff*4)-3, 18, 17, $ES_NUMBER) ;mins $secs3=GUICtrlCreateInput ("", 108, ($y_var_group +$diff*4)-3, 18, 17, $ES_NUMBER) ;secs $Conv3=GUICtrlCreateButton ("Convert", 137, ($y_var_group +$diff*4)-3, 45, 17) ;convert button $ttl3=GUICtrlCreateInput ("", 190, ($y_var_group +$diff*4)-3, 40, 17, $ES_NUMBER) ;secsttl $xy3=GUICtrlCreateButton("Click", 255, ($y_var_group +$diff*4)-3, 40, 17) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Conv1 $convsec1=(GuiCtrlRead($hrs1)*3600)+(GuiCtrlRead($mins1)*60)+GuiCtrlRead($secs1) GUICtrlSetData ($ttl1, $convsec1) Case $msg = $Conv2 $convsec2=(GuiCtrlRead($hrs2)*3600)+(GuiCtrlRead($mins2)*60)+GuiCtrlRead($secs2) GUICtrlSetData ($ttl2, $convsec2) Case $Msg = $Conv3 $convsec3=(GuiCtrlRead($hrs3)*3600)+(GuiCtrlRead($mins3)*60)+GuiCtrlRead($secs3) GUICtrlSetData ($ttl3, $convsec3) EndSelect WEnd Link to comment Share on other sites More sharing options...
NutherNoob Posted January 20, 2007 Author Share Posted January 20, 2007 Anyone......... please? Link to comment Share on other sites More sharing options...
LxP Posted January 20, 2007 Share Posted January 20, 2007 Anyone......... please?It's generally not good form to bump your own posts unless you've waited at least a couple days. This should get you started: expandcollapse popup#include <GUIConstants.au3> ;master gui vars $master_gui_width = 320 $master_gui_hight = 250 ; variables group $default_group_width = 230 $x_var_group = 5 $y_var_group = 10 $var_group_width = $default_group_width $var_group_hight = $master_gui_hight - 100 ;positions vars group $pdefault_group_width = ($master_gui_width - $default_group_width) $px_var_group = 237 $py_var_group = 10 $pvar_group_width = $pdefault_group_width -10 $pvar_group_hight = $master_gui_hight - 100 ; = END DEFINE VARIABLES ; ===== START MASTER GUI GUICreate("=- Test -=", $master_gui_width, $master_gui_hight , -1, -1, -1) GUISetState () WinSetOnTop("=- Test -=", "", 1) ; MENU GuiCtrlCreateMenu("Menu &One") GuiCtrlCreateMenu("Menu &Two") GUICtrlCreateGroup ("Times", $x_var_group , $y_var_group , $var_group_width , $var_group_hight) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group GUICtrlCreateGroup ("Positions", $px_var_group , $py_var_group , $pvar_group_width , $pvar_group_hight) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group ;Hrs, secs title $widthCell=100 GUICtrlCreateLabel ("Hrs. Mins. Secs.", 50 , 40, $widthCell) Local Const $NumTimeFields = 3 Local $HourFields[$NumTimeFields] Local $MinuteFields[$NumTimeFields] Local $SecondFields[$NumTimeFields] Local $ConvertButtons[$NumTimeFields] Local $ConversionFields[$NumTimeFields] Local $ClickButtons[$NumTimeFields] $widthCellb=40 $diff=27 For $I = 0 To $NumTimeFields - 1 Local $Y = $y_var_group + $diff * ($I + 2) - 3 Local $Label = 'Eg ' & $I + 1 & '.' GUICtrlCreateLabel($Label, $x_var_group + 2, $Y + 3, $widthCellb) $HourFields[$I] = GUICtrlCreateInput('', 50, $Y, 18, 17, $ES_NUMBER) $MinuteFields[$I] = GUICtrlCreateInput('', 79, $Y, 18, 17, $ES_NUMBER) $SecondFields[$I] = GUICtrlCreateInput('', 108, $Y, 18, 17, $ES_NUMBER) $ConversionFields[$I] = GUICtrlCreateInput('', 190, $Y, 40, 17, $ES_NUMBER) $ConvertButtons[$I] = GUICtrlCreateButton('Convert', 137, $Y, 45, 17) $ClickButtons[$I] = GUICtrlCreateButton('Click', 255, $Y, 40, 17) Next GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect For $I = 0 To $NumTimeFields - 1 If $msg = $ConvertButtons[$I] Then Local $ConversionValue _ = GUICtrlRead($HourFields[$I]) * 3600 _ + GUICtrlRead($MinuteFields[$I]) * 60 _ + GUICtrlRead($SecondFields[$I]) GUICtrlSetData($ConversionFields[$I], $ConversionValue) EndIf Next WEnd Here are some tips:Adjust $NumTimeFields to increase/decrease the number of rows that get created.Indenting code within Select and While loops makes the logic easier to follow.Meaningful variable names make things easier to understand.You should always declare your variables with Local.I would suggest modifying the code so that the dialogue box is dynamically sized according to how many rows show up. Example: what happens right now if you set $NumTimeFields to 5? 10? Link to comment Share on other sites More sharing options...
NutherNoob Posted January 20, 2007 Author Share Posted January 20, 2007 Thanx LxP. Wont do it again. Thought maybe I'd posted in the wrong forum too, so double posted (and rightfully got flamed). I'm new to scripting and forum etiquette but I'm getting there. Thanx again. Link to comment Share on other sites More sharing options...
LxP Posted January 21, 2007 Share Posted January 21, 2007 Discussion on this topic should probably continue in its other thread... Link to comment Share on other sites More sharing options...
Recommended Posts