Jump to content

simple script doesnt work


aphesia
 Share

Recommended Posts

#include <Timers.au3>;same as Timers.au3

Opt("WinTitleMatchMode", -2); Makes it case insensitive, but still substring

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

while 1

If _Timer_GetIdleTime() > "5000" Then

if WinActive("dvd") = 0 And WinActive("firefox") = 0 And WinActive("player") = 0 Then

Monitor("off")

EndIf

EndIf

WEnd

it should work.. but it doesnt ^_^

why ? :)

also tried to give the whole func thigny on the end (after wend) but will dont work. :)

Edited by aphesia
Link to comment
Share on other sites

it should work.. but it doesnt :huh2:

why ? :)

also tried to give the whole func thigny on the end (after wend) but will dont work. ^_^

Are you saying the window does not receive the message? That message is sent on an event (changing the monitor power state). I don't think it will cause the monitor to change state.

:)

Edit: I was wrong, it does work.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

this turns of the monitor:

#include <Timers.au3>

Opt("WinTitleMatchMode", 4)

_Timer_GetIdleTime()

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

my script (above) should do it after a time of inacitivty.. but it doesnt :)

Link to comment
Share on other sites

this turns of the monitor:

my script (above) should do it after a time of inacitivty.. but it doesnt :)

Well, I was wrong. It works fine for me and turns the monitor off until I move the mouse.

Are you sure the monitor you have supports power management?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Your first script isn't finding "classname=Progman" because you've set the window match mode to -2.

Put this at the top of your Monitor function: Opt("WinTitleMatchMode", 4)

You can set it back to -2 if you want before exiting your function.

Hope that helps.

--Kris

EDIT: Even easier, yet; don't change the "Opt" just change "classname=Progman" to "Program Manager"

Edited by Envoi
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...