Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 22 JUL 2010 03:51:05AM Matthew Crozier wrote:

I'm trying to determine User idle time (not CPU idle time) by using the GetLastInputInfo Function in USER32 to return the time of the last user input event. So I've defined the 6 byte LASTINPUTINFO Structure using Define_Struct(), and I've prototyped the function as

UINT STDCALL GetLastInputInfo( LPCHAR)

But this bit of code fails, with SUCCESS and TIME both returning 0

lastInputInfo=var_to_struct( 6[/color]: [/color]@fm[/color]: [/color]''[/color], [/color]'LASTINPUTINFO'[/color]) 
[/color]Call [/color]Delay( [/color]3[/color])  ;[/color]* Don't press any keys or mouse 
[/color]success=getLastInputInfo( lastInputInfo) 
time=struct_to_var( lastInputInfo, [/color]'LASTINPUTINFO'[/color])2][/color][/color][/size]         
               

Any ideas what I'm doing wrong?

Cheers, M@

[img]http://www.vernonsystems.com/images/logo_main_ani.gif[/img]


At 22 JUL 2010 07:52PM Matthew Crozier wrote:

BTW, this is with OI 8.0.8 on Windows XP, so it should work.

Cheers, M@

[img]http://www.vernonsystems.com/images/logo_main_ani.gif[/img]


At 23 JUL 2010 03:40AM cpates@sprezzatura.com wrote:

Hi M@,

You're not initializing the LASTINPUTINFO structure correctly. Its defined as a UINT and DWORD, which is 8 bytes in total, not 6:

  • A DWORD is an unsigned long (4 bytes)
  • A UINT is an unsigned long (4 bytes)

(Also I usually use struct_Len() to get the structure size…)

.bpPre {

 font-family:Consolas,Courier New,Courier,Verdana,Arial;
 font-size:10pt;
 background-color:#FEFEFE;
 color:#000000;
 border:1px solid #7389AE;
 padding:10px 20px;
 margin:0px 10px auto;

}

.bpComment {

 font-style:italic;
 color:#008000;

}

.bpDirective {

 color:#808000;

}

.bpKeyword {

 color:#0000FF;

}

.bpNumber {

 color:#800000;

}

.bpString {

 color:#008080;

}

.bpSymbol {

 color:#800040;

}

.bpSysVar {

 color:#8000FF;

}

.bpDebug {

 font-size:12pt;
 font-weight:bold;
 color:#FF0000;

}

.bpDict {

 color:#FF8000;

}

.bpLabel {

 font-size:11pt;
 font-weight:bold;

}

.bpLineNo {

 font-family:Courier New, Courier, monospace;
 color:#808080;
 background-color:#F5F5F5;

}

0001  lii = struct_Len( "LASTINPUTINFO" ) : @fm : 0
0002  lii = var_To_Struct( lii, "LASTINPUTINFO" ) 
0003  
0004  call delay( 3 )
0005  
0006  success = getLastInputInfo( lii )
0007  time    = struct_To_Var( lii, "LASTINPUTINFO" )<2>

I'd also prototype your function as LPBINARY rather than LPCHAR, as it's designed for passing pointers to arbitrary blocks of data like structures. LPCHAR is not strictly for that purpose (but then this is just me being pedantic :-)).

cpates@sprezzatura.com

Captain's Blog

Battlestar Sprezzatura - BSG 77

Colonial leaders in all things RevSoft


At 25 JUL 2010 06:15PM Matthew Crozier wrote:

Brilliant! - thanks Capt'n

I took UINT for granted, as typing 'uint' into the Structure Designer window (OI 8.0.8) comes back with 'unsigned short' and a size of 2 bytes.

And thanks also for the tip on LPBINARY. As we're running in UTF8 mode, I'm pedantic myself when it comes to binary vs char ;).

Cheers, M@

[img]http://www.vernonsystems.com/images/logo_main_ani.gif[/img]

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/144d0e76e2d8aed285257768002b212a.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1