Cronometro, by me and Mhack

« Older   Newer »
  Share  
Dragon[ITA]
CAT_IMG Posted on 9/5/2010, 09:41     +1   -1




Visto che non mi andava di fare una nuova gui, ho preso quella di MHack e ho corretto il codice del timer...
spero non ti dispiaccia.


CODICE
#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
;gui create
$gui = GUICreate("Cronometro",270,350,-1,-1)
GUISetState(@SW_SHOW)


;lista
$list = GUICtrlCreateListView("Tempo              ",5,5,250,280)


;label
$labelcount = GUICtrlCreateLabel("",90,295,75,21)
GUICtrlSetColor(-1,0xFF0000)
$ora = GUICtrlCreateLabel(@HOUR&":"&@MIN,5,330,30,15)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)
$crono = GUICtrlCreateLabel("",215,330,50,15)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)


;hotkey
HotKeySet("{SPACE}","_Giro")
HotKeySet("{ENTER}","_Stop")



;button
$split = GUICtrlCreateButton("Giro",8,290,75,25)
$stop = GUICtrlCreateButton("Stop",184,288,75,25)
$go = GUICtrlCreateButton("Vai",96,320,75,25)

$timer = TimerInit()
$count = 0
$titletimer = TimerInit()

While 1
      $nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
      Exit
  Case $split
          If String($timer) <> "stopped" Then
                       _Giro()
          EndIf
Case $go
      GUICtrlSetData($crono," started")
      $timer = TimerInit()
EndSwitch
If TimerDiff($titletimer) >=100 Then
       _title()
EndIf
WEnd

Func _title()
       $tmp = TimerDiff($timer)
       $sec = $tmp /1000
       $min = 0
       $hour = 0
       If $sec >= 60 Then
               For $i = 0 To $sec Step 60
                       $min +=1
                       $sec -= 60
               Next
       EndIf
       If $min >= 60 Then
               For $i = 0 To $min Step 60
                       $hour +=1
                       $min -= 60
               Next
       EndIf
       WinSetTitle($gui,"","Cronometro "&$hour&":"&$min&":"&$sec)
EndFunc

Func _Giro()
       $count+=1
       $tmp = TimerDiff($timer)
       $sec = $tmp /1000
       $min = 0
       $hour = 0
       If $sec >= 60 Then
               For $i = 0 To $sec Step 60
                       $min +=1
                       $sec -= 60
               Next
       EndIf
       If $min >= 60 Then
               For $i = 0 To $min Step 60
                       $hour +=1
                       $min -= 60
               Next
       EndIf
      GUICtrlSetData($labelcount,$count&"°")
      _GUICtrlListView_AddItem($list,$count&"°"&" - "&$hour&":"&$min&":"&$sec)
EndFunc


Func _Stop()
      $timer = "stopped"
          GUICtrlSetData($crono," ")
EndFunc


By Dragon[ITA] & MHack
 
Top
lollofieretto
CAT_IMG Posted on 9/5/2010, 10:07     +1   -1




carino... ma cè un bug:
quando schiacci stop non succede niente però se schiacci enter + o - si stoppa
 
Top
VforVentordici
CAT_IMG Posted on 9/5/2010, 18:06     +1   -1




Good ;) come ha detto lollofieretto c'è quella piccolina cosa da mettere a posto ;)
 
Top
lollofieretto
CAT_IMG Posted on 10/5/2010, 15:25     +1   -1




trovato l'errore ... ti 6 dimenticato il " case $stop" ecco la versione senza bug

SPOILER (click to view)
#include <buttonconstants.au3>
#include <guiconstants.au3>
#include <guilistview.au3>
#include <windowsconstants.au3>
;gui create
$gui = GUICreate("Cronometro",270,350,-1,-1)
GUISetState(@SW_SHOW)


;lista
$list = GUICtrlCreateListView("Tempo ",5,5,250,280)


;label
$labelcount = GUICtrlCreateLabel("",90,295,75,21)
GUICtrlSetColor(-1,0xFF0000)
$ora = GUICtrlCreateLabel(@HOUR&":"&@MIN,5,330,30,15)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)
$crono = GUICtrlCreateLabel("",215,330,50,15)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xFFFFFF)


;hotkey
HotKeySet("{SPACE}","_Giro")
HotKeySet("{ENTER}","_Stop")



;button
$split = GUICtrlCreateButton("Giro",8,290,75,25)
$stop = GUICtrlCreateButton("Stop",184,288,75,25)
$go = GUICtrlCreateButton("Vai",96,320,75,25)

$timer = TimerInit()
$count = 0
$titletimer = TimerInit()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $split
If String($timer) <> "stopped" Then
_Giro()
EndIf
Case $go
GUICtrlSetData($crono," started")
$timer = TimerInit()
case $stop
$timer = "stopped"
GUICtrlSetData($crono," ")
EndSwitch
If TimerDiff($titletimer) >=100 Then
_title()
EndIf
WEnd

Func _title()
$tmp = TimerDiff($timer)
$sec = $tmp /1000
$min = 0
$hour = 0
If $sec >= 60 Then
For $i = 0 To $sec Step 60
$min +=1
$sec -= 60
Next
EndIf
If $min >= 60 Then
For $i = 0 To $min Step 60
$hour +=1
$min -= 60
Next
EndIf
WinSetTitle($gui,"","Cronometro "&$hour&":"&$min&":"&$sec)
EndFunc

Func _Giro()
$count+=1
$tmp = TimerDiff($timer)
$sec = $tmp /1000
$min = 0
$hour = 0
If $sec >= 60 Then
For $i = 0 To $sec Step 60
$min +=1
$sec -= 60
Next
EndIf
If $min >= 60 Then
For $i = 0 To $min Step 60
$hour +=1
$min -= 60
Next
EndIf
GUICtrlSetData($labelcount,$count&"°")
_GUICtrlListView_AddItem($list,$count&"°"&" - "&$hour&":"&$min&":"&$sec)
EndFunc

Func _Stop()
$timer = "stopped"
GUICtrlSetData($crono," ")
EndFunc
 
Top
MHack
CAT_IMG Posted on 10/5/2010, 15:53     +1   -1




No, non mi dispiace affatto ;) Anzi, grazie di averlo "corretto"
 
Top
4 replies since 9/5/2010, 09:41   445 views
  Share