Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-11-2008, 07:08 PM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default Application.captureMouse in Flex 3

Hi,

I want to track "user activity" on a windows system in order to know if he is active or away from the pc. (like in messenger)

A good way to do this would be to track mouse movement and reset a timer when the mouse is not moving.
I thought about Application.captureMouse but I don't see how to use this in Flex 3.

Any hints?

tnx,
Gert
Reply With Quote
  #2 (permalink)  
Old 08-13-2008, 06:55 AM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default Re: Application.captureMouse in Flex 3

I found a solution (workaround?) for myself:


struct {
long x;
long y;
} POINT;

dllimport "user32.dll" stdcall Boolean GetCursorPos(POINT*);

function traceWin() {
var output = new Object;
output.value = new Struct(POINT);
GetCursorPos(output);
//var hwnd = WindowFromPoint(output.value);
trace(output.value.x);
}

Application.setInterval(traceWin, 1000);


Checking the x and y values for changes will let me know if the user is away or not.


Probably not the most elegant way of doing this: any other hints are very welcome.

Gert
Reply With Quote
  #3 (permalink)  
Old 08-13-2008, 06:53 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Application.captureMouse in Flex 3

Watching only the mouse events may not be enough. On win2k,xp,vista you can use the "GetLastInputInfo" method.
http://msdn.microsoft.com/en-us/library/ms646302(VS.85).aspx
Reply With Quote
  #4 (permalink)  
Old 08-14-2008, 06:59 AM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default Re: Application.captureMouse in Flex 3

Thank you SWFKit: this is indeed a much better solution.
I love your support: this is *the* reason why our company sticks with SWFKit (despite its outdated looking IDE and scripting environment)
Reply With Quote
  #5 (permalink)  
Old 08-14-2008, 07:31 AM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default Re: Application.captureMouse in Flex 3

Hm, I was a little bit too fast ... I can not make this work:

here's my ffish code, but output is "0 - 0" ...

struct {
long cbSize; //uint ~ long ?
long dwTime; //dword ~ long ?
} LASTINPUTINFO;
dllimport "user32.dll" stdcall Boolean GetLastInputInfo(LASTINPUTINFO*);

function pollLastInputInfo() {
var lastInput = {cbSize:32, dwTime:0}; //is 32 the right size?
lastInput.value = new Struct(LASTINPUTINFO);
GetLastInputInfo(lastInput);
trace(lastInput.value.cbSize + " - " + lastInput.value.dwTime);

}
Application.setInterval(pollLastInputInfo, 1000);
Reply With Quote
  #6 (permalink)  
Old 08-14-2008, 10:05 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Application.captureMouse in Flex 3

Code:
struct {
  long cbSize; //uint ~ long ?
  long dwTime; //dword ~ long ?
} LASTINPUTINFO;
dllimport "user32.dll" stdcall Boolean GetLastInputInfo(LASTINPUTINFO*);

function pollLastInputInfo() {
  var lastInput = new Object;
  lastInput.value = new Struct(LASTINPUTINFO);
  lastInput.value.cbSize = lastInput.value.structSize;
  GetLastInputInfo(lastInput);
  trace(lastInput.value.cbSize + " - " + lastInput.value.dwTime);

}
Application.setInterval(pollLastInputInfo, 1000);
Reply With Quote
  #7 (permalink)  
Old 08-14-2008, 11:06 AM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default Re: Application.captureMouse in Flex 3

aah - structSize, that was what I was seeking for ...

thanks! It works now!
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:19 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.