Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: sendkkey for monitor turnoff

  1. #1
    Constant Bitrate
    Join Date
    Aug 2007
    Posts
    171

    sendkkey for monitor turnoff

    I'm trying to add these buttons to the autoit script but I can not, someone could help me "MONITOR_OFF" , "MONITOR_ON" , "MONITOR_ESC"

    Code:
    #NoTrayIcon
    
    ;*****************************************connexion  RR**************************************
    Global Const $StructDef_COPYDATA = "ptr;dword;ptr"
    ;Global Const $WM_COPYDATA = 0x4A
    ;Global Const $WM_CLOSE = 0x10
    Global Const $STRUCTDEF_AU3MESSAGE = "char[255]"
    
    $rr = ObjCreate("RoadRunner.SDK")
    
    Global Const $lciWM_SYSCommand = 274
    Global Const $lciSC_MonitorPower = 61808
    Global Const $lciPower_Off = 2
    Global Const $lciPower_On = -1
    
    Global $MonitorIsOff = False
    
    HotKeySet("{F11}", "_Monitor_OFF")
    HotKeySet("{F10}", "_Monitor_ON")
    HotKeySet("{Esc}", "_Quit")
    
    ;~ MsgBox(64, "Monitor On/Off", "Press F11 to turn off the monitor." & @LF & _
    ;~                             "Press F10 to turn on the monitor back." & @LF & _
    ;~                             "Press ESC to turn on the monitor and exit program.")
    
    While 1
        Sleep(10)
    WEnd
    
    Func _Monitor_ON()
        $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()
        $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)
            _IdleWaitCommit(0)
            Sleep(20)
        WEnd
    EndFunc
    
    Func _IdleWaitCommit($idlesec)
        Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword")
        DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))
        DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        Do
            $iSave = DllStructGetData ($LastInputInfo, 2)
            Sleep(60)
            DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False
        Return DllStructGetData ($LastInputInfo, 2)-$iSave
    EndFunc
    
    Func _Quit()
        _Monitor_ON()
        Exit
     EndFunc
    
     ;**********************************************connexion  RR*************************************************
    ;***********************************************************************************************************
    
    ; Message Handler
    Func _GUIRegisterMsgProc($hWnd, $MsgID, $WParam, $LParam)
    	If $MsgID = $WM_COPYDATA Then
    		; We Recived a WM_COPYDATA Message
    		; $LParam = Poiter to a COPYDATA Struct
    		$vs_cds = DllStructCreate($StructDef_COPYDATA, $LParam)
    		; Member No. 3 of COPYDATA Struct (PVOID lpData;) = Pointer to Costum Struct
    		$vs_msg = DllStructCreate($STRUCTDEF_AU3MESSAGE, DllStructGetData($vs_cds, 3))
    
    		$SciTECmdLen = DllStructGetData($vs_cds, 2)
    		$cmd = StringLeft(DllStructGetData($vs_msg, 1), $SciTECmdLen)
    
    		; Display what we have recived
    		;MsgBox(0, "Test String", $cmd)
    
    	ElseIf $MsgID = $WM_CLOSE Then
    	; We Recived a WM_CLOSE Message
    
    	EndIf
     EndFunc ;==>_GUIRegisterMsgProc
    
     Exit

  2. #2
    Raw Wave pierrotm777's Avatar
    Join Date
    May 2008
    Location
    Bordeaux, France
    Posts
    2,867
    If you don't use rr for send these commands, just comment the RR object !

    Code:
    #NoTrayIcon
    
    ;~ ;*****************************************connexion  RR**************************************
    ;~ Global Const $StructDef_COPYDATA = "ptr;dword;ptr"
    ;~ ;Global Const $WM_COPYDATA = 0x4A
    ;~ ;Global Const $WM_CLOSE = 0x10
    ;~ Global Const $STRUCTDEF_AU3MESSAGE = "char[255]"
    
    ;$rr = ObjCreate("RoadRunner.SDK")
    
    Global Const $lciWM_SYSCommand = 274
    Global Const $lciSC_MonitorPower = 61808
    Global Const $lciPower_Off = 2
    Global Const $lciPower_On = -1
    
    Global $MonitorIsOff = False
    
    HotKeySet("{F11}", "_Monitor_OFF")
    HotKeySet("{F10}", "_Monitor_ON")
    HotKeySet("{Esc}", "_Quit")
    
    ;~ MsgBox(64, "Monitor On/Off", "Press F11 to turn off the monitor." & @LF & _
    ;~                             "Press F10 to turn on the monitor back." & @LF & _
    ;~                             "Press ESC to turn on the monitor and exit program.")
    
    While 1
        Sleep(10)
    WEnd
    
    Func _Monitor_ON()
        $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()
        $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)
            _IdleWaitCommit(0)
            Sleep(20)
        WEnd
    EndFunc
    
    Func _IdleWaitCommit($idlesec)
        Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword")
        DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))
        DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        Do
            $iSave = DllStructGetData ($LastInputInfo, 2)
            Sleep(60)
            DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False
        Return DllStructGetData ($LastInputInfo, 2)-$iSave
    EndFunc
    
    Func _Quit()
        _Monitor_ON()
        Exit
    EndFunc
    
    ;~  ;**********************************************connexion  RR*************************************************
    ;~ ;***********************************************************************************************************
    
    ;~ ; Message Handler
    ;~ Func _GUIRegisterMsgProc($hWnd, $MsgID, $WParam, $LParam)
    ;~ 	If $MsgID = $WM_COPYDATA Then
    ;~ 		; We Recived a WM_COPYDATA Message
    ;~ 		; $LParam = Poiter to a COPYDATA Struct
    ;~ 		$vs_cds = DllStructCreate($StructDef_COPYDATA, $LParam)
    ;~ 		; Member No. 3 of COPYDATA Struct (PVOID lpData;) = Pointer to Costum Struct
    ;~ 		$vs_msg = DllStructCreate($STRUCTDEF_AU3MESSAGE, DllStructGetData($vs_cds, 3))
    
    ;~ 		$SciTECmdLen = DllStructGetData($vs_cds, 2)
    ;~ 		$cmd = StringLeft(DllStructGetData($vs_msg, 1), $SciTECmdLen)
    
    ;~ 		; Display what we have recived
    ;~ 		;MsgBox(0, "Test String", $cmd)
    
    ;~ 	ElseIf $MsgID = $WM_CLOSE Then
    ;~ 	; We Recived a WM_CLOSE Message
    
    ;~ 	EndIf
    ;~  EndFunc ;==>_GUIRegisterMsgProc
    
     ;Exit
    Into the While loop, it's better to use a bigger sleep (100) (CPU will you say thanks)

  3. #3
    Constant Bitrate
    Join Date
    Aug 2007
    Posts
    171
    I want this script to turn off the monitor at night, using the touch screen, I do not use keyboard

    why I wanted to put those 3 buttons ...

    for example

    I would do a skin for this RR is working, press a button and turn off the monitor
    B,0,4,85,54,"LOAD;MONITOROFF.SKIN||MY COMMAND TO F11"

    then when you want to turn on the monitor, this command would

    L01,-2,2,802,598,255,255,255,18,"Arial","EXEC;EXIT||MY COMMAND TO F10","",


    the idea would be something like

  4. #4
    Variable Bitrate
    Join Date
    Sep 2012
    Location
    Germany - Munich
    Posts
    406
    may be is this a reason for you?:
    http://www.nirsoft.net/utils/nircmd.html

  5. #5
    Constant Bitrate
    Join Date
    Aug 2007
    Posts
    171
    but that little software only have turn off monitor or have too turn on monitor , let me see

    i only need add

    those hotkey that work with RR to this autoit

    HotKeySet("{F11}", "_Monitor_OFF")
    HotKeySet("{F10}", "_Monitor_ON")
    HotKeySet("{Esc}", "_Quit")


    with sendkey or something
    Last edited by mikeeps2; 03-07-2014 at 03:57 PM.

  6. #6
    Constant Bitrate
    Join Date
    Aug 2007
    Posts
    171
    no , that small software that does not work for me what I want

  7. #7
    Raw Wave pierrotm777's Avatar
    Join Date
    May 2008
    Location
    Bordeaux, France
    Posts
    2,867
    I think that this code will run well !
    Create 3 buttons:
    SENDMSG;MONITOR;MONITOR_ON
    SENDMSG;MONITOR;MONITOR_OFF
    SENDMSG;MONITOR;MONITOR_EXIT

    Run the script as:
    "Run;$skinpath$Scripts\MonitorOnOff.exe"

    But when the monitor is off , how do you click on the button ?

    Code:
    #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_outfile=MonitorOnOff.exe
    #AutoIt3Wrapper_Compression=4
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    ;~ ;*****************************************connexion  RR**************************************
    Global Const $StructDef_COPYDATA = "ptr;dword;ptr"
    Global Const $WM_COPYDATA = 0x4A
    Global Const $WM_CLOSE = 0x10
    Global Const $STRUCTDEF_AU3MESSAGE = "char[255]"
    
    ;create SDK for COM with RR.  This must be done ONLY once per script
    $rr = "NIL"
    $F = WinExists("RoadRunner")
    If $F = 0 Then MsgBox(0, "Error", "Google Maps need a RideRunner" & @CRLF & _
    			"process to run !!!", 5)
    If $F = 1 Then
        $rr = ObjCreate("RideRunner.SDK")
    Else
    	_Quit()
    EndIf
    
    Global Const $lciWM_SYSCommand = 274
    Global Const $lciSC_MonitorPower = 61808
    Global Const $lciPower_Off = 2
    Global Const $lciPower_On = -1
    
    Global $MonitorIsOff = False
    
    Dim $cmd
    
    HotKeySet("{F11}", "_Monitor_OFF")
    HotKeySet("{F10}", "_Monitor_ON")
    HotKeySet("{Esc}", "_Quit")
    
    ;~ MsgBox(64, "Monitor On/Off", "Press F11 to turn off the monitor." & @LF & _
    ;~                             "Press F10 to turn on the monitor back." & @LF & _
    ;~                             "Press ESC to turn on the monitor and exit program.")
    
    ; Create Reciver window
    $hwmd_Reciver = GUICreate("MONITOR")
    ; Register Windows Messages
    GUIRegisterMsg($WM_COPYDATA, "_GUIRegisterMsgProc")
    GUIRegisterMsg($WM_CLOSE, "_GUIRegisterMsgProc")
    
    While 1
       	If $cmd = "MONITOR_ON" Then
    	  $cmd = ""
    		Send("{F10}")
    	Endif
    
    	If $cmd = "MONITOR_OFF" Then
    	  $cmd = ""
    		Send("{F11}")
    	Endif
    
    	If $cmd = "MONITOR_EXIT" Then
    	  $cmd = ""
    		Send("{ESC}")
    	Endif
    	sleep(100)
    WEnd
    
    Func _Monitor_ON()
        $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()
        $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)
            _IdleWaitCommit(0)
            Sleep(20)
        WEnd
    EndFunc
    
    Func _IdleWaitCommit($idlesec)
        Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword")
        DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))
        DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        Do
            $iSave = DllStructGetData ($LastInputInfo, 2)
            Sleep(60)
            DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False
        Return DllStructGetData ($LastInputInfo, 2)-$iSave
    EndFunc
    
    Func _Quit()
        _Monitor_ON()
        Exit
    EndFunc
    
    ;**********************************************connexion  RR*************************************************
    ;***********************************************************************************************************
    
    ; Message Handler
    Func _GUIRegisterMsgProc($hWnd, $MsgID, $WParam, $LParam)
    	If $MsgID = $WM_COPYDATA Then
    		; We Recived a WM_COPYDATA Message
    		; $LParam = Poiter to a COPYDATA Struct
    		$vs_cds = DllStructCreate($StructDef_COPYDATA, $LParam)
    		; Member No. 3 of COPYDATA Struct (PVOID lpData;) = Pointer to Costum Struct
    		$vs_msg = DllStructCreate($STRUCTDEF_AU3MESSAGE, DllStructGetData($vs_cds, 3))
    
    		$SciTECmdLen = DllStructGetData($vs_cds, 2)
    		$cmd = StringLeft(DllStructGetData($vs_msg, 1), $SciTECmdLen)
    
    		; Display what we have recived
    		;MsgBox(0, "Test String", $cmd)
    
    	ElseIf $MsgID = $WM_CLOSE Then
    	; We Recived a WM_CLOSE Message
    
    	EndIf
     EndFunc ;==>_GUIRegisterMsgProc

  8. #8
    Constant Bitrate
    Join Date
    Aug 2007
    Posts
    171
    when try to compile , or run show this error

    C:\Program Files\RideRunner\Skins\AUTOMATION\Scripts\MONITORO NOFF\MonitorOnOff.au3 (50) : ==> Unterminated string.:
    Send("{F10})


    i think for turn on again , use

    L01,-2,2,802,598,255,255,255,18,"Arial","EXEC;EXIT||SEN DMSG;MONITOR;MONITOR_ON","",

  9. #9
    Variable Bitrate
    Join Date
    Sep 2012
    Location
    Germany - Munich
    Posts
    406
    => " <= insert this behind }

  10. #10
    Raw Wave pierrotm777's Avatar
    Join Date
    May 2008
    Location
    Bordeaux, France
    Posts
    2,867
    Sorry , the post 7 is updated !

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 09-09-2010, 07:01 PM
  2. Digita gauges on main monitor or on seperate monitor?
    By stonestatue in forum LCD/Display
    Replies: 2
    Last Post: 04-16-2008, 01:03 PM
  3. Flat Screen Vga Monitor /car Monitor Wanted
    By donavanaccord in forum Classified Archive
    Replies: 0
    Last Post: 04-03-2006, 05:33 PM
  4. Headrest Monitor or Dash Monitor
    By BIzFlawless in forum Classified Archive
    Replies: 3
    Last Post: 01-28-2006, 04:16 AM
  5. FS- Datalux TS monitor, Prim View TS monitor,
    By coachreed in forum Classified Archive
    Replies: 8
    Last Post: 03-10-2005, 11:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •