1

Konu: uygulamayı kapatmak

belli bir süre klavye ve mouse kullanılmadığını nasıl anlarım?
kullanılmadığında programı otomotik sonlandırmak istiyorum.  kullanıcının nekadar süreyle klavye yi kullanmadığını nasıl tesbit ederim?

2

Re: uygulamayı kapatmak

CHRSAW([nSeconds])



Parameters
nSeconds


Specifies the time in seconds that CHRSAW( ) waits before checking the keyboard buffer. The keyboard buffer is checked immediately if you omit nSeconds. Including nSeconds lets you use CHRSAW( ) for a variety of timed activities. For example, your program can close an application if a key hasn't been pressed for a specific number of seconds.
Return Value
Logical

Remarks
CHRSAW( ) returns True (.T.) if a character is present in the keyboard buffer, and False (.F.) if not. CHRSAW( ) doesn't affect the keyboard buffer contents.

Example
In the following example, the system displays a window containing input fields created with @ ... GET commands, and waits 5 seconds for keyboard input. If a key isn't pressed in this time period, CHRSAW( ) returns False (.F.) and the program terminates.

  Copy Code
SET TALK OFF
DEFINE WINDOW wEnter FROM 7,10 to 13,70 PANEL
ACTIVATE WINDOW wEnter
@ 1,3 SAY 'Customer: '   GET gcCustomer  DEFAULT SPACE(40)
@ 3,3 SAY 'Address:  '   GET gcAddress  DEFAULT SPACE(40)
WAIT WINDOW 'Waiting for input' NOWAIT
IF NOT CHRSAW(5)   
   DEACTIVATE WINDOW wEnter
   CLEAR GETS
ELSE
   READ
   DEACTIVATE WINDOW wEnter
ENDIF
RELEASE WINDOW wEnter
WAIT
CLEAR




***
bu olabilirmi acaba

3 Son düzenleyen, foxman (15.01.2009 12:09:45)

Re: uygulamayı kapatmak

Uygulamayı otomatik kapatmak için aşağıdaki kodu yazdım, çok uzun uzadıya test etmedim ama iş görebilir. Klavye veya mouse, verilen interval süresi içinde kullanılmazsa programdan otomatik çıkarıyor. Programı açık bırakıp giden kullanıcılar için kullanılabilir.
Dikkat : Uzun sürecek rapor veya data process işlemleri için peşpeşe çalışacak komut satırları varsa timer ın satır aralarında devreye girip programı kesmemesi için _Screen.o_screen_timer1.Enabled = .F. yapılmalı.

_Screen.o_screen_timer1.Enabled = .F.
Çalışacak Komut Satırları.
_Screen.o_screen_timer1.Enabled = .T.



Visual Fox Pro
_screen.AddObject("o_screen_timer1","_screen_timer1")

_Screen.o_screen_timer1.Interval = 5000
_Screen.o_screen_timer1.Enabled = .T.
 
*Do Form form1
Read Events
 
 
Define Class _screen_timer1 As Timer
    befor_mx = 0
    befor_yx = 0
    befor_lk = 0
    after_mx = 0
    after_yx = 0
    after_lk = 0
 
    Procedure Init
        Declare Sleep In Win32API Integer
        Declare short GetCursorPos In win32api String @ lpPoint
        Declare Integer GetWindowDC In Win32API Integer HWnd
        Declare Integer GetPixel In win32API Integer hdc, Integer nXPos, Integer nYPos
        This.getvals("init")
    Endproc
 
    Procedure getvals
        Lparameters pcall
        lpPoint = Space(8)
        =GetCursorPos(@lpPoint)
        x = Asc(Substr(lpPoint,1))*256^0+Asc(Substr(lpPoint,2))*256^1+Asc(Substr(lpPoint,3))*256^2+Asc(Substr(lpPoint,4))*256^3
        Y = Asc(Substr(lpPoint,5))*256^0+Asc(Substr(lpPoint,6))*256^1+Asc(Substr(lpPoint,7))*256^2+Asc(Substr(lpPoint,8))*256^3
        If pcall="init"
            This.befor_mx = x
            This.befor_yx = Y
            This.befor_lk = Lastkey()
        Else
            This.after_mx = x
            This.after_yx = Y
            This.after_lk = Lastkey()
        Endif
    Endproc
 
    Procedure Timer
        This.getvals("")
 
        *?This.befor_mx,This.befor_yx,This.befor_lk
        *?This.after_mx,This.after_yx,This.after_lk
 
        If     This.befor_mx = This.after_mx ;
                AND This.befor_yx = This.after_yx ;
                AND This.befor_lk = This.after_lk
 
            *_Screen.RemoveObject("o_screen_timer1")
 
            FOR iform=1 TO AINSTANCE(gaMyArray, 'Form')
                cform=gaMyArray(iform)+".release "
                &cform
            ENDFOR
 
            *Cancel
            Quit
        Endif
 
        This.befor_mx = This.after_mx
        This.befor_yx = This.after_yx
        This.befor_lk = This.after_lk
    Endproc
 
Enddefine

4 Son düzenleyen, foxman (15.01.2009 13:21:29)

Re: uygulamayı kapatmak

Buda dakika ile çalışanı.
Bilgisayarı fazla meşgul etmesini istemiyorsanız interval değerini yükseltebilirsiniz.


Visual Fox Pro
_Screen.AddObject("o_screen_timer1","_screen_timer1")

_Screen.o_screen_timer1.WaitTime = 10 && minutes
_Screen.o_screen_timer1.Enabled = .T.
 
Do Form form1
Read Events
 
 
Define Class _screen_timer1 As Timer
    Interval = 1000
    WaitTime = 0 && minutes
    befor_mx = 0
    befor_yx = 0
    befor_lk = 0
    after_mx = 0
    after_yx = 0
    after_lk = 0
    befor_tm = Datetime()
    after_tm = Datetime()
 
    Procedure Init
        Declare Sleep In Win32API Integer
        Declare short GetCursorPos In win32api String @ lpPoint
        Declare Integer GetWindowDC In Win32API Integer HWnd
        Declare Integer GetPixel In win32API Integer hdc, Integer nXPos, Integer nYPos
        This.getvals("init")
    Endproc
 
    Procedure getvals
        Lparameters pcall
        lpPoint = Space(8)
        =GetCursorPos(@lpPoint)
        x = Asc(Substr(lpPoint,1))*256^0+Asc(Substr(lpPoint,2))*256^1+Asc(Substr(lpPoint,3))*256^2+Asc(Substr(lpPoint,4))*256^3
        Y = Asc(Substr(lpPoint,5))*256^0+Asc(Substr(lpPoint,6))*256^1+Asc(Substr(lpPoint,7))*256^2+Asc(Substr(lpPoint,8))*256^3
        If pcall="init"
            This.befor_mx = x
            This.befor_yx = Y
            This.befor_lk = Lastkey()
        Else
            This.after_mx = x
            This.after_yx = Y
            This.after_lk = Lastkey()
        Endif
    Endproc
 
    Procedure Timer
        This.getvals("")
 
        *?This.befor_mx,This.befor_yx,This.befor_lk
        *?This.after_mx,This.after_yx,This.after_lk
 
        If     This.befor_mx = This.after_mx ;
                AND This.befor_yx = This.after_yx ;
                AND This.befor_lk = This.after_lk
            This.after_tm = Datetime()
        Else
            This.befor_tm = This.after_tm
        Endif
 
        *?(This.after_tm - This.befor_tm)/60, This.WaitTime
 
        If (This.after_tm - This.befor_tm)/60 > This.WaitTime
            _Screen.o_screen_timer1.Enabled = .F.
            _Screen.RemoveObject("o_screen_timer1")
            For iform=1 To Ainstance(gaMyArray, 'Form')
                cform=gaMyArray(iform)+".release "
                &cform
            Endfor
 
            *CANCEL
            Quit
        Endif
 
        This.befor_mx = This.after_mx
        This.befor_yx = This.after_yx
        This.befor_lk = This.after_lk
    Endproc
 
Enddefine

5

Re: uygulamayı kapatmak

hepinize teşekkür ederim. elinize sağlık