Jump to content
Sign in to follow this  
Rancar

Turn monitor off

Recommended Posts

Rancar

Hi,

First, excuse me for my english, I'm Belgian and I usually speak French.

I have a problem and I need your help :)

I need turn off my monitor to make believe the computer is extinct. I found a nice script on this forum ('?do=embed' frameborder='0' data-embedContent>>) but it doesn't work like I want.

When I move the mouse or I hit on the keyboard, the monitor turn on 1 or 2 seconds and after turn off.

I want remove this 1 or 2 seconds when the monitor is on. I want not create a dark GUI.

I am on a W7 Pro SP1 64Bits.

Here is the script inspered by the script posted above. I just added a HotKey for exit the script. 

#include <BlockInputEx.au3>
HotKeySet("{TAB}", "Terminate")
_blockinputex(2)
_monitor_off()
While 1
    Sleep(1000)
WEnd

Func terminate()
    _monitor_on()
    Exit
EndFunc

Func _monitor_on()
    Global $lciwm_syscommand = 274
    Global $lcisc_monitorpower = 61808
    Global $lcipower_off = 2
    Global $lcipower_on = -1
    Global $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()
    Global $lciwm_syscommand = 274
    Global $lcisc_monitorpower = 61808
    Global $lcipower_off = 2
    Global $lcipower_on = -1
    $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)
        Sleep(1)
    WEnd
EndFunc 

If you don't understand what I said, please tell me :)

Thanks for your help :)

Ricardo.

Share this post


Link to post
Share on other sites
MHz

$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)
        Sleep(1)
    WEnd
EndFunc 

See the part of code quoted. You enter into the _monitor_off() function which sets $monitorisoff to true. Then enter into a While loop to continue looping until $monitorisoff changes to false. There is nothing in that loop which will change the state of $monitorisoff. So you are trapped in that loop which continually turns your monitor off.

Look at the link you gave and there you may see that MrCreatoR uses the _IdleWaitCommit() function to change the setting of $monitorisoff. The link is where your answer is.

Edit:

I reread your question and perhaps misunderstood your problem. As for the monitor coming on for 1 to 2 seconds, that is perhaps unavoidable. It may be your monitor gets that brief signal and takes that long to switch off again.

Also note that BlockInput() returns 0 if #RequireAdmin is not used. This BlockInputEx.au3 that you include may have a similar requirement?

Edited by MHz

Share this post


Link to post
Share on other sites
Rancar

I tested _IddleWaitCommit in my first script but it didn't work :/

It is imposible to remove these one or two seconds ?

I am watching for disable the touchpad without BlockInput but with the Control Panel of Windows. (In the proprety of the mouse).

It is possible in AutoIT ?

I tested and this work when I disable the touchpad in the Control Panel =)

EDIT : 

I found to disable the TouchPad. Now I'm searching for disable the keyboard :)

Note:  My computer is in French ^^

Run("control.exe main.cpl,")
WinWait("Propriétés de : Souris")
ControlCommand("Propriétés de : Souris","","SysTabControl321","TabRight","")
ControlCommand("Propriétés de : Souris","","SysTabControl321","TabRight","")
ControlCommand("Propriétés de : Souris","","SysTabControl321","TabRight","")
ControlCommand("Propriétés de : Souris","","SysTabControl321","TabRight","")
ControlCommand("Propriétés de : Souris","","SysTabControl321","TabRight","")
Sleep(2000)
ControlClick("Propriétés de : Souris","",1311)
Sleep(1000)
ControlClick("Avertissement","",1)
Winclose("Propriétés de : Souris","")
Edited by Rancar

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×