Recent

Author Topic: GetLastInputInfo  (Read 10547 times)

pascall

  • Newbie
  • Posts: 6
GetLastInputInfo
« on: January 20, 2012, 11:45:49 am »
The GetLastInputInfo function is described here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646302(v=vs.85).aspx
However, when I use this function in my program, compiling stops with error: Identifier not found GetLastInputInfo.
I have already put "windows" under "uses".
It is described on that website that this function is included in User32.dll. So if that's the reason causing the error, how to load that function from User32.dll into my program?
Thank you for your help.

pascall

  • Newbie
  • Posts: 6
Re: GetLastInputInfo
« Reply #1 on: January 20, 2012, 01:17:50 pm »
To be more specific, please show me exactly how to get "GetLasInputInfo" to work on my program.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: GetLastInputInfo
« Reply #2 on: January 20, 2012, 02:16:38 pm »
GetLastInputInfo is defined in jwawinuser. jwawinuser is part of the jedi port to fpc.

If you don't want to use that huge unit, just include the following in your code:

Code: [Select]
type
  PLASTINPUTINFO = ^LASTINPUTINFO;
  tagLASTINPUTINFO = record
    cbSize: UINT;
    dwTime: DWORD;
  end;
  LASTINPUTINFO = tagLASTINPUTINFO;
  TLastInputInfo = LASTINPUTINFO;

function GetLastInputInfo(var plii: TLastInputInfo): BOOL;stdcall; external 'user32' name 'GetLastInputInfo';


pascall

  • Newbie
  • Posts: 6
Re: GetLastInputInfo
« Reply #3 on: January 20, 2012, 05:08:02 pm »
Thank you very much :) That's exactly what I need for my project.

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: GetLastInputInfo
« Reply #4 on: July 23, 2013, 06:16:54 pm »
Sorry for resurrecting an old thread, but I'm trying to use this functionality and am hitting a compile error:

Code: [Select]
config.pas(49,79) Fatal: Syntax error, "=" expected but "const string" found

which corresponds to right before
Code: [Select]
'user32'.

(I'm trying to implement an idle timer based on the code here).

Thanks,

FM

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1290
Re: GetLastInputInfo
« Reply #5 on: July 24, 2013, 01:42:04 am »
hello,
for your idle timer why do you not use the component tidletimer ( system components tab) ?
Blaazen in another post explains what is it :
Quote
Well, when TIdleTimer.AutoEnabled=False then it behaves just like normal TTimer.
If you switch to Enabled:=False and AutoEnabled:=True then (in default configuration, i.e. AutoStartEvent=itaOnIdle and AutoEndEvent=itaOnUserInput) this timer raises events on IDLE (= when nothing happens, i.e. you don't move move, no clicks, no keyboard input etc.)

so, to use this component in a form for no activity detection, for example put a tidletimer in your form with properties :
AutoEnabled :  True
AutoEndEvent :  itaOnUserInput
AutoStartEvent : itaOnIdle
Enabled : False
Interval : 60000

and for OnTimerEvent this procedure :
Code: [Select]
procedure TForm1.IdleTimer1Timer(Sender: TObject);
begin
  showmessage('no activity during one minut');
end;   

Friendly, J.P
« Last Edit: July 24, 2013, 01:45:41 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: GetLastInputInfo
« Reply #6 on: July 24, 2013, 11:36:06 am »
Aha, thanks! It was the config I had wrong... I tried that component but couldn't quite figure the config out.

Next question - how do you reset the timer once it's reached it's idle time interval?

And this could ruin the whole idea.. is there any way to measure system idle time (lack of user input) rather than application idle time. I realise this is not fool proof and doesn't take account of a user reading a long text or watching a video etc, but it would get me at least part of the way in what I'm trying to build.

Thanks,

Dan

 

TinyPortal © 2005-2018