Draygoes Posted September 3, 2007 Share Posted September 3, 2007 Im building a moniter sleeper program. This is my code so far... Func _Mononoff() Opt("WinTitleMatchMode", 4) $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) Sleep(90000) endfunc _mononoff() The problem is, the moniter is activated when the user presses a key but the program is still running. I need the program to be able to tell when the user presses the key or moves the mouse so it can exit. I have no idea how to go about doing this. I cant find much info in the help file about that. Could anyone give me an example of the code? thx Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Draygoes Posted September 3, 2007 Author Share Posted September 3, 2007 Did I say something wrong? Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Generator Posted September 3, 2007 Share Posted September 3, 2007 My version i guess...i use it in school sometimes.. expandcollapse popupOpt("WinTitleMatchMode", 4) Opt("TrayMenuMode", 1) Opt("TrayOnEventMode", 1) Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 Global $Msg = "Idle" HotKeySet("^!o", "_On") HotKeySet("^!f", "_Off") HotKeySet("^!i", "_Idle") HotKeySet("^!e", "_Bye") $menu = TrayCreateMenu("Help") $on = TrayCreateItem("Monitor On" & @TAB & "Ctrl+Alt+O", $menu) $off = TrayCreateItem("Monitor Off" & @TAB & "Ctrl+Alt+F", $menu) $idle = TrayCreateItem("Monitor Idle" & @TAB & "Ctrl+Alt+I", $menu) $Quititem = TrayCreateItem("Exit" & @TAB & "Ctrl+Alt+E", $menu) $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") While 1 Sleep(1) WEnd Func _On() $Msg = "On" While $Msg = "On" DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On) Sleep(1) WEnd EndFunc ;==>_On Func _Off() $Msg = "Off" While $Msg = "Off" DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) Sleep(1) WEnd EndFunc ;==>_Off Func _Idle() $Msg = "Idle" EndFunc ;==>_Idle Func _Bye() $Msg = "Idle" DllClose($user32) Exit EndFunc ;==>_Bye Link to comment Share on other sites More sharing options...
Draygoes Posted September 3, 2007 Author Share Posted September 3, 2007 Thanks but im looking for a way to tell when they have pressed any key on the keyboard. For example, If userpressesanykey Then Exit Endif Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Generator Posted September 4, 2007 Share Posted September 4, 2007 _IsPressed() 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