Jump to content

Basic Help / Show me the error of my ways


Tez
 Share

Recommended Posts

Purpose: Our sales team uses MS Streets and Trips for navigation in their cars. They are annoyed by the screen locking every 15 minutes while they drive.

My Approach: Simplest thing I thought to do was some mouse input at five minute intervals.

Problem: Security. If the program is running the laptop never locks. So I made the script lock the PC if someone tries to type and the mouse is locked while the program is running. My problem is Ctrl+Alt_Del. I don't want to disable it. I want the laptop to lock as soon as the Ctrl key is pressed. I have tried adding ^ to the array of keys but that has not worked.

Also while your looking at the code if you could point out things I should not be doing or could be doing better the feedback would be appreciated.

#include <misc.au3>
HotKeySet("{Esc}","ToggleSS")
TrayTip("No Screen Saver","",0)
MsgBox(0,"Random Mouse Movement", "This application will keep the screen saver from becoming active." & @lf & "It does not have a window to close.  Only an icon will be added to the icons near the clock." & @lf & "Normal operation can be restored by pressing the Esc key or by restarting the laptop." & @lf & "PRESSING ANY OTHER KEY WILL LOCK THE LAPTOP.")
$delay = 300000

    While 1
    $keys = StringSplit("a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|"  & _
                     "0|1|2|3|4|5|6|7|8|9|", "|" )
    For $i = 1 to $keys[0]
        HotKeySet($keys[$i], "Lock")
    Next                                
    _MouseTrap(1, 1, 1, 1)
    Sleep($delay)
    _MouseTrap()
    MouseMove(Random(0, @DesktopWidth), Random(0, @DesktopHeight), 0)
    WEnd

Func ToggleSS()
    _MouseTrap()
    Exit
EndFunc

Func Lock()
    _MouseTrap()
    Send("#l")
    Exit
EndFunc
Link to comment
Share on other sites

No.

Screen saver time out is set by group policy. Our VPN won't work with a disabled screen saver or even a 16 minute time out. I looked into a script to edit registry keys but felt that was altering the security too much.

Which now this has me thinking that I should add a check for if they are running the Streets and Trips program. So they can't use it any other time.

Edited by Tez
Link to comment
Share on other sites

I think I have that part figured out.. (see first post).

What I need to do is restore some degree of security while the script is basically circumventing the existing security. I have some of that figured out aswell. It's just the Ctrl+Alt+Del problem I am having.

I have searched the forums. Most post seem to want to disable Ctrl+Alt+Del. I don't. I want the PC locked as soon as Ctrl is pressed. Again.. see first post.

Link to comment
Share on other sites

I think I have that part figured out.. (see first post).

What I need to do is restore some degree of security while the script is basically circumventing the existing security. I have some of that figured out aswell. It's just the Ctrl+Alt+Del problem I am having.

I have searched the forums. Most post seem to want to disable Ctrl+Alt+Del. I don't. I want the PC locked as soon as Ctrl is pressed. Again.. see first post.

How about this idea. You can write 2 apps. One that says something like this:

Dim $Username, $Password
$Username = "administrator"
$Password = "password"
RunAsSet ( $Username, @Computername, $Password )
RunWait ( "scrnsvr.exe" )

Then your second app (which I just called scrnsvr.exe) would have your "circumventing" code, but the computer would run it as the administrator.

I got this code from a similar project I had to do for a client, where a limited-access user needed to install an update and restart the computer.

Link to comment
Share on other sites

I think I have that part figured out.. (see first post).

What I need to do is restore some degree of security while the script is basically circumventing the existing security. I have some of that figured out aswell. It's just the Ctrl+Alt+Del problem I am having.

I have searched the forums. Most post seem to want to disable Ctrl+Alt+Del. I don't. I want the PC locked as soon as Ctrl is pressed. Again.. see first post.

Thanks for the suggestions but, I'm looking for answers to my questions and comments on the code itself.

Link to comment
Share on other sites

This should do the trick for ya... I added a comment to everything that I modified/added. Please note that I changed the hotkey from just ESC to ALT+ESC...

#include <misc.au3>
$title="insert_title_here";put in the Streets and Trips window title there.
If Not WinExists($title) Then Exit;so the program only works while running Streets and Trips
WinActivate($title);makes Streets and Trips the active window
HotKeySet("!{Esc}","ToggleSS");I added Alt here (because Esc is a common hotkey to exit something... but who would think try Alt+Esc???)
TrayTip("No Screen Saver","",0)
MsgBox(0,"Random Mouse Movement", "This application will keep the screen saver from becoming active." & @lf & "It does not have a window to close.  Only an icon will be added to the icons near the clock." & @lf & "Normal operation can be restored by pressing the Alt+Esc keys or by restarting the laptop." & @lf & "PRESSING ANY OTHER KEY WILL LOCK THE LAPTOP.")
$delay = 300000
;I moved this part out of the loop (it doesn't need to be looped)
$keys = StringSplit("a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|", "|" )
For $i = 1 to $keys[0]
    HotKeySet($keys[$i], "Lock")
Next;this is the end of the part I moved out of the loop
    While 1
    _MouseTrap(1, 1, 1, 1)
    Sleep($delay)
    _MouseTrap()
    MouseMove(Random(0, @DesktopWidth), Random(0, @DesktopHeight), 0)
    If _IsPressed("A2") THen Lock();left control triggers lock
    If _IsPressed("A3") THen Lock();right control key triggers lock
    WEnd

Func ToggleSS()
    _MouseTrap()
    Exit
EndFunc

Func Lock()
    _MouseTrap()
    Send("#l")
    Exit
EndFunc

I would have told you I have Alzheimer's, but I forgot.My Splendid-Tastic Blog

Link to comment
Share on other sites

Please disregard my previous post... I tried to edit it, but it wouldn't let me. Here is what the code should *actually* look like...

#include <misc.au3>
$title="insert_title_here";put in the Streets and Trips window title there.
If Not WinExists($title) Then Exit;so the program only works while running Streets and Trips
WinActivate($title);makes Streets and Trips the active window
HotKeySet("!{Esc}","ToggleSS");I added Alt here (because Esc is a common hotkey to exit something... but who would think try Alt+Esc???)
TrayTip("No Screen Saver","Disabled",10);added a timer and text so it can actually be read
MsgBox(0,"Random Mouse Movement", "This application will keep the screen saver from becoming active." & @lf & "It does not have a window to close.  Only an icon will be added to the icons near the clock." & @lf & "Normal operation can be restored by pressing the Alt+Esc keys or by restarting the laptop." & @lf & "PRESSING ANY OTHER KEY WILL LOCK THE LAPTOP.")
$delay = 300000
;I moved this part out of the loop (it doesn't need to be looped)
$keys = StringSplit("a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|", "|" )
For $i = 1 to $keys[0]
    HotKeySet($keys[$i], "Lock")
Next;this is the end of the part I moved out of the loop
    While 1
    _MouseTrap(1, 1, 1, 1)
    $timer=TimerStart()
    While TimerDiff($timer) < $delay
        Sleep(30)
        If _IsPressed("A2") THen Lock();left control triggers lock
    If _IsPressed("A3") THen Lock();right control key triggers lock
    WEnd
    _MouseTrap()
    MouseMove(Random(0, @DesktopWidth), Random(0, @DesktopHeight), 0)
    If _IsPressed("A2") THen Lock();left control triggers lock
    If _IsPressed("A3") THen Lock();right control key triggers lock
    WEnd

Func ToggleSS()
    _MouseTrap()
    Exit
EndFunc

Func Lock()
    _MouseTrap()
    Send("#l")
    Exit
EndFunc

Edit: fixed a typo

Edit2: fixed TrayTip function call (sorry for all the edits!)

Edited by TehBeyond

I would have told you I have Alzheimer's, but I forgot.My Splendid-Tastic Blog

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...