Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   has this been done? (https://thetfp.com/tfp/tilted-technology/34777-has-been-done.html)

junglistic 11-07-2003 06:59 AM

has this been done?
 
a stupid little program where you can input a $ per hour amount and it counts in real time how much $ is adding up as time goes by?

it would be some nice inspiration to those at work :)

numist 11-07-2003 07:10 AM

if it hasnt been written, it doesnt look like it would be very difficult to write at all.

Just ask one of the other coders here, and perhaps you may get something.

If I have time in the next week, I'll have a crack at it.

Fallon 11-07-2003 07:31 AM

That'd be pretty easy. If I wasn't at work, I'd see if I could throw somethin together, but I am. What'd be even better is if it took out taxes and the like beforehand =p. Ugh, damn you...=p
All of a sudden, my brain is thinking about many different things that could be added, like if theres direct deposit, how much will go into it, if you have it split, how much will go into both. I wanna go home now...

junglistic 11-07-2003 07:34 AM

well it has been quite slow at work lately. Ive averaged out a net $/hr after taxes and what from my last few pay's. So if i could just put in a $/hr or even $/sec and it just counted it in realtime that'd be perfect.

im sure someone has done it before, or could do something up

f00sion 11-07-2003 08:53 AM

A search engine consultant friend of mine uses something like that to keep track of his time spent on the phone... he puts $400/hour in the box and hits the start button at the beginning of the call and the end button when it is done then he can bill the client for the exact amount of time... i will email him and ask him what the name of the program is.

junglistic 11-07-2003 10:01 AM

Quote:

Originally posted by f00sion
A search engine consultant friend of mine uses something like that to keep track of his time spent on the phone... he puts $400/hour in the box and hits the start button at the beginning of the call and the end button when it is done then he can bill the client for the exact amount of time... i will email him and ask him what the name of the program is.
thanks, just post it up if you can find a name or link for the app.

:)

arch13 11-07-2003 10:12 AM

It's more money than you'd care to spend but the design and law standard program Timeslips does this and breaks it down into what each task or job was worth.
Perfect for keeping track of what i've done for a client and what i bill each client since they all are on different rates.

junglistic 11-10-2003 05:45 AM

ttt for the monday mornin crew

Fallon 11-10-2003 11:38 AM

Tonight, I'm gonna make myself a program that I can turn on when I start work, and when I finish, but it won't have a running counter, if you want a copy, get the .NET Framework 1.1, and when I'm done I'll see if I can send it.
What it'll do is hopefully write the start time, and when you click again, the end time, it'll save that to a file, if you want, you can then total the day, and get the hours and such. I'm sure the extras could be added, such as taxes and such. For me, it became a need after I did my timecard today so =p.

yellowgowild 11-11-2003 07:32 PM

If you do write that program, check for any patents and then license the feature to watch companies. Then remember me :)

numist 11-11-2003 07:37 PM

$400 per hour? ask him not only for the program, but if I can have his job!

rock_bottom 11-11-2003 07:51 PM

We have an in-house program (very antiquated and shell-based, but it works). My hourly rate is $85/hour... at least that's what clients pay. If only that was what my actual wage was :-)

f00sion 11-12-2003 09:41 AM

Quote:

Originally posted by numist
$400 per hour? ask him not only for the program, but if I can have his job!
yeah no kidding, he is good at what he does, but unless it involves a reacharound i would not pay that much.

MontanaXVI 11-13-2003 12:10 AM

i seen something similar to this but it was java based and calculated how much texas rangers shortstop alex rodriguez made per hour minute second of each day on his 10 year 100+ million dollar contract never been able to find it again

yellowgowild 11-16-2003 01:36 AM

Computer experts are a dime a dozen these days, thats why they don't make as much as they used to.

charliex 11-16-2003 10:54 PM

Here you go, its still a work in progress, but i think it works

http://www.finitemonkeys.com/tfp/waiw.zip

havent tested it outside XP, a lot of the shell stuff changed on 2000 and XP, so it probably doesn't work pre 2k and possibly not even pre XP,..

yes in fact i just tried in my 2k advanced server and it started up but looked like it failed on something later. so i'll check to see what stuff i have to add to make it work pre XP.

its pretty simple, defaults to 100 err units, you can change it easily enough, select start to start it, change to change it and quit to exit, it updates every 1 minute.

if you have XP play with it, see if it does what you want it to do, and i'll fix the bugs, like the one where it might in fact be showing 10x the earnings :) its what we like to call a one level demo

junglistic 11-17-2003 05:25 AM

link seems to be down for me.

btw, im running 2k pro at work, so hopefully i can get it working.

charliex 11-17-2003 10:25 AM

hmm thats odd, the whole tfp directory disappeared, i wonder if my isp didnt like my version of secretemethods avatar.

anyway should be ok now, some definite wierdness going on there.

charliex 11-19-2003 10:47 PM

I upated it again and added the code ( should run at the right rate )

if this posts right, i'll be very suprised :) (ok edit for disable smileys, i bet when they came up with :DWORD they werent expecting cheesy grins , dunno about the double line feed though, try small size)


Code:


    .386
    .model flat, stdcall
    option casemap:none

;===============================================================================================
; include
;===============================================================================================

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\shell32.inc

    include \MASM32\include\gdi32.inc
    include \MASM32\include\MASM32.inc
    include \MASM32\INCLUDE\advapi32.inc
   
;===============================================================================================
; libs
;===============================================================================================

    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\shell32.lib
    includelib \masm32\lib\gdi32.lib

    includelib \MASM32\lib\gdi32.lib
    includelib \MASM32\lib\MASM32.lib
    includelib \MASM32\LIB\advapi32.lib
   
;===============================================================================================
; prototypes
;===============================================================================================

    main        PROTO :DWORD
    SetBmpColor PROTO :DWORD
    GetRateProc PROTO :HWND,:DWORD,:WPARAM,:LPARAM
        Float2ASCII PROTO
        CalcRate2        PROTO

;===============================================================================================
; macros
;===============================================================================================

        LOWORD        MACRO        bigword        ;; Retrieves the low word from double word argument

                mov        eax,bigword
                and        eax,0FFFFh        ;; Set to low word

                ENDM

        return MACRO arg
       
                mov eax, arg
        ret
               
                ENDM


;===============================================================================================
; defines
;===============================================================================================

.const
    WM_SHELLNOTIFY  equ WM_USER+5
    IDI_TRAY        equ 0

; icon resource number
    ProgIcon        equ 100

; menu ID's
    IDM_Pause      equ 1005
    IDM_Stop        equ 1004
    IDM_Start      equ 1003
    IDM_ChangeRate  equ 1002

; standard items

    IDM_AboutBox    equ 1001
    IDM_Quit        equ 1000


    IDB_Pause      equ 10002
    IDB_AboutBox    equ 10001
    IDB_Quit        equ 10000


        IDC_DOLLARS    equ 1000
        IDC_CENTS      equ 1001
        ID_OK                        equ 1003
        IDD_RATE                equ        9; ; hmm how did i manage that one

    Count                        equ 14
   
; simple state

        STATE_STOPPED        equ        1
        STATE_STARTED        equ        2
        STATE_PAUSED        equ        3
        STATE_ABOUT                equ        4

;===============================================================================================
; const non bss data
;===============================================================================================
.data

        currentState        db STATE_STOPPED

    ProcessInfo        PROCESS_INFORMATION <>

; ---------------------------------

    ClassName      db "WaiwWinClass", 0
    ProgramName    db "WAIW", 0
        NotRunningText        db "Stopped", 0

; ---------------------------------

    SetHourlyText  db "&Change hourly rate", 0
    StartText      db "&Start", 0
    StopText        db "S&top", 0
    PauseText      db "&Pause", 0
   
; ---------------------------------

    AboutBoxTitle    db "About", 0
    AboutBoxText    db "WAIW, Copyright © 2003 charliex, root@charliex.net", 0
; ---------------------------------

    QuitText        db "&Quit", 0
        ConfirmText      db "Are you sure you wish to quit ?", 0

; ---------------------------------

    ChangeRateText  db "Changing rate", 0
    StartedText      db "Running", 0
    PausedText      db "Paused", 0


        div60          dd 03c888889h
        div2                        dd 03c23d70ah

        fipaddcon                dd 000000000h,04f800000h

        startMS          dd 0
        milliSeconds    dd 0
    startTime        dd 0

; rate per hour
        ratePerHour      dd 100
       
; how much made so far
        made            REAL4 0.0

; internal calcs, exposed for debugging
        rph            REAL4 0.0
; temp buff
    buffer          db 255 dup (0)


;===============================================================================================
;  non const data
;===============================================================================================

ETDBuffer db "ETD : $"
ETDData db  128 dup (0)

;===============================================================================================
;  non const bss data
;===============================================================================================
.data?

    hInstance      dd ?
    note            NOTIFYICONDATA <>
    StatusInfo      db ?

    hPopupMenu      dd ?

    hBmp1          dd ?        ; bitmap handle
    IDM            dd ?        ; menu number id
    IDB            dd ?        ; menu bitmap id


;===============================================================================================
; code
;===============================================================================================
.code

code:

    invoke GetModuleHandle, NULL
    mov    hInstance, eax

; call our main
    invoke main, hInstance


    invoke ExitProcess, eax

;===============================================================================================
; WinMain
;===============================================================================================

main PROC hInst:HINSTANCE

    LOCAL WindowClass : WNDCLASSEX
    LOCAL Msg        : MSG
    LOCAL hWindow    : HWND

    mov    WindowClass.cbSize, SIZEOF WNDCLASSEX
    mov    WindowClass.style, CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS
    mov    WindowClass.lpfnWndProc, OFFSET WindowProc
    mov    WindowClass.cbClsExtra, NULL
    mov    WindowClass.cbWndExtra, NULL

    push  hInst
    pop    WindowClass.hInstance

    mov    WindowClass.hbrBackground, COLOR_APPWORKSPACE
    mov    WindowClass.lpszMenuName, NULL
    mov    WindowClass.lpszClassName, OFFSET ClassName

; load icon

    invoke LoadIcon, hInstance, ProgIcon
    mov    WindowClass.hIcon, eax
    mov    WindowClass.hIconSm, eax

    invoke LoadCursor, hInstance, IDC_ARROW
    mov    WindowClass.hCursor, eax

    invoke RegisterClassEx, ADDR WindowClass

    invoke CreateWindowEx, WS_EX_CLIENTEDGE, ADDR ClassName, ADDR ProgramName,\
                          0, \
                          CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL,\
                          hInst, NULL
    mov    hWindow, eax


; process message pump
    .while TRUE
   
            invoke GetMessage, ADDR Msg, NULL, 0, 0
            .BREAK .IF (!eax)
            invoke TranslateMessage, ADDR Msg
            invoke DispatchMessage, ADDR Msg

    .endw

    mov    eax, Msg.wParam
    ret

main ENDP

;===============================================================================================
; WindowProc
;===============================================================================================

WindowProc PROC hWindow:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

    LOCAL pt          : POINT
    LOCAL StartInfo    : STARTUPINFO
        LOCAL hWnd : HWND
        LOCAL Nb: QWORD

.code

    .if uMsg==WM_CREATE

        invoke CreatePopupMenu
        mov    hPopupMenu, eax

        invoke AppendMenu, hPopupMenu, MF_STRING, IDM_Start, ADDR StartText
        invoke AppendMenu, hPopupMenu, MF_STRING, IDM_Stop, ADDR StopText
        invoke AppendMenu, hPopupMenu, MF_STRING, IDM_Pause, ADDR PauseText
        invoke AppendMenu, hPopupMenu, MF_STRING, IDM_ChangeRate, ADDR SetHourlyText
          invoke AppendMenu, hPopupMenu, MF_SEPARATOR, NULL, NULL

        invoke AppendMenu, hPopupMenu, MF_STRING, IDM_AboutBox , ADDR AboutBoxTitle
          invoke AppendMenu, hPopupMenu, MF_SEPARATOR, NULL, NULL

        invoke AppendMenu, hPopupMenu, MF_STRING, IDM_Quit  , ADDR QuitText


        mov    ecx, Count
        mov    IDB, IDB_Quit
        mov    IDM, IDM_Quit
    loadBitmaps:
        push  ecx

            invoke LoadBitmap, hInstance, IDB

            mov    hBmp1, eax
          invoke SetBmpColor, hBmp1
          mov    hBmp1, eax
            invoke SetMenuItemBitmaps, hPopupMenu, IDM, MF_BYCOMMAND, hBmp1, hBmp1

        pop    ecx
        inc    IDB
        inc    IDM

    LOOP loadBitmaps

        mov    note.cbSize, SIZEOF NOTIFYICONDATA

        push  hWindow
        pop    note.hwnd

        mov    note.uID, IDI_TRAY
        mov    note.uFlags, NIF_ICON+NIF_MESSAGE+NIF_TIP
        mov    note.uCallbackMessage, WM_SHELLNOTIFY
        invoke LoadIcon, hInstance, ProgIcon                         
        mov    note.hIcon, eax
           

; set the program tool trap icons tool tip

          invoke lstrcpy, ADDR note.szTip, ADDR NotRunningText

          invoke Shell_NotifyIcon, NIM_ADD, ADDR note

    .elseif uMsg==WM_COMMAND

        .if lParam==0

                mov    eax, wParam

            .if ax==IDM_Quit
           
                invoke MessageBox, NULL, ADDR ConfirmText, ADDR ProgramName, MB_YESNO or MB_ICONINFORMATION

                .if eax==IDNO
                    invoke Shell_NotifyIcon, NIM_ADD, ADDR note
                .else
                    invoke DestroyWindow, hWindow
                .endif
               
                .elseif ax==IDM_AboutBox

                cmp    StatusInfo, 1
                jz    menu

                inc    StatusInfo

                invoke LoadIcon, NULL, IDI_INFORMATION
                mov    note.hIcon, eax
                                invoke lstrcpy, ADDR note.szTip, ADDR AboutBoxTitle
                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note

                invoke LoadIcon, hInstance, ProgIcon
                invoke ShellAbout, NULL,ADDR AboutBoxTitle, ADDR AboutBoxText, eax

                dec    StatusInfo

; change this to show the current status instead.

;;                            invoke lstrcpy, ADDR note.szTip, ADDR NotRunningText
                invoke LoadIcon, hInstance, ProgIcon
                mov    note.hIcon, eax
                               

                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note

            menu:
           
            .elseif ax==IDM_ChangeRate

       

; popup a dialog asking use to set the hourly rate

                                invoke lstrcpy, ADDR note.szTip, ADDR ChangeRateText
                                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note


                        invoke DialogBoxParam, hInstance, IDD_RATE,0,ADDR GetRateProc,NULL       


            .elseif ax==IDM_Stop

; stop counting
                                invoke lstrcpy, ADDR note.szTip, ADDR NotRunningText

                                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note

                                invoke KillTimer, hWnd, 0


            .elseif ax==IDM_Start
       
; get the current ms counter

                        invoke GetTickCount

; clear up old one not needed anymore

                        mov                startMS, eax
                        mov                startTime,eax

; start of a windows timer for n seconds

                        invoke SetTimer,hWindow,NULL,(1*60)*1000,NULL  ; Set the timer to 60000 mSec (1 min)

; start counting
                                invoke lstrcpy, ADDR note.szTip, ADDR StartedText

                                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note

            .elseif ax==IDM_Stop

; pause counting
                                invoke lstrcpy, ADDR note.szTip, ADDR PausedText

                                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note

                                invoke KillTimer, hWnd, 0

                        .endif

        .endif

    .elseif uMsg==WM_SHELLNOTIFY
   
        .if wParam==IDI_TRAY
            .if (lParam==WM_LBUTTONDOWN) || (lParam==WM_RBUTTONDOWN)
           
; popup menu
                invoke GetCursorPos, ADDR pt
                invoke TrackPopupMenu, hPopupMenu, TPM_LEFTALIGN, pt.x, pt.y, NULL, hWindow, NULL

                        .endif
        .endif

    .elseif uMsg==WM_TIMER

; temp test, remove later !! :)

;                                mov ratePerHour,600

; calculate                               

                                invoke CalcRate2

; convert current amount made from float to ascii,


                                lea esi,made
                                fld dword ptr [esi]
                                fstp [Nb]

                                invoke FloatToStr, [Nb], ADDR ETDData
 
; invoke DebugPrint, addr ETDBuffer

                                invoke lstrcpy, ADDR note.szTip, ADDR ETDBuffer

                                invoke OutputDebugStringA, ADDR ETDBuffer
                                invoke Shell_NotifyIcon, NIM_MODIFY, ADDR note

    .elseif uMsg==WM_DESTROY

; quit
        invoke Shell_NotifyIcon, NIM_DELETE, ADDR note
        invoke PostQuitMessage, NULL
        return 0
       
    .endif

    invoke DefWindowProc, hWindow, uMsg, wParam, lParam
    ret

WindowProc ENDP

;===============================================================================================
; SetBmpColor
;===============================================================================================
SetBmpColor proc hBitmap:DWORD

    LOCAL mDC      :DWORD
    LOCAL hBrush    :DWORD
    LOCAL hOldBmp  :DWORD
    LOCAL hReturn  :DWORD
    LOCAL hOldBrush :DWORD

    invoke CreateCompatibleDC, NULL
    mov    mDC, eax

    invoke SelectObject, mDC, hBitmap
    mov hOldBmp, eax

    invoke GetSysColor, COLOR_BTNFACE
    invoke CreateSolidBrush, eax
    mov hBrush, eax

    invoke SelectObject, mDC, hBrush
    mov hOldBrush, eax

    invoke GetPixel,mDC, 1, 1
    invoke ExtFloodFill, mDC, 1, 1, eax, FLOODFILLSURFACE

    invoke SelectObject, mDC, hOldBrush
    invoke DeleteObject, hBrush

    invoke SelectObject, mDC, hBitmap
    mov    hReturn, eax
    invoke DeleteDC, mDC

    mov eax, hReturn

  ret

SetBmpColor endp


;===============================================================================================
; GetRateProc
;===============================================================================================
GetRateProc proc hDlg:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM

        LOCAL        rateDollars:DWORD
        LOCAL        rateCents:DWORD

        mov  eax,iMsg

        .if    eax==WM_INITDIALOG

        .elseif eax==WM_COMMAND

                LOWORD wParam

                .if eax==ID_OK

                        invoke  GetDlgItemInt, hDlg,IDC_DOLLARS,NULL,0
                        mov  rateDollars,eax

; convert to p
                        mov ebx,100
                        mul        ebx
                        mov    ratePerHour,eax

                        invoke  GetDlgItemInt, hDlg,IDC_CENTS,NULL,0
                        mov  rateCents,eax

; add to dollarrs for one figure in units
                        add  ratePerHour,eax

                        invoke  EndDialog,hDlg,TRUE

                .elseif eax==IDCANCEL

                        invoke  EndDialog,hDlg,FALSE

                .endif

        .else
                        mov eax,FALSE
                        ret
        .endif

        mov  eax,TRUE

        ret

GetRateProc endp


;===============================================================================================
; Float2ASCII - Convert a float to an ASCIZ string
;===============================================================================================
Float2ASCII proc   

        LOCAL Nb:QWORD
       

        fld QWORD PTR [esi]
        fstp [Nb]

        invoke FloatToStr, [Nb], ADDR ETDData


        ret

Float2ASCII endp


;===============================================================================================
; CalcRate2 - Calculate how much has been earnt since started.
;===============================================================================================
CalcRate2        proc

; use a local!!

        sub      esp, 8                                     

;        ms = GetTickCount()-startTime;

; get current ms counter
        invoke GetTickCount

; eax = edx = ms
        mov      edx, eax                                     

;        rph = rateperhour

        fild      dword ptr ratePerHour

; this really only needs to be done everytime the rate is updated or at start
;        rph = rph/100.0

        fmul      dword ptr div2

; get start time in ms
        mov      ecx, dword ptr startTime                   

;        made = rph * (( ms/60.0)/60.0)

        fld      dword ptr div60                 
        fxch      st(1)       

; store as float / 100.0
                               
        fst      dword ptr rph

; ms = current - last

        sub      edx, ecx                                     

        mov      eax, 274877907                               
        mul      edx                                         
        shr      edx, 6                                       

; store secs count (for debug) yes yes i know it says ms, its milli vanilli seconds

        mov      dword ptr milliSeconds, edx                           

; now do the actual math
        mov      dword ptr [esp], edx                         
        fild      dword ptr [esp]                             
        shr      edx, 31                                     
        fadd      dword ptr fipaddcon[0+edx*4]       
        fmul      st, st(2)                                   
        fmulp    st(2), st                                   
        fmulp    st(1), st 
                                                 
; store the amount calculated
        fstp      dword ptr made   

; use a local!

        add      esp, 8                                       
        ret


                CalcRate2        endp



                         

        end  code


junglistic 11-20-2003 06:33 AM

well done, works perfect charlie.

cant thank you enuff :)


All times are GMT -8. The time now is 05:44 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360