AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detecting Remote Desktop Connection

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
silveredge78



Joined: 25 Jul 2006
Posts: 382
Location: Midwest, USA

PostPosted: Sun May 13, 2007 4:07 am    Post subject: Detecting Remote Desktop Connection Reply with quote

I would like to be able to detect when a computer is in use normally - as in, someone physically at the computer in the normal session, and when the computer is in use via Remote Desktop Connection, and when it is just sitting there locked.

Is there anyway of detecting this?
_________________
SilverEdge78
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Sun May 13, 2007 4:10 am    Post subject: Reply with quote

if you have matlab, you could try to start it. It refused to start over remote desktop - haha!

What is good about this, is that there must be some way of detecting it.

Have you found any relevant links at MSDN?
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
silveredge78



Joined: 25 Jul 2006
Posts: 382
Location: Midwest, USA

PostPosted: Sun May 13, 2007 4:24 am    Post subject: Reply with quote

I havent looked at MSDN. I wouldnt even know where to start in terms of what is detectable or how in AHK.

Also, the reason for this is I am trying to guage how much work is done on a machine in person, remotely, and how much the machine is idle.
_________________
SilverEdge78
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 382
Location: Midwest, USA

PostPosted: Tue May 15, 2007 4:52 pm    Post subject: Reply with quote

For anyone wanting to do something similar, I found SysGet could get what I wanted. Specifically:

AHK's Manual wrote:
4096 SM_REMOTESESSION: This system metric is used in a Terminal Services environment. If the calling process is associated with a Terminal Services client session, the return value is nonzero. If the calling process is associated with the Terminal Server console session, the return value is zero. The console session is not necessarily the physical console. Windows NT 4.0 SP3 and earlier, Windows Me/98/95: The retrieved value is always 0.

Using this information, I came up with the following script. It records whether the computer is in remote session mode or not. I have it set to ignore when the machine is not in use. It logs what mode it is in and what the active window is (primarily for testing). Since this is not to track workflow, I have it only check every 30 seconds and an idle time of 5 minutes.

Code:
#Persistent
#SingleInstance, Force
#NoEnv

SplitPath, A_ScriptName,,,, ScriptNoExt
ScriptLog = %ScriptNoExt%.log

Loop
{
  If A_TimeIdle > 300000
  {
    Sleep, 30000
    Continue
  }
  RS = False

  SysGet, SessionRS, 4096

  If SessionRS <> 0
    RS = True

  WinGetActiveTitle, ActiveWindowTitle

  Message = Session Remote Session = %RS%, %SessionRS% - %ActiveWindowTitle%
  Log(Message)
  Sleep, 30000
}
Return

Log(Message)
{
  Global ScriptLog
  FormatTime TimeString,, yyyy-MM-dd HH:mm:ss
  FileAppend, %TimeString% - %Message%`n, %A_ScriptDir%\%ScriptLog%
}

Esc::
  Run notepad.exe %A_ScriptDir%\%ScriptLog%
ExitApp

_________________
SilverEdge78
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 382
Location: Midwest, USA

PostPosted: Tue Jun 19, 2007 9:25 pm    Post subject: Reply with quote

Anyone know how I can turn this off and on remotely on a machine? I am an administrator on my network and I have been asked to verify whether an employee is actually working from home when they say they are. I do not need it on all the time. More like, if they are supposed to be working from home from 8am-12pm, I want to be able to turn it on and off accordingly and know when they are actively working or not. We suspect someone is drastically abusing the work at home priviledge. Sad I know I can set it to be in their startup but I dont want it on all the time, only when they are supposed to be working and they arent in the office. Also, this individual does not ever really log off (even though that is company policy).

Any ideas would be greatly appreciated.
_________________
SilverEdge78
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Tue Jun 19, 2007 11:06 pm    Post subject: Reply with quote

search the forum for psexec - you canrun programs on other machines on the network, so your guy just has to be VPN'd in.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
System Monitor



Joined: 09 Mar 2007
Posts: 392
Location: Unknown

PostPosted: Wed Jun 20, 2007 1:16 am    Post subject: Reply with quote

You could put up in their startup to search for a certain color pixel on the desktop ( because it does not show the backround ) then if it is there start the monitoring, and if not close Laughing hope that helped

also check

Code:
SysGet

its in there
Back to top
View user's profile Send private message Visit poster's website
Lemming



Joined: 20 Dec 2005
Posts: 150
Location: Malaysia

PostPosted: Thu Jun 21, 2007 2:38 am    Post subject: sounds more like an evaluation problem Reply with quote

Eh? I don't get it. Why the need to monitor his sessions (work or otherwise). Isn't there a better way to track productivity?

I mean, wouldn't it be obvious if he/she isn't finishing work on schedule, doesn't file reports, doesn't respond to emails, etc.

BTW, PsExec which was mentioned earlier is part of the PsTools suite which you can get here:
http://www.microsoft.com/technet/sysinternals/utilities/PsTools.mspx

You might also want to check out PsList and PsLoggedOn.
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 382
Location: Midwest, USA

PostPosted: Thu Jun 21, 2007 4:58 pm    Post subject: Reply with quote

After the psexec suggestion, I was like duh and looked at it cause I already had PsTools downloaded (I use it for stats on machines on the network sometimes).

I am not looking for productivity, or even to monitor what he is doing. More to see when he is connected to the office remotely versus in the office actually working.

Amusingly enough, in testing it for myself yesterday, I could not get it to work right, and today in typing this reply realized I just hadnt put the options before the command. Silly me. Smile
_________________
SilverEdge78
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group