Jump to content

Recommended Posts

Posted (edited)

From searching the forum I've noticed a couple of threads where people are asking for some sort of computerised Panic Button functionality. We've recently had an incident where it was definitely needed (thankfully it's all on camera), so I decided to knock one up in AutoIt. Here's the code so far:

 

#include 
#include 
#include 
#NoTrayIcon

If IsAdmin() Then Exit
If  @COMputerName = "MHS-TS-01" Then Exit

Local $mailServer, $mailDisplayFrom, $mailAddressFrom, $mailAddressTo, $mailSubject, $mailBody[1], $panicButton, $guiMsg

$mailServer = "172.16.253.108"
$mailDisplayFrom = "PANIC BUTTON!"
$mailAddressFrom = "[email protected]"
$mailAddressTo = "[email protected]"
$mailSubject = "Button pressed!"
$mailBody[0] = "User " &  @username & " on computer " &  @COMputerName & " is requesting emergency assistance please!"

GUICreate("Panic Button", 80, 50, -1, 0, $WS_POPUPWINDOW)
Opt("GUICoordMode", 2)
$panicButton = GUICtrlCreateButton("Panic Button", 7, 14)
GUISetState()

While 1
  $guiMsg = GUIGetMsg()
  Select
  Case $guiMsg = $GUI_EVENT_CLOSE
	 ExitLoop
  Case $guiMsg = $panicButton
	 _INetSmtpMail($mailServer, $mailDisplayFrom, $mailAddressFrom, $mailAddressTo, $mailSubject, $mailBody,  @COMputerName, -1)
  EndSelect
WEnd

 

This gives you a button centred at top of the screen, which when pressed will send an e-mail to an address (a distribution group in this case, making it easy to add/remove members, and set to not require senders to be authenticated). All members would have radios so they can co-ordinate who will respond once the message is received. It doesn't run for admins (it would just annoy me as it launches on logon for all staff users), nor does it run if it detects you're on the remote access server as that would be pointless.

 

It doesn't make use of Always On Top, as that could be annoying for presentations etc. and it would be too "conspicuous" either way, but if you do want it to be ever-present, add this line after GUISetState():

 

WinSetOnTop("Panic Button", "", 1)

 

Obviously all text can be customised... I was thinking maybe it shouldn't say "Panic Button", maybe something like "Intervention" instead... or perhaps "I'm a Teacher, Get Me Out of Here"? :rolleyes:

 

It doesn't do anything fancy like the paid-for solutions such as Little Green Button, but then again we don't need it to... :)

Edited by Ephelyon
  • Thanks 1
  • 1 month later...
Posted (edited)

That's awesome, and looks great, shall be showing that to the head and one of my schools when I am there next. Just wondering if there is anyway to have it so if the member is part of group pupils it exits it as well, just for those rare moments that pupils might log onto the teachers desktop?

 

Thanks :)

 

Edit: Don't worry, just figured out I could add it to the staff startup script to run on startup :) Silly me...

Edited by scotyboy56
  • Thanks 1
Posted (edited)

UPDATE: New code for error-checking the e-mail.

 

Case $guiMsg = $panicButton
Local $mailSuccess = _INetSmtpMail($mailServer, $mailDisplayFrom, $mailAddressFrom, $mailAddressTo, $mailSubject, $mailBody,    @COMputerName, -1)
Local $mailError =    @error
If $mailSuccess = 1 Then
	MsgBox(0, "Success", "Message sent!")
Else
	MsgBox(0, "Failure", "Message failed with error code: " & $mailError)
EndIf

 

Just means they know it's definitely gone and they don't need to keep pressing the button... :rolleyes:

Edited by Ephelyon
  • Thanks 1

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



×
×
  • Create New...