Jump to content

Moniter Manager


Generator
 Share

Recommended Posts

This is a little tool I use in school, comes in handy if teacher/whatever checks on you. They will think you haven't touch you computer and it is on idle. Very easy to use and i guess you might like it.

Source:

#include<Misc.au3>

_Singleton("Monitor Manager")

Opt("MouseCoordMode", 1)
Opt("WinTitleMatchMode", 4)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
Opt("RunErrorsFatal", 0)

Global Const $lciWM_SYSCommand = 274
Global Const $lciSC_MonitorPower = 61808
Global Const $lciPower_Off = 2
Global Const $lciPower_On = -1
Global $Msg = 1

$RegRead = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "SCRNSAVE.EXE")
$dll = DllOpen("user32.dll")
$menu = TrayCreateItem("Help")
$hwnd = WinGetHandle("classname=Progman")
TrayItemSetOnEvent($menu, "_Help")

While 1
    If _IsPressed("01") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0 Then
        While _IsPressed("01")
            Sleep(1)
        WEnd
        $Msg = Not $Msg
        If Not $Msg Then
            Do
                _Off()
                Sleep(1)
            Until _IsPressed("01") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0
        Else
            _On()
        EndIf
    EndIf
    If _IsPressed("02") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0 Then
        While _IsPressed("02")
            Sleep(1)
        WEnd
        _On()
        _Bye()
    EndIf
    If _IsPressed("04") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0 And $Msg Then
        While _IsPressed("04")
            Sleep(1)
        WEnd
        _ScreenSaver()
    EndIf
    Sleep(1)
WEnd
Func _Help()
    MsgBox(64, "Instruction", "To activate this, make appropriate click at top left screen" & @CRLF & @CRLF & "Left Button - Screen On/Off" & @CRLF & "Middle Button - Activate Screensaver" & @CRLF & "Right Button to exit program" & @CRLF & @CRLF & "This will close in 5 seconds", 5)
EndFunc   ;==>_Help
Func _On()
    DllCall($dll, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)
EndFunc   ;==>_On
Func _Off()
    DllCall($dll, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)
EndFunc   ;==>_Off
Func _Bye()
    Exit
EndFunc   ;==>_Bye
Func _ScreenSaver()
    ShellExecute($RegRead)
    If @error Then TrayTip("Error", "This machine have no default screensaver", "", 1)
EndFunc   ;==>_ScreenSaver
Edited by Generator
Link to comment
Share on other sites

nice script thow i dont like that you use the mouse to trun on or off maybe use shit+1 for off and shit+2 for on? just a idea

Or maybe.... shift+1?

:)

Ahhhh, beat me to it!

Nice script, by the way!

I would just add #NoTrayIcon and make the help message box appear when you first run it, and yes, I also would like to see a keyboard shortcut

Maybe like this

#include<Misc.au3>
#NoTrayIcon

_Singleton("Monitor Manager")

Opt("WinTitleMatchMode", 4)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

Global Const $lciWM_SYSCommand = 274
Global Const $lciSC_MonitorPower = 61808
Global Const $lciPower_Off = 2
Global Const $lciPower_On = -1
Global $Msg = 1

HotKeySet("{Pause}", "_Bye")
HotKeySet("+1", "_Off")
HotKeySet("+2", "_On")

_Help()

$dll = DllOpen("user32.dll")
$menu = TrayCreateItem("Help")
$hwnd = WinGetHandle("classname=Progman")
TrayItemSetOnEvent($menu, "_Help")

While 1
    If _IsPressed("01") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0 Then
        While _IsPressed("01")
            Sleep(1)
        WEnd
        $Msg = Not $Msg
        If Not $Msg Then
            Do
                _Off()
                Sleep(1)
            Until _IsPressed("01") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0
        Else
            _On()
        EndIf
    EndIf
    If _IsPressed("02") And MouseGetPos(0) = 0 And MouseGetPos(1) = 0 Then
        While _IsPressed("02")
            Sleep(1)
        WEnd
        _On()
        _Bye()
    EndIf
    Sleep(1)
WEnd
Func _Help()
    MsgBox(64, "Instruction", "Left Click Top Left Screen - On/Off" & @CRLF & "Right Click Top Left Screen - Exit" & @CRLF & "Shift+1 - Hide" & @CRLF & "Shift + 2 - Show" & @CRLF & "Pause|Break - Exit" & @CRLF & @CRLF & @CRLF & "This will close in 5 seconds", 5)
EndFunc ;==>_Help
Func _On()
    DllCall($dll, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)
EndFunc ;==>_On
Func _Off()
    DllCall($dll, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)
EndFunc ;==>_Off
Func _Bye()
    Exit
EndFunc ;==>_Bye
Edited by magician13134
Link to comment
Share on other sites

There are few reasons i prefer mouse over key:

- In any situation, left click on top left screen is the fastest

- The reason top left screen is used because it is the least use spot in the screen

- Even you can't see anything you can keep moving mouse to top left and make a click

- AutoIt hotkey takes over all programs hotkey, though _IsPressed can be used but as i mentioned it is the fastest way and least effecting anything work or progress being made on computer

Glad you all like it, change the script to suit your need.

Link to comment
Share on other sites

  • 1 month later...

Hey this is really useful, as I use my monitor as my Xbox 360 display, and whenever I want to switch over to the Xbox while the PC screen had priority, I would have to fiddle with the buttons on the monitor, now its one easy click ;)

Though there is one thing, I don't have a set screensaver, and when I do the wheel-click it doesn't give the prescribed error, but rather the folder directory of the script pops open. :P

Link to comment
Share on other sites

Hey this is really useful, as I use my monitor as my Xbox 360 display, and whenever I want to switch over to the Xbox while the PC screen had priority, I would have to fiddle with the buttons on the monitor, now its one easy click ;)

Though there is one thing, I don't have a set screensaver, and when I do the wheel-click it doesn't give the prescribed error, but rather the folder directory of the script pops open. :P

Glad you liked it, play with the source for you own need.
Link to comment
Share on other sites

  • 2 months later...

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