MrCreatoR Posted November 19, 2007 Share Posted November 19, 2007 Hi all,This example shows how you can turn off your monitor, so even mouse move can not turn it on back.The main function to turn on/off monitor is taken from Help file example, and was changed for this example's needs.The function _IdleWaitCommit() i think written by amel27, and also have been changed.Here it is:expandcollapse popup#NoTrayIcon Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 Global $MonitorIsOff = False HotKeySet("{F11}", "_Monitor_OFF") HotKeySet("{F10}", "_Monitor_ON") HotKeySet("{Esc}", "_Quit") MsgBox(64, "Monitor On/Off", "Press F11 to turn off the monitor." & @LF & _ "Press F10 to turn on the monitor back." & @LF & _ "Press ESC to turn on the monitor and exit program.") While 1 Sleep(10) WEnd Func _Monitor_ON() $MonitorIsOff = False Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]') DllCall('user32.dll', 'int', 'SendMessage', _ 'hwnd', $Progman_hwnd, _ 'int', $lciWM_SYSCommand, _ 'int', $lciSC_MonitorPower, _ 'int', $lciPower_On) EndFunc Func _Monitor_OFF() $MonitorIsOff = True Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]') While $MonitorIsOff = True DllCall('user32.dll', 'int', 'SendMessage', _ 'hwnd', $Progman_hwnd, _ 'int', $lciWM_SYSCommand, _ 'int', $lciSC_MonitorPower, _ 'int', $lciPower_Off) _IdleWaitCommit(0) Sleep(20) WEnd EndFunc Func _IdleWaitCommit($idlesec) Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword") DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo)) DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo)) Do $iSave = DllStructGetData ($LastInputInfo, 2) Sleep(60) DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo)) Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False Return DllStructGetData ($LastInputInfo, 2)-$iSave EndFunc Func _Quit() _Monitor_ON() Exit EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
zfisherdrums Posted November 19, 2007 Share Posted November 19, 2007 That's really cool|good! Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
sosimple Posted November 26, 2007 Share Posted November 26, 2007 Thanks, I was trying to do this, and i found here.... Link to comment Share on other sites More sharing options...
AscaroN Posted December 2, 2007 Share Posted December 2, 2007 Very Nice, but is it possible to auto turn off and auto tur on after like 3 seconds, i tried send("{f11}") sleep(3000) send("{f10}")oÝ÷ Ù»Ú'+n®w¡÷ÚÛazx®'jëh×6send("{f11}") sleep(3000) _Monitor_OFF() and still not worked, maybe you can help me? Link to comment Share on other sites More sharing options...
MrCreatoR Posted December 2, 2007 Author Share Posted December 2, 2007 is it possible to auto turn off and auto tur on after like 3 secondsYou will need to change these functions a little: While 1 _Monitor_OFF() ;this will turn off monitor and sleep 3000 _Monitor_ON() Sleep(3000) WEnd Func _Monitor_OFF() $MonitorIsOff = True Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]') Local $TimerInit = TimerInit() While $MonitorIsOff = True And TimerDiff($TimerInit) < 3000 DllCall('user32.dll', 'int', 'SendMessage', _ 'hwnd', $Progman_hwnd, _ 'int', $lciWM_SYSCommand, _ 'int', $lciSC_MonitorPower, _ 'int', $lciPower_Off) _IdleWaitCommit(0, $TimerInit) Sleep(20) WEnd EndFunc Func _IdleWaitCommit($idlesec, $TimerInit=-1) Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword") DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo)) DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo)) Do $iSave = DllStructGetData ($LastInputInfo, 2) Sleep(60) DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo)) If $TimerInit <> -1 And TimerDiff($TimerInit) >= 3000 Then ExitLoop Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False Return DllStructGetData ($LastInputInfo, 2)-$iSave EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
AscaroN Posted December 2, 2007 Share Posted December 2, 2007 Thank You Link to comment Share on other sites More sharing options...
Cerberuschow Posted December 3, 2007 Share Posted December 3, 2007 Strange... on my laptop it only disables the screen for a few seconds... Link to comment Share on other sites More sharing options...
jzn2 Posted April 7, 2008 Share Posted April 7, 2008 sounds like a useful covert script... Link to comment Share on other sites More sharing options...
mdixon Posted April 8, 2008 Share Posted April 8, 2008 Strange... on my laptop it only disables the screen for a few seconds...^^ Mine too. Any ideas? Link to comment Share on other sites More sharing options...
GEOSoft Posted April 9, 2008 Share Posted April 9, 2008 ^^ Mine too. Any ideas?If you read the script you will see that it only turns the monitor off for 3 seconds ( sleep(3000) ) before turning it back on. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
mdixon Posted April 9, 2008 Share Posted April 9, 2008 If you read the script you will see that it only turns the monitor off for 3 seconds ( sleep(3000) ) before turning it back on.Sorry, I should have said... I'm trying to run the original script... the one without the sleep(3000) thing. I'm running XPsp2 on a laptop. Link to comment Share on other sites More sharing options...
mdixon Posted April 9, 2008 Share Posted April 9, 2008 On further investigation... if I've pressed F11, the monitor turns off for a second or so whenever I move the mouse or press a key. So the turning off thing isn't a problem. It's just that for some reason either my monitor keeps turning back on after a second or so. Curiouser and curiouser! Link to comment Share on other sites More sharing options...
MrCreatoR Posted April 9, 2008 Author Share Posted April 9, 2008 @mdixon What AutoIt version you are using? and what system? And have you tried to play with other hotkeys? maybe some external app on your system (some forgotten AutoIt script?) hits the F10 hotkey? Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
mdixon Posted April 9, 2008 Share Posted April 9, 2008 @mdixonWhat AutoIt version you are using? and what system?And have you tried to play with other hotkeys? maybe some external app on your system (some forgotten AutoIt script?) hits the F10 hotkey? I'm using AutoIt v3.2 on an XP SP2 laptop (ASUS A6T).I've tried with other hotkeys, and that's not the problem. The same behaviour occurs. I will describe exactly what happens.I start the script. The message box pops up. Yay, all good so far.I close the message box. Windows runs as per usual.I press F11, the screen goes blank.About a second later, the screen turns back on.I press a key, the screen goes blank, and about a second later, it turns back on.I move the mouse, the screen goes blank, and about a second later, it turns back on.If I continually move the mouse, the screen goes black, but flickers every second or so, as if it's trying to turn on but is turned off again immediately.If I press F10, the screen turns on or stays on.If I press esc, the script exits.I think this must be a hardware issue of some sort. But I can't see what's causing it. Link to comment Share on other sites More sharing options...
ResNullius Posted April 9, 2008 Share Posted April 9, 2008 I can confirm mdixon's results on my (Toshiba) laptop with XP sp3, and AutoIt 3.2.10/Beta 3.2.11.5Slightly different twist though, if I hit F11 before I click OK on the instruction msgbox, my screen will stay blank until I move the mouse or touch a key. Then it starts the whole "on-off" routine. Interestingly, if I hit F11 before I dismiss the msgbox and i dismiss the msgbox by hitting ENTER rather than clicking OK with the mouse, the screen goes off, comes back on and then will go on-off as I hit keys or move the mouse. Link to comment Share on other sites More sharing options...
UEZ Posted April 12, 2008 Share Posted April 12, 2008 Same on my Laptop (Vista). Btw, is it possible to turn off only one monitor if you use dual view (e.g. laptop monitor and connected external monitor)? Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Ontosy Posted April 13, 2008 Share Posted April 13, 2008 On my system some software turn on the monitor though not press buttons or move the mouse. Is there a way to check the check the status of the monitor if it is turned off or or? Link to comment Share on other sites More sharing options...
potitpanda Posted April 21, 2008 Share Posted April 21, 2008 (edited) Hi everybody How can I Modify this script in order to "Monitor_ON" if Mouse Moves when my monitor is in "Monitor_OFF" Thanks for responding Potit Panda Edited April 21, 2008 by potitpanda Link to comment Share on other sites More sharing options...
goldenix Posted November 24, 2008 Share Posted November 24, 2008 (edited) I start the script , after few seconds maybe 10 or so the screen is turned on & then off again & if flickers like this constantly.It must be the mouse that is turning the monitor off, cuz after I turned off my mouse screen stayed turned off. But if I move my mouse purposely, the screen is not turned on. This is weird.Well ether way this code is a real life saver. will just have to figure out how keep the screen turned off until i hit the hotkey.EDIT: I dont know why, but it works fine now.An idea, what you can do with this script:there was this project where ppl tried to force the user to go away from the computer for 5 min every hour or so. but since ppl were to smart for their own good+limitations of autoitscropt, nothing came out of it. Now think: you kill the screen & no mater what you press it will stay blank for 5 min. & you cant do anything about it. so its a perfect solution.! Edited December 3, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
FireFox Posted December 24, 2008 Share Posted December 24, 2008 (edited) @MrCreatoR Ive little modified your function because it wasnt easy to handle with some scripts... btw, ive deleted _IdleWaitCommit function because it works fine without Function _Monitor Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 Func _Monitor($run = 1) Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]') If $run = 0 Then BlockInput(1) DllCall('user32.dll', 'int', 'SendMessage', _ 'hwnd', $Progman_hwnd, _ 'int', $lciWM_SYSCommand, _ 'int', $lciSC_MonitorPower, _ 'int', $lciPower_Off) Return 1 ElseIf $run = 1 Then BlockInput(0) DllCall('user32.dll', 'int', 'SendMessage', _ 'hwnd', $Progman_hwnd, _ 'int', $lciWM_SYSCommand, _ 'int', $lciSC_MonitorPower, _ 'int', $lciPower_On) Return 1 EndIf Return 0 EndFunc ;==>_MonitoroÝ÷ ØLZ^jëh×6_Monitor(0) ;Turn off monitor Sleep(10000) ;Wait 10 seconds _Monitor(1) ;Turn on monitor Edit : Hum..._IdleWaitCommit is for mouse movement... but I dont think I have to add it Edit 2 : Added BlockInput Edited December 24, 2008 by FireFox Link to comment Share on other sites More sharing options...
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