Home > Software engineering >  How to judge the whole mouse events?
How to judge the whole mouse events?

Time:10-09

Do a project for five minutes without operation automatically jump back to the main interface, this will need to determine the form of the mouse time (form have N controls, and there is no click event web controls), could you tell me how to completely control form the mouse to click the event, as long as a click of the mouse response?

CodePudding user response:

Global mouse control a lot of, can be searched,

CodePudding user response:

GetLastInputInfo Function

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The GetLastInputInfo function retrieves The time of The last input event.

Syntax

BOOL GetLastInputInfo (PLASTINPUTINFO plii
);
The Parameters

Plii
[out] Pointer to a LASTINPUTINFO structure that receives the time of the last input event.
The Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.




Few

This function is useful for input idle detection. An GetLastInputInfo does not dojo.provide system - wide user input information across indicates all running sessions. Rather, GetLastInputInfo provides the session - specific user input information for only the session that invoked the function.

The Function Information

Minimum DLL Version user32. DLL
The Header Declared in Winuser. J h, include Windows. H
The Import library User32. Lib
Minimum operating systems, Windows 2000

See Also

The rid_device_info_keyboard Input, LASTINPUTINFO

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

 # pragma comment (lib, "NTDLL") 
# pragma comment (lib, "user32")
# include & lt; Afxdisp. H>
# include & lt; Windows. H>
# include & lt; Winnt. H>
# include & lt; Stdio. H>
# include & lt; The memory. H>
Typedef struct tagLASTINPUTINFO {
UINT cbSize;
DWORD dwTime;
} LASTINPUTINFO, * PLASTINPUTINFO;
Extern "C" BOOL WINAPI GetLastInputInfo (PLASTINPUTINFO plii);
LASTINPUTINFO lii.
BOOL r;
Extern "C" NTSYSAPI NTAPI NtQuerySystemInformation (
IN UINT SystemInformationClass,//information type
OUT PVOID SystemInformation,//the buffer pointer
The size, IN bytes IN ULONG SystemInformationLength,//the buffer
The OUT PULONG ReturnLength OPTIONAL//of the number of bytes written to the buffer
);
//the first parameter is the request of information type, this parameter can have many values, in order to get the system startup time, we only use one of these values: SystemTimeInformation (3),
//if the first parameter is the SystemTimeInformation, the second parameter must be a SYSTEM_TIME_INFORMATION structure pointer,
Typedef struct {
LARGE_INTEGER liKeBootTime;//system has been start time (in milliseconds),
LARGE_INTEGER liKeSystemTime;
LARGE_INTEGER liExpTimeZoneBias;
ULONG uCurrentTimeZoneId;
DWORD dwReserved;
} SYSTEM_TIME_INFORMATION;
SYSTEM_TIME_INFORMATION sti;
ULONG rl.
FILETIME ft;
Int main () {
Lii. CbSize=sizeof (LASTINPUTINFO);
R=GetLastInputInfo (& amp; Lii);
If (r) {
//printf (" OK to GetLastInputInfo: dwTime==% d ms \ n ", lii. DwTime);
NtQuerySystemInformation (3, & amp; Sti, sizeof (sti), & amp; Rl);//3==SystemTimeOfDayInformation
//printf (" NtQuerySystemInformation (SystemTimeOfDayInformation,... ) return liKeBootTime I64u ms==% \ n ", * ((unsigned __int64 *) & amp; Sti. LiKeBootTime)/10000 ui64);
COleDateTime t;
COleDateTimeSpan ts ();
Cstrings s, FMT;
FMT="% % Y - m - H: % d % % m: % S".
Memcpy (& amp; The ft, & amp; Sti. LiKeBootTime, 8);
T=COleDateTime (ft);
S=t.F ormat (FMT);
Printf (" BootDateTime: % s \ n ", s);
* ((unsigned __int64 *) & amp; Ft) +=(unsigned __int64) (lii. DwTime) * 10000 ui64;
T=COleDateTime (ft);
S=t.F ormat (FMT);
Printf (" LastInputDateTime: % s \ n ", s);
} else {
Printf (" Fail to GetLastInputInfo! \n");
return 1;
}
return 0;
}
//BootDateTime: the 2014-04-15 09:04:18
//LastInputDateTime: the 2014-04-15 17:26:37
//

CodePudding user response:

GetLastInputInfo

WM_SETFOCUS
WM_KILLFOCUS

This combination of three perfect solution...

Train of thought, according to the foreground window setfoucus detect whether the window has focus, start the timer if you have five minutes getlastinputinfo detection confirm input on how the operation, conversely, no

Setfocus killfocus, start the timer for 5 minutes not received focus to capture directly as a timeout, whereas the operating rights to the setfocus can

CodePudding user response:

Subclass can be not?
Message 5 minutes didn't receive the mouse, keyboard,,

CodePudding user response:

Some feel may still use GetLastInputInfo more appropriate, estimates that don't need that high authority,
  • Related