Sign in to follow this  
Followers 0
GodandRock

Screen Blackout And Mouse Disappear

12 posts in this topic

#1 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Wow dude thanks a lot. Thats pretty cool. Also, can the GUI be in @SW_HIDE mode and it still works?


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

Share this post


Link to post
Share on other sites

Something I just noticed - GUISetCursor(16) does the same thing (hides the cursor). And no, it has to be showing - only while the cursor is over a visible GUI does it work.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


Umbrella Member

Share this post


Link to post
Share on other sites

ihenvyr, you are spamming dude. We all read you the first time, if someone wants to help you out they will, no need to spam.


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

Share this post


Link to post
Share on other sites

#11 ·  Posted

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 :)


Share this post


Link to post
Share on other sites

bump


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  
Followers 0