필터 지우기
필터 지우기

How do I get system idle time in MATLAB?

조회 수: 3 (최근 30일)
John
John 2011년 2월 23일
How do I go about getting the system idle time in MATLAB, I've searched around and cant find anything. Im using Windows XP x64. I thought something with the 'system' command might work. Thanks

채택된 답변

John
John 2011년 2월 23일
Found this perl script that works, simply call perl('last-input.pl') in matlab
use Win32::OLE;
use Win32::API;
use Win32;
$debug=0;
#Count the current 'ticks' (time in millisecs since last boot)
my $tick = Win32::GetTickCount();
#Create a structure for LASTINPUTINFO
my $struct = Win32::API::Struct->typedef( LASTINPUTINFO => qw{
UINT cbSize;
DWORD dwTime;
});
#Reference user32.dll
my $dllcall = Win32::API->Import("user32", 'BOOL GetLastInputInfo(LPLASTINPUTINFO plii)');
#Call this dll
my $input = Win32::API::Struct->new('LASTINPUTINFO');
#Define a buffer size to fill with the tick value of last input ??
$input->{"cbSize"}=$input->sizeof;
#Get the tick value
GetLastInputInfo($input);
my $lastinput = $input->{"dwTime"};
print "Current Tick: $tick\n" if ($debug);
print "Last Input: $lastinput\n" if ($debug);
#Convert the difference betwen values to seconds
my $diff = ($tick - $lastinput)/1000;
print "Last input: $diff seconds ago\n";

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by