James Posted February 12, 2008 Posted February 12, 2008 Nothing special I made a tray program for my friend so his monitor will turn off after a set time then turn back on after another time. Here is the Monitor control part: Opt("WinTitleMatchMode", 4) Monitor("off") Func Monitor($io_control = "on") Local $WM_SYSCommand = 274 Local $SC_MonitorPower = 61808 Local $HWND = WinGetHandle("classname=Progman") Switch StringUpper($io_control) Case "OFF" DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", 2) Case "ON" DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", -1) Case Else MsgBox(32, @ScriptName, "Command usage: on/off") EndSwitch EndFunc The commands were from the feature request, I just made it into a function. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
mikidutza Posted February 13, 2008 Posted February 13, 2008 it's a great function , i realy think i wil need this function. do you think you can make a function to chek if the monitor is off or on?? keep up the good work
James Posted February 13, 2008 Author Posted February 13, 2008 I can most certainly look to see if there was. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
fastnick1oo Posted February 16, 2008 Posted February 16, 2008 Great func, I love it. SciTE - much better than notepad. ; ]
James Posted February 16, 2008 Author Posted February 16, 2008 Thanks good for power saving! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
TPaul81 Posted February 17, 2008 Posted February 17, 2008 (edited) Thanks good for power saving!I can think of many-many-many useful stuff for it on April 1st. Edited February 17, 2008 by TPaul81 My Scripts (so far)Myspace Layout EditorAnother Boss ScreenClipboard Collector
James Posted February 17, 2008 Author Posted February 17, 2008 Be good lol. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Trystian Posted April 24, 2009 Posted April 24, 2009 (edited) Hey, great function James. I hope you don't mind, but I added the "powersave" functionality, along with turning on the screensaver. expandcollapse popup;=============================================================================== ; Function Name: _Monitor() ; Description: Changes the state of the monitor or turns on screensaver. ; Syntax: _Monitor ( [$sIo_control] ) ; ; Parameter(s): $sIo_control = The command to send (default = "on"). ; "on" turns on monitor. ; "off" turns off monitor. ; "powersave" puts monitor(s) in powersave mode. ; "screensaver" turns on screensaver, if one has been selected in Windows. ; ; Requirement(s): External: = user32.dll (it's already in system32). ; Internal: = None. ; ; Author(s): Original function by JamesBrooks (on/off). Modified by TrystianSky (added powersave/screensaver). ; ; Example(s): ; _Monitor("powersave") ;=============================================================================== Func _Monitor($sIo_control = "on") Local $iWM_SYSCommand = 274 Local $iSC_MonitorPower = 61808 Local $iSC_ScreenSave = 61760 Local $hWnd = WinGetHandle("[CLASS:Progman]") Switch StringUpper($sIo_control) Case "OFF" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", 2) Case "ON" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", -1) Case "POWERSAVE" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", 1) Case "SCREENSAVER" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_ScreenSave, "int", 0) Case Else MsgBox(64, @ScriptName, "Command usage: on/off/powersave/screensaver") EndSwitch EndFunc;==>_Monitor Edit: Changed WinGetHandle call. Thanks Authenticity. Edited April 29, 2009 by TrystianSky
dmob Posted April 25, 2009 Posted April 25, 2009 Hey, great function James. I hope you don't mind, but I added the "powersave" functionality, along with turning on the screensaver. expandcollapse popup;=============================================================================== ; Function Name: _Monitor() ; Description: Changes the state of the monitor or turns on screensaver. ; Syntax: _Monitor ( [$sIo_control] ) ; ; Parameter(s): $sIo_control = The command to send (default = "on"). ; "on" turns on monitor. ; "off" turns off monitor. ; "powersave" puts monitor(s) in powersave mode. ; "screensaver" turns on screensaver, if one has been selected in Windows. ; ; Requirement(s): External: = user32.dll (it's already in system32). ; Internal: = None. ; ; Author(s): Original function by JamesBrooks (on/off). Modified by TrystianSky (added powersave/screensaver). ; ; Example(s): ; _Monitor("powersave") ;=============================================================================== Func _Monitor($sIo_control = "on") Local $iWM_SYSCommand = 274 Local $iSC_MonitorPower = 61808 Local $iSC_ScreenSave = 61760 Local $hWnd = WinGetHandle("classname=Progman") Local $iRet = 1 Switch StringUpper($sIo_control) Case "OFF" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", 2) Case "ON" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", -1) Case "POWERSAVE" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", 1) Case "SCREENSAVER" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_ScreenSave, "int", 0) Case Else MsgBox(64, @ScriptName, "Command usage: on/off/powersave/screensaver") EndSwitch EndFunc ;==>_Monitor nothing happens on my monitor with any of the parameters. I'm using WinXP SP3 and AI 3
Authenticity Posted April 25, 2009 Posted April 25, 2009 Either insert in the header Opt("WinTitleMatchMode", 4) or change WinGetHandle("classname=Progman") to WinGetHandle("[CLASS:Progman]")
dmob Posted April 29, 2009 Posted April 29, 2009 Either insert in the header Opt("WinTitleMatchMode", 4) or change WinGetHandle("classname=Progman") to WinGetHandle("[CLASS:Progman]") Great call! Works beautifully now. Thanks fro the help.
Yashied Posted April 29, 2009 Posted April 29, 2009 Useful function. Thanks. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Trystian Posted April 29, 2009 Posted April 29, 2009 Thanks for the feedback dmob. I forgot to change the winhandle call. Either insert in the header Opt("WinTitleMatchMode", 4) or change WinGetHandle("classname=Progman") to WinGetHandle("[CLASS:Progman]") Thanks Authenticity. Decided to use WinGetHandle("[CLASS:Progman]") instead of Opt("WinTitleMatchMode", 4) to make the function play well with other functions. =)
rajeshontheweb Posted May 5, 2009 Posted May 5, 2009 guys, can we add wake on hot key support? i mean can this work like a pc on monitor off mode, a mouse movement or keyboard sroke will wake up the monitor? Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
James Posted May 9, 2009 Author Posted May 9, 2009 guys, can we add wake on hot key support? i mean can this work like a pc on monitor off mode, a mouse movement or keyboard sroke will wake up the monitor?Of course. HotKeySet("!{F7}", "On") HotKeySet("!{F7}", "Off") While 1 Sleep(500) Wend Func Off() _Monitor("off") EndFunc Func On() _Monitor() EndFunc Func _Monitor($sIo_control = "on") Local $iWM_SYSCommand = 274 Local $iSC_MonitorPower = 61808 Local $iSC_ScreenSave = 61760 Local $hWnd = WinGetHandle("[CLASS:Progman]") Switch StringUpper($sIo_control) Case "OFF" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", 2) Case "ON" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", -1) Case "POWERSAVE" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_MonitorPower, "int", 1) Case "SCREENSAVER" DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $iWM_SYSCommand, "int", $iSC_ScreenSave, "int", 0) Case Else MsgBox(64, @ScriptName, "Command usage: on/off/powersave/screensaver") EndSwitch EndFunc;==>_Monitor Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
yousifucv Posted May 10, 2009 Posted May 10, 2009 If you have dual (or more) monitors, can you control each of them individually? Like make the secondary one powersave after 5mins of inactivity and leave the primary one alone.
newcomer44 Posted May 19, 2009 Posted May 19, 2009 Hello, if I run the script part from Post#1 it switches the monitor "Off". But if I move the mouse, the monitor switches "On". I want, that the monitor remains in "Off"- status and switches "On" if I push a key or a mouse button. If I run the script part from Post#15 and push "Alt"+"F7" the monitor switches "Off" for a second, then switches "On". It should show the same behavior as I wrote before. I don't know, how to realize this in a script. I want this for my notebook (laptop), which has no switch to turn off the display. Can anybody help me please? Perhaps the author? Thanks
loukaniko Posted June 12, 2009 Posted June 12, 2009 Hello. anyone can add a handle or something to select which monitor to turn off (primary secondary) What I should look to change it? I want to make a camera controled powersave mode. I have made the camera/motion detect issue, but I don't know anything about the monitor
James Posted June 12, 2009 Author Posted June 12, 2009 Hello. anyone can add a handle or something to select which monitor to turn off (primary secondary)What I should look to change it?I want to make a camera controled powersave mode. I have made the camera/motion detect issue, but I don't know anything about the monitor Hmm, I never thought about multi monitors. I'll take a look around. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
mercessb Posted June 14, 2012 Posted June 14, 2012 I was wondering have you figured out how to do Monitor Control over multi monitors? Thanks
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