Jump to content

Pause/Resume and Time while ON to the txt


0000
 Share

Recommended Posts

Ok I found one script:

HotKeySet("{pause}","TogglePause")
HotKeySet("{home}","Start")
HotKeySet("{end}","Stop")

Global $Paused

While 1
    Sleep(25)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
    WEnd
EndFunc
Func Start()
    While NOT $Paused
        ToolTip(@HOUR&":"&@MIN&":"&@SEC,0,0,"Current time")
        Sleep(1000)
    WEnd    
EndFunc
Func Stop()
    ToolTip("bye bye!",0,0,"Current time")
    Sleep(1000)
    Exit
EndFunc

I want to add Resume/pause buttons to my program, and timer then ppl click Exit that the program will enter to txt the time of the begin..

But my program add milisecond time so it's hard to know how many hours it was working...

Can smbody give me example?

Link to comment
Share on other sites

Get away from Sleep() and use TimerInit()/TimerDiff() to track your times, then just do the math for calculating elapsed time, i.e.

#include <Date.au3>

HotKeySet("{HOME}", "_TimeIt")
HotKeySet("{END}", "_Quit")

$Timer = TimerInit()
While 1
    Sleep(20)
WEnd

Func _TimeIt()
    Dim $Hour, $Mins, $Secs
    _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
    MsgBox(64, "Time", $Hour & ":" & $Mins & ":" & $Secs)
EndFunc

Func _Quit()
    Exit
EndFunc

<_<

Edit: Actually, have _TicksToTime() do the math for you...

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok what I want..

Starting Program...

Counting time..

Pressing Pause..

Counting time stops...

Pressing Resume..

Counting timke resume from last minute..

Exitting from program...

Program creates time.txt and write all working time to file <_<

Exits

Edited by Guest
Link to comment
Share on other sites

Ok what I want..

Ok, what you need... Rent-A-Coder

My mistake, I thought you wanted help leaning to code it. You wanted someone to code it for you.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I have 50% code so i don't want to rent code.

I want to get/learn function off time adding in the txt :)

and I want to find/ask function off script pause and resume :P

When you start, it's just a matter of saving the current timeticks to a variable with TimerInit().

When you stop, as shown in my script above, TimerDiff() will give you time elapsed in 'ticks' of one millisecond.

To pause, you will have to do TimerDiff to get the elapsed ticks and save them to a separate variable.

To continue a new TimerInit will be done.

Each time you continue/pause again, add the elapsed time to second variable to keep track.

Upon stop, do a TimerDiff to get elapsed time since the last start/continue and add the accumulated times from pausing.

Code it up, and if you get stuck post your code for more help.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok one more thing what function need for adding time to txt file ?

You can just format a string variable with the time and write it to the file with FileWrite() or FileWriteLine(). If it's like a time stamp for a log entry, the use _FileWriteLog(), which adds the time stamp automatically.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok my Program not works... <_<

;Wrong code
#include <Date.au3>
#include <GuiConstants.au3>
#Include <Misc.au3>
#include <File.au3>
GUICreate("Test_Time", 150, 170)

$B1 = GUICtrlCreateButton("Test1", 35, 14, 80, 25)
$B2 = GUICtrlCreateButton("Test2", 35, 41, 80, 25)
$Bend = GUICtrlCreateButton("Exit", 35, 68, 80, 25)
$Mini = GUICtrlCreateButton("Hide me", 35, 95, 80, 25)  
$Timer = TimerInit()

GUISetState()
While 1
$msg = GUIGetMsg()
Sleep(20)
If  $msg = $B1 Or $msg = $B2 Then
    Dim $Hour, $Mins, $Secs
    _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
    MsgBox(64, "Time", $Hour & ":" & $Mins & ":" & $Secs)   
EndIf
If $msg = $Bend Then
    $file = FileOpen("time.cfg", 1)
    Sleep(50)
    FileWriteLine($file, "Line1")
            FileWriteLine($file, "Line2" & "Line4")
            FileWriteLine($file, "Line3")
    FileClose($file)
    Sleep(2000)
    Exit
EndIf
WEnd

Another problem, i don't know how to do that in the txt will write:

October 19, Friday. 0 : 0 : 18

+

another Q how to do that then i Run program it will write time to another line

Edited by Guest
Link to comment
Share on other sites

Another problem, i don't know how to do that in the txt will write:

October 19, Friday. 0 : 0 : 18

Check the help file for: _DateDayOfWeek() and _DateToMonth()

another Q how to do that then i Run program it will write time to another line

Either put a newline character at the end of the line you are writing (i.e. @CRLF), or use FileWriteLine() vice FileWrite() which adds it for you.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Why program not working? No Show, Kill, Minimize functions ?

#include <Date.au3>
#include <GuiConstants.au3>
#Include <Misc.au3>
#include <File.au3>
GUICreate("DC Prevent", 175, 300)
GuiCtrlCreateGroup("Settings", 1, 1,173,110)
GuiCtrlCreateGroup("Info", 1, 115,174,100)
GUICtrlCreateLabel(" Created by SwaDDie", 32,250, 110, 35, $SS_SUNKEN)
$B1 = GUICtrlCreateButton("PC ShutDown", 47, 15, 80, 20)
$B2 = GUICtrlCreateButton("Sound Msg", 47, 38, 80, 20)
$B3 = GUICtrlCreateButton("Two in one", 47, 61, 80, 20)
$B4 = GUICtrlCreateButton("Kill SRO", 5, 221, 165, 20)
$Bend = GUICtrlCreateButton("Exit", 47, 189, 80, 20)
$Mini = GUICtrlCreateButton("Hide me", 47, 83, 80, 20)  
$log_show = GUICtrlCreateButton ("Show", 47, 165, 80, 20)
$last = GUICtrlCreateLabel("",40,140,115,20)
$Timer = TimerInit()
$dll = DllOpen("user32.dll")
Opt("WinTitleMatchMode", 2)
While 1

GUISetState()

$msg = GUIGetMsg()
Sleep(20)
If ProcessExists ("sro_client") Then
$sLongDayName = _DateDayOfWeek( @WDAY )
$sLongMonthName = _DateToMonth(@MON)
$reg = $sLongMonthName & " " & @MDAY & ", " & $sLongDayName
GUICtrlSetData($last, $reg)
If $msg = $log_show then
        Execute("Log.log")
EndIf

;DC Prevent
;Hehe
    If $msg = $GUI_EVENT_CLOSE Or $msg = $Bend Then
    $sLongDayName = _DateDayOfWeek( @WDAY )
    $sLongMonthName = _DateToMonth(@MON)
    $reg = $sLongMonthName & " " & @MDAY & ", " & $sLongDayName
    Dim $Hour, $Mins, $Secs
    _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
    $file = FileOpen("log.log", 1)
    FileWrite($file, $reg & ". " & $Hour & "Hours" & " : " & $Mins & "Minutes" & " : " & $Secs & "Seconds" &@CRLF)
    FileClose($file)
    Sleep(5)
        Exit
    EndIf

    If $msg = $B4 Then
        if WinExists("SRO_Client") Then
            ProcessClose("sro_client.exe")
            EndIf
        EndIf
    EndIf
    If $msg = $B1 Then
    if WinExists("SRO_Client") Then
      Sleep (5000)
      WinActivate ("SRO_Client")
      Sleep (500)
        if (PixelGetColor( 400 , 330) == 0x181818) And (PixelGetColor( 649, 369) == 0x313031) Then ; DC Prevent.
            Sleep(15000)
                $sLongDayName = _DateDayOfWeek( @WDAY )
                $sLongMonthName = _DateToMonth(@MON)
                $reg = $sLongMonthName & " " & @MDAY & ", " & $sLongDayName
                Dim $Hour, $Mins, $Secs
                _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
                $file = FileOpen("log.log", 1)
                FileWrite($file, $reg & ". " & $Hour & "Hours" & " : " & $Mins & "Minutes" & " : " & $Secs & "Seconds" &@CRLF)
                FileClose($file)
                Sleep(5)
            ProcessClose("sro_client.exe")
            Sleep (15000)
            Shutdown(1)
        endIf
    endIf
    if (PixelGetColor( 535 , 708 ) == 0x00E794) Then ;Spot TP
        Sleep (60000)   
        EndIf
            if (PixelGetColor( 535 , 708 ) == 0x00E794) Then ; TP Bug Prevent
            Sleep(15000)
                $sLongDayName = _DateDayOfWeek( @WDAY )
                $sLongMonthName = _DateToMonth(@MON)
                $reg = $sLongMonthName & " " & @MDAY & ", " & $sLongDayName
                Dim $Hour, $Mins, $Secs
                _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
                $file = FileOpen("log.log", 1)
                FileWrite($file, $reg & ". " & $Hour & "Hours" & " : " & $Mins & "Minutes" & " : " & $Secs & "Seconds" &@CRLF)
                FileClose($file)
                Sleep(5)
            ProcessClose("sro_client.exe")
            Sleep (15000)
            Shutdown(1)
        endIf
        EndIf
    If $msg = $B2 Then
        If WinExists("SRO_Client") Then
      Sleep (5000)
      WinActivate ("SRO_Client")
      Sleep (500)
      EndIf
        If (PixelGetColor( 400 , 330) == 0x181818) And (PixelGetColor( 649, 369) == 0x313031) Then ; DC Prevent.
            beep(500, 5000)
            Sleep (1500)
            beep(500, 2000)
            Sleep(250)
            beep(500, 2000)
                    If _IsPressed("01", $dll) Then
                        ExitLoop
        EndIf
    EndIf
    If (PixelGetColor( 535 , 708 ) == 0x00E794) Then ;Spot TP
        Sleep (30000)   
        EndIf
            If (PixelGetColor( 535 , 708 ) == 0x00E794) Then ; TP Bug Prevent
            beep(500, 5000)
            Sleep (1500)
            beep(500, 2000)
            Sleep(250)
            beep(500, 2000)
                    If _IsPressed("01", $dll) Then
                        ExitLoop
                        EndIf
                    EndIf
    EndIf
    If $msg = $B3 Then
        If WinExists("SRO_Client") Then
      Sleep (5000)
      WinActivate ("SRO_Client")
      Sleep (500)
      EndIf
        If (PixelGetColor( 400 , 330) == 0x181818) And (PixelGetColor( 649, 369) == 0x313031) Then ; DC Prevent.
            beep(500, 5000)
            Sleep (1500)
            beep(500, 2000)
            Sleep(250)
            beep(500, 2000)
            Sleep(60000)
                $sLongDayName = _DateDayOfWeek( @WDAY )
                $sLongMonthName = _DateToMonth(@MON)
                $reg = $sLongMonthName & " " & @MDAY & ", " & $sLongDayName
                Dim $Hour, $Mins, $Secs
                _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
                $file = FileOpen("log.log", 1)
                FileWrite($file, $reg & ". " & $Hour & "Hours" & " : " & $Mins & "Minutes" & " : " & $Secs & "Seconds" &@CRLF)
                FileClose($file)
                Sleep(5)
            ProcessClose("sro_client.exe")
            Sleep (15000)
            Shutdown(1)
        EndIf
        If (PixelGetColor( 535 , 708 ) == 0x00E794) Then ;Spot TP
        Sleep (30000)   
        EndIf
            If (PixelGetColor( 535 , 708 ) == 0x00E794) Then ; TP Bug Prevent
            beep(500, 5000)
            Sleep (1500)
            beep(500, 2000)
            Sleep(250)
            beep(500, 2000)
            Sleep(60000)
                $sLongDayName = _DateDayOfWeek( @WDAY )
                $sLongMonthName = _DateToMonth(@MON)
                $reg = $sLongMonthName & " " & @MDAY & ", " & $sLongDayName
                Dim $Hour, $Mins, $Secs
                _TicksToTime(TimerDiff($Timer), $Hour, $Mins, $Secs )
                $file = FileOpen("log.log", 1)
                FileWrite($file, $reg & ". " & $Hour & "Hours" & " : " & $Mins & "Minutes" & " : " & $Secs & "Seconds" &@CRLF)
                FileClose($file)
                Sleep(5)
            ProcessClose("sro_client.exe")
            Sleep (15000)
            Shutdown(1)
        EndIf
    EndIf
WEnd
    Switch GUIGetMsg()
    Case $Mini
            WinSetState("DC Prevent", "", @SW_MINIMIZE)
            EndSwitch
DllClose($dll)
Link to comment
Share on other sites

Q1, Is any method include a lot of au3 scripts and compile them in one .exe ?

Because to read 600 lines is very hard.

#include <YourFile.au3>

Q2.What is Method to write text in vertical line, like here:

http://img150.imageshack.us/img150/599/verticalqk4.png

Good question, I don't think that is available as any kind of Style or ExStyle in AutoIt. You would probably have to create the rotated text in another app, then export it as a .gif, .jpg, or .bmp for use as an image in your GUI.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Why program not working? No Show, Kill, Minimize functions ?

Too much code to fiddle with. Can you reduce it to a short script showing just what doesn't work? What Dale calls a 'reproducer'?

(The exercise of trying to do that before posting here has lead me to the solution before I posted more than once.)

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok now everything works :) cleaned all func or another insane things...

About vertical line...

Read this, he said that I can write it :P

http://www.autoitscript.com/forum/index.php?showtopic=55446

In a word... no.

What you posted (which was a Windows toolbar), had the text rotated 90deg left:

Posted Image

I don't know of any tricks to do THAT with AutoIt, except what I posted earlier: Generate it as an image in another app.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok, is any method in AutoIt that, then someone move mouse on my created button he will se information window or pop-up like Posted Image Here

TrayTip()

"Once more unto the breach help file, dear friends, once more,

Or close the wall up with our English dead broken code!"

Henry V -- Shakespeare v3.2.8.1

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...