|
Started by Piet van Zanten, Sep., 02 2010 1:22 AM - 10 replies |
| |
| | | |
|
| |
Posted on September, 02 2010 - 1:22 AM |
Hi, I would like to have a window close if there has not been any user activity (mouse and keyboard) in the window during a certain period. DelayBeforeClosing is no option, because I want to reset the time left, as soon as there's activity. Does anyone know of a generic procedure to accomplish such? Regards, Piet |
| |
| |
| | | |
|
| | |
| |
Posted on September, 02 2010 - 11:44 AM |
Piet, I use something like this by trapping WM_CHAR and WM_MOUSEMOVE using Event(). I set a global var say gbIdle=False. (maybe you also need trapping WM_LBUTTONDOWN and so on) Then I use a timer to do my stuff, depending on this gbIdle. |
| |
| |
| | | |
|
| | |
| |
Posted on September, 02 2010 - 1:23 PM |
Hello Piet, I use this code for tracking inactivity (sorry for my bad english
Procedure Inactivite() LASTINPUTINFO est une structure cbTaille est un entier sans signe sur 4 dwTime est un entier FIN FinTimerSys(gtimerInactivite) InfoUser est un LASTINPUTINFO InfoUser:cbTaille = Dimension(InfoUser ) SI API("user32","GetLastInputInfo",&InfoUser ) 0 ALORS
SI (API("Kernel32","GetTickCount" )-InfoUser:dwTime) > gnInactivite ALORS
Ouvre(fen_Inactivite) FIN FIN gtimerInactivite = TimerSys("Inactivite", 100)
In the init of the Project
gtimerInactivite=TimerSys("Inactivite", 100) Hope it will help you |
| |
| |
| | | |
|
| | |
| |
Posted on September, 02 2010 - 5:21 PM |
Thanks guys, TheDuke's solution looks promising, I'll give it a try. Regards, Piet |
| |
| |
| | | |
|
| | |
| |
Posted on May, 08 2021 - 8:49 AM |
This code works exactly what I want: //// first window //// I have two static controls //// first is STC_MessageOfInactivity where I show text "Program inactivity detected...Program will shut down in:" //// second is STC_Time where it is shown the remaining time before shut down the app - in my case is 120sec gnStartOfInactivity,gnEndOfInactivity,gnRemainedTime,gnTimeOfInactivity is int gnRemainedTime=120 /// Time in seconds when the message is shown and this is remaining time in which the app will close gnTimeOfInactivity=1800 //// Time in seconds of inactivity gnEndOfInactivity=TimerSys("EndProgam", 100)
PROCEDURE (EndProgram) /// procedure in the first window LASTINPUTINFO is Structure cbTaille is 4-byte unsigned int dwTime is int END EndTimerSys(gnEndOfInactivity) InfoUser is LASTINPUTINFO InfoUser:cbTaille = Dimension(InfoUser ) IF API("user32","GetLastInputInfo",&InfoUser ) = 0 THEN STC_Time=gnEndOfInactivity IF (API("Kernel32","GetTickCount" )-InfoUser:dwTime) > gnEndOfInactivity THEN STC_Time=gnEndOfInactivity END END gnStartOfInactivity=(API("Kernel32","GetTickCount" )-InfoUser:dwTime)/1000 IF gnStartOfInactivity>=gnTimeOfInactivity THEN STC_MessageOfInactivity..Visible=True STC_Time..Visible=True gnRemainedTime-=1 STC_Time=gnRemainedTime IF gnRemainedTime=0 THEN EndProgram() END ELSE STC_MessageOfInactivity..Visible=False STC_Time..Visible=False END gnEndOfInactivity=TimerSys("EndProgram", 100)
///// IT IS WORKING PERFECTLY! |
| |
| |
| | | |
|
| | |
| |
Posted on May, 08 2021 - 9:01 AM |
This worked for me (with a little bit adjusting the code) First window:
gnStartOfInactivity,gnEndOfInactivity,gnRemainingTime,gnTimeOfInactivity is int gnRemainingTime=120 /// time in seconds before the app shut down gnTimeOfInactivity=1800 //// time in seconds before the message appear and start counting down (120s) before shut down gnEndOfInactivity=TimerSys("EndProgram", 100) Procedure:
PROCEDURE EndProgram() LASTINPUTINFO is Structure cbTaille is 4-byte unsigned int dwTime is int END EndTimerSys(gnEndOfInactivity) InfoUser is LASTINPUTINFO InfoUser:cbTaille = Dimension(InfoUser ) IF API("user32","GetLastInputInfo",&InfoUser ) = 0 THEN STC_Time=gnEndOfInactivity IF (API("Kernel32","GetTickCount" )-InfoUser:dwTime) > gnKrajNeaktivnosti THEN STC_Time=gnEndOfInactivity END END gnStartOfInactivity=(API("Kernel32","GetTickCount" )-InfoUser:dwTime)/1000 IF gnStartOfInactivity>=gnTimeOfInactivity THEN STC_StartOfInactivity..Visible=True STC_Time..Visible=True gnRemainingTime-=1 STC_Time=gnRemainingTime IF gnRemainingTime=0 THEN EndProgram() END ELSE STC_StartOfInactivity..Visible=False STC_Time..Visible=False END gnEndOfInactivity=TimerSys("EndProgram", 100) I have two static controls in the first window that are NOT visible: STC_StartOfInactivity - here I show the message text "Program is inactive...it will shut down in:" STC_Time - this control shows counting down the seconds from gnRemainingTime variable
Hope it helps.... |
| |
| |
| | | |
|
| | |
| |
Registered member 2 messages |
|
Posted on May, 08 2021 - 9:09 AM |
This worked for me (with a little bit adjusting the code) First window:
gnStartOfInactivity,gnEndOfInactivity,gnRemainingTime,gnTimeOfInactivity is int gnRemainingTime=120 /// time in seconds before the app shut down gnTimeOfInactivity=1800 //// time in seconds before the message appear and start counting down (120s) before shut down gnEndOfInactivity=TimerSys("EndProgram", 100) Procedure:
PROCEDURE EndProgram() LASTINPUTINFO is Structure cbTaille is 4-byte unsigned int dwTime is int END EndTimerSys(gnEndOfInactivity) InfoUser is LASTINPUTINFO InfoUser:cbTaille = Dimension(InfoUser ) IF API("user32","GetLastInputInfo",&InfoUser ) = 0 THEN STC_Time=gnEndOfInactivity IF (API("Kernel32","GetTickCount" )-InfoUser:dwTime) > gnKrajNeaktivnosti THEN STC_Time=gnEndOfInactivity END END gnStartOfInactivity=(API("Kernel32","GetTickCount" )-InfoUser:dwTime)/1000 IF gnStartOfInactivity>=gnTimeOfInactivity THEN STC_StartOfInactivity..Visible=True STC_Time..Visible=True gnRemainingTime-=1 STC_Time=gnRemainingTime IF gnRemainingTime=0 THEN EndProgram() END ELSE STC_StartOfInactivity..Visible=False STC_Time..Visible=False END gnEndOfInactivity=TimerSys("EndProgram", 100) I have two static controls in the first window that are NOT visible: STC_StartOfInactivity - here I show the message text "Program is inactive...it will shut down in:" STC_Time - this control shows counting down the seconds from gnRemainingTime variable
Hope it helps.... |
| |
| |
| | | |
|
| | |
| |
Registered member 2 messages |
|
Posted on May, 08 2021 - 9:12 AM |
correction of the code above... gnKrajNeaktivnosti=gnEndOfInactivity |
| |
| |
| | | |
|
| | |
| |
Registered member 7 messages |
|
Posted on May, 13 2021 - 9:23 AM |
Hi Piet, I have understood that you want to play with timeouts in a particular window, otherwise there always is: Project > Description >Advanced > Application security {Just in case the subject might pop up in a search) All the best /Jacek |
| |
| |
| | | |
|
| | |
| |
Registered member 55 messages Popularité : +2 (2 votes) |
|
Posted on May, 13 2021 - 10:31 AM |
| |
| |
| | | |
|
| | |
| |
Posted on July, 08 2021 - 6:16 PM |
Hi all I did this way for all windows of the project
I put in each Windows an procedure called "CloseWindow"
In the procedure called "CloseWindow" the code
ToastDisplay("If you do not use this windows, its will be closed in ",toastShort,vaBottom,haCenter) DelayBeforeClosing(MyWindow,BTN_CloseX,3000)
In Procedure Automatic Mhecanism (the Icon of a wath (clock) on the Right site of code editor of the procedure I put in the Option HOW : 1 TIMES spacing between call 01:30 marked Triger a New Timer
WHEN: Automatic start 01:30 Hrs
and Outside of window one CLOSE BUTTON with the code warning the user and giving him a Option to abort the operation of CLOSING the windos IF Open(WIN_YesNo) = "N" THEN RETURN END |
| |
| |
| | | |
|
| | | | |
| | |
|