Jump to content

Disable key combination


Recommended Posts

Hi,

(I'm a newbie with autoit)

My wife uses a program at her school to monitor student PC's. The software has a client program on the student XP systems which can be disabled by the ctrl+alt+shift+F10 keys.

It would be great if I could create an autoit executable which runs automatically at startup and would prevent them to use this key combination.

Can somebody help me with that?

Kind regards, Gert

Link to comment
Share on other sites

Yes, the hotkeyset() example will help.

You'll also want the #NoTrayIcon command at the top of your script as the script will need to continually be running in the background.

Before you ask how to run script at startup: http://www.autoitscript.com/forum/index.php?showtopic=17949

See also http://www.autoitscript.com/forum/index.ph...topic=22455&hl= to prevent users from terminating the process....

Edit: spelling

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

use hotkeyset()

I have defined a desktop shortcut wich can be started with ctrl+alt+shift+F10.

I ran the script below but still the desktop shortcut is started. What am I doing wrong?

; capture and pass along a keypress
#NoTrayIcon

   while 1 = 1
      HotKeySet("{^!+F10}", "captureCasF10")
      sleep(1)
   wend

Func captureCasF10()
   ; ... do nothing here
EndFunc
Link to comment
Share on other sites

Here's a li'l sump'm sump'm...

; This will give a warning the first time the key is pressed, 
; and a different message for the second time.  Every time it 
; will log the keypress to a file $logfile.  This tells you the 
; computer, the student, and the time the key was pressed 
; in a plain text file in CSV format.

#NoTrayIcon
#include <Date.au3>

HotKeySet("^!+{F10}", "ShowError")

Global $logfile = "\\teachers-computer\share$\" & @ComputerName & "_" & @UserName & ".log"
Global $showalerts = True
Global $keypressed = 0

While 1
    Sleep(100)
WEnd

Func ShowError()
    Global $logfile, $showalerts, $keypressed
    If $showalerts = True Then
        If $keypressed = False Then
            MsgBox(0+16, "WARNING!", _
                "That key is no longer valid, and your teacher has " & @LF & _
                "been alerted to your subversive activities!" & @LF & @LF & _
                "The next time you press those keys, you will be sent" & @LF & _
                "to the principal's office to receive a severe beating!")
            $keypressed = True
        Else
            MsgBox(0+16, "YOU WERE WARNED!", _
                "You were warned about pressing those keys again." & @LF & _
                "Please report immediately to me for punishment." & @LF & @LF _
                "                   <Teacher's Name>")
        EndIf
    EndIf
    $date = _DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3)
    $csvline = @ComputerName & "," & @UserName & "," & $date
    FileWriteLine($logfile, $csvline)
EndFunc

You can turn off the MsgBoxes using the variable $showalerts.

Edited by c0deWorm

My UDFs: ExitCodes

Link to comment
Share on other sites

Here's a li'l sump'm sump'm...

; This will give a warning the first time the key is pressed, 
; and a different message for the second time.  Every time it 
; will log the keypress to a file $logfile.  This tells you the 
; computer, the student, and the time the key was pressed 
; in a plain text file in CSV format.

#NoTrayIcon
#include <Date.au3>

HotKeySet("^!+{F10}", "ShowError")

Global $logfile = "\\teachers-computer\share$\" & @ComputerName & "_" & @UserName & ".log"
Global $showalerts = True
Global $keypressed = 0

While 1
    Sleep(100)
WEnd

Func ShowError()
    Global $logfile, $showalerts, $keypressed
    If $showalerts = True Then
        If $keypressed = False Then
            MsgBox(0+16, "WARNING!", _
                "That key is no longer valid, and your teacher has " & @LF & _
                "been alerted to your subversive activities!" & @LF & @LF & _
                "The next time you press those keys, you will be sent" & @LF & _
                "to the principal's office to receive a severe beating!")
            $keypressed = True
        Else
            MsgBox(0+16, "YOU WERE WARNED!", _
                "You were warned about pressing those keys again." & @LF & _
                "Please report immediately to me for punishment." & @LF & @LF _
                "                   <Teacher's Name>")
        EndIf
    EndIf
    $date = _DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3)
    $csvline = @ComputerName & "," & @UserName & "," & $date
    FileWriteLine($logfile, $csvline)
EndFunc

You can turn off the MsgBoxes using the variable $showalerts.

your msgboxes are really funny! XD

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

Be careful with the where the braces go inside the HotKeySet (only F10 needs to be in braces):

Since you gave it good try, here's my version:

#NoTrayIcon
HotKeySet("^!+{F10}", "doNothing")

While 1
    sleep(100);prevent maxing-out the CPU
Wend

Func doNothing()
EndFunc

Edit: fixed missing quote and parens (thanks SmOke_N)

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Be careful with the where the braces go inside the HotKeySet (only F10 needs to be in braces):

Since you gave it good try, here's my version:

#NoTrayIcon
HotKeySet("^!+{F10}, "doNothing")

While 1
    sleep(100);prevent maxing-out the CPU
Wend

Func doNothing
EndFunc

Thanks, I noticed that when comparing it with the supplied example.

Now I have a problem, the HotKeySet doesn't work. The desktop shortcut is still active.

This is the code a ran and the returned code = 0

; capture and pass along a keypress
;#NoTrayIcon
  $x = HotKeySet("^!+{F10}","DoNothing")

  If $x = 1 then
            MsgBox(0+16, "OK :)", _
                " HotKeySet succeeded")
  else
            MsgBox(0+16, "ERROR!", _
                " Returncode " & $x & " from HotKeySet")
  EndIf

   while 1
      sleep(100)
   wend

Func DoNothing()
EndFunc
Link to comment
Share on other sites

  • Moderators

Thanks, I noticed that when comparing it with the supplied example.

Now I have a problem, the HotKeySet doesn't work. The desktop shortcut is still active.

This is the code a ran and the returned code = 0

; capture and pass along a keypress
;#NoTrayIcon
  $x = HotKeySet("^!+{F10}","DoNothing")

  If $x = 1 then
            MsgBox(0+16, "OK :)", _
                " HotKeySet succeeded")
  else
            MsgBox(0+16, "ERROR!", _
                " Returncode " & $x & " from HotKeySet")
  EndIf

   while 1
      sleep(100)
   wend

Func DoNothing()
EndFunc
What are you trying to accomplish with the $x = HotKeySet()?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

What are you trying to accomplish with the $x = HotKeySet()?

The manual says that HotKeySet returns 1 when successfull and 0 when unsuccesfull. This way I wanted to check if the function ran without a problem.

Link to comment
Share on other sites

  • Moderators

; capture and pass along a keypress
;#NoTrayIcon
Global $x = 0
HotKeySet("^!+{F10}","DoNothing")

While 1
    If $x = 1 Then 
        MsgBox(0, '', "HotKey Was Blocked")
        $x = 0
    EndIf
    Sleep(100)
WEnd

Func DoNothing()
    $x = 1
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thank you very much, but that's not what I ment to say.

The key combination wasn't captured at all because running the HotKeySet function failed. It looks like I can't overrule the hotkey combination already defined to start a desktop shortcut.

You can run my code after adding the used shortcut to a desktop shortcut to check if it reacts the same way, I should guess so.

Link to comment
Share on other sites

It looks like I can't overrule the hotkey combination already defined to start a desktop shortcut.

Correct. The hotkeys share the same global space, and HotKeySet won't overwrite existing hotkeys. This should be added to the docs.

HOWEVER, you might use FileCreateShortcut to create a dummy shortcut with the Ctrl+Alt+Shift+F10 hotkey--FileCreateShortcut does overwrite global hotkeys--and then delete that dummy shortcut to free up the hotkey....

Disclaimer on Microsoft's buggy shortcut hotkeys:

http://www.autoitscript.com/forum/index.ph...ndpost&p=155169

EDIT: Well, maybe my plan doesn't work after all....

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Correct. The hotkeys share the same global space, and HotKeySet won't overwrite existing hotkeys. This should be added to the docs.

Does this mean that the autoit script needs to be started before the client monitoring software?

Link to comment
Share on other sites

Can you change or disable its hotkey in it's configuration settings?

Or make your script check for the existance of that programs process, kill it, set the hotkey, then restart the program.

I've checked the doc's but if the doc's are complete changing the config isn't possible.

Killing the process might be an option if it's necessary, I'll have to check that.

Thanks everybody for the fast help, I will report back how things will be implemented.

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...