Ephelyon Posted April 13, 2015 Posted April 13, 2015 (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"? 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 April 13, 2015 by Ephelyon 1
scotyboy56 Posted May 19, 2015 Posted May 19, 2015 (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 May 19, 2015 by scotyboy56 1
Ephelyon Posted May 19, 2015 Author Posted May 19, 2015 (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... Edited May 19, 2015 by Ephelyon 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now