Jump to content

Screen Blackout And Mouse Disappear


Recommended Posts

Hello. I was thinking and I got an idea. You know when you set a timer for your monitor to turn off in Win XP, it turns off if you're idle for that long. I was thinking, this is software related. So is there a way in AutoIt so that you can turn off the monitor?

Second idea is the mouse disappearing. Like when you're watching a movie on your computer. Certain programs make your mouse disappear after idling for a few seconds. So is there a way you can make the mouse disappear using AutoIt? Thank you.

<<<------------ YAY! 50'th post!

Edited by GodandRock

[font="Fixedsys"][size="3"][u][font="Franklin Gothic Medium"] [/font][/u][/size][/font]

Link to comment
Share on other sites

Monitor Toggle:

MonitorToggle(1)
Sleep (20000)
MonitorToggle(0)

Func MonitorToggle($Off = 1)
    $opt = Opt("WinTitleMatchMode", 4)

    $WM_SYSCommand = 274
    $SC_MonitorPower = 61808
    $Power_Off = 2
    $Power_On = -1
    
    $HWND = WinGetHandle("classname=Progman")
    If $Off Then
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_Off)
    Else
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_On)
    EndIf
    Opt ("WinTitleMatchMode", $opt)
EndFunc

Hide cursor (only while over GUI):

GUICreate ("cursor")
GUISetState ()
DllCall("user32.dll", "int", "ShowCursor", "int", 0);HIDE CURSOR
Sleep (10000)
DllCall("user32.dll", "int", "ShowCursor", "int", 1);SHOW CURSOR
Sleep (1000)

P.S. - it helps to search.

Edited by greenmachine
Link to comment
Share on other sites

Monitor Toggle:

MonitorToggle(1)
Sleep (20000)
MonitorToggle(0)

Func MonitorToggle($Off = 1)
    $opt = Opt("WinTitleMatchMode", 4)

    $WM_SYSCommand = 274
    $SC_MonitorPower = 61808
    $Power_Off = 2
    $Power_On = -1
    
    $HWND = WinGetHandle("classname=Progman")
    If $Off Then
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_Off)
    Else
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_On)
    EndIf
    Opt ("WinTitleMatchMode", $opt)
EndFunc

Hide cursor (only while over GUI):

GUICreate ("cursor")
GUISetState ()
DllCall("user32.dll", "int", "ShowCursor", "int", 0);HIDE CURSOR
Sleep (10000)
DllCall("user32.dll", "int", "ShowCursor", "int", 1);SHOW CURSOR
Sleep (1000)

P.S. - it helps to search.

hello!! i just wanna ask if it works for TV as monitor?? is there a way to turn of TV as well?

or any recommendations? thanks... :think:

Edited by ihenvyr

Umbrella Member

Link to comment
Share on other sites

Attempt to hide mouse. Requires Win 2000/XP for WinSetTrans to work. Press Escape to exit the script.

#include <GuiConstants.au3>

HotKeySet("{Esc}", "Quit")
Func Quit()
    Exit
EndFunc

$MyGUI = GuiCreate("",@DesktopWidth+9, @DesktopHeight+9, -9, -9, BitOR($WS_POPUP, $WS_DLGFRAME))
GuiSetBkColor(0x0)

GuiSetState()
WinSetOnTop($MyGUI, "", 1)

WinSetTrans($MyGUI, "", 1);almost transparent; opacity value of 0 doesn't hide mouse
GuiSetCursor(16)
While 1
    sleep(10)
    $mouse = GUIGetCursorInfo()
    If @error Then ContinueLoop

; Attempt to pass on mouse clicks just for fun (not required)
    If $mouse[2] Then;primary down
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("primary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    ElseIf $mouse[3] Then;right-click
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("secondary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    EndIf
Wend
Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Attempt to hide mouse. Requires Win 2000/XP for WinSetTrans to work. Press Escape to exit the script.

#include <GuiConstants.au3>

HotKeySet("{Esc}", "Quit")
Func Quit()
    Exit
EndFunc

$MyGUI = GuiCreate("",@DesktopWidth+9, @DesktopHeight+9, -9, -9, BitOR($WS_POPUP, $WS_DLGFRAME))
GuiSetBkColor(0x0)

GuiSetState()
WinSetOnTop($MyGUI, "", 1)

WinSetTrans($MyGUI, "", 1);almost transparent; opacity value of 0 doesn't hide mouse
GuiSetCursor(16)
While 1
    sleep(10)
    $mouse = GUIGetCursorInfo()
    If @error Then ContinueLoop

; Attempt to pass on mouse clicks just for fun (not required)
    If $mouse[2] Then;primary down
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("primary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    ElseIf $mouse[3] Then;right-click
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("secondary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    EndIf
Wend
thanks you very much..

but this:

MonitorToggle(1)
Sleep (5000)
MonitorToggle(0)

Func MonitorToggle($Off = 1)
    $opt = Opt("WinTitleMatchMode", 4)

    $WM_SYSCommand = 274
    $SC_MonitorPower = 61808
    $Power_Off = 2
    $Power_On = -1
    
    $HWND = WinGetHandle("classname=Progman")
    If $Off Then
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_Off)
    Else
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_On)
    EndIf
    Opt ("WinTitleMatchMode", $opt)
EndFunc

is there a way to turn of TV as well? -if i use TV as my monitor..

or to turn TV display to black?

any recommendations? thanks... :think:

Edited by ihenvyr

Umbrella Member

Link to comment
Share on other sites

  • 3 weeks later...

Monitor Toggle:

MonitorToggle(1)
Sleep (20000)
MonitorToggle(0)

Func MonitorToggle($Off = 1)
    $opt = Opt("WinTitleMatchMode", 4)

    $WM_SYSCommand = 274
    $SC_MonitorPower = 61808
    $Power_Off = 2
    $Power_On = -1
    
    $HWND = WinGetHandle("classname=Progman")
    If $Off Then
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_Off)
    Else
        DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ 
        "int", $SC_MonitorPower, "int", $Power_On)
    EndIf
    Opt ("WinTitleMatchMode", $opt)
EndFunc

is there a way to make it so:

you turn it off via hotkey,

you can't turn it back on by moving the mouse,

but you can turn it back by pressing that hotkey again (toggle)

thanks :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...