Win Scripts for Resolution, Resume, AlwaysOnTop, ForceRestart of XBMC/PC & more
#1
These are all autohotkey scripts but can be converted into executables.

What you do is download autohotkey
( http://autohotkey.com/ )
open notepad and copy paste the code. extremely easy program but very useful.

1. Execute commands on resume/suspend/sleep. In this example I have it "sleep" for 10 seconds and then execute another script to change resolution.
Code:
OnMessage(0x218, "WM_POWERBROADCAST")
Return

WM_POWERBROADCAST(wParam, lParam)
{
   ; PBT_APMQUERYSUSPEND = 0
   ; PBT_APMRESUMESUSPEND = 7
   If (wParam == 7) {
      Sleep, 10000      
      Run C:\Resolution.ahk
   }
}

2. Change resolution,refreshrate,colorquality. You can bind this to a button on keyboard/mouse/remote or w/e or have it execute when you come out of standby/sleepmode.
Code:
EncodeInteger( p_value, p_size, p_address, p_offset )
{
   loop, %p_size%
      DllCall( "RtlFillMemory"
         , "uint", p_address+p_offset+A_Index-1
         , "uint", 1
         , "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}

colorDepth = 32 ; bits (quality)
screenWidth = 1920 ; pixels
screenHeight = 1080 ; pixels
refreshRate = 60 ; Hz (frequency)
; Don't change anything below!

struct_devicemode_size = 156
VarSetCapacity(device_mode, struct_devicemode_size, 0)

EncodeInteger(struct_devicemode_size, 2, &device_mode, 36)

success := DllCall("EnumDisplaySettings", "uint", 0, "uint", -1, "uint", &device_mode)

; DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY
EncodeInteger(0x00040000|0x00080000|0x00100000|0x00400000, 4, &device_mode, 40)

EncodeInteger(colorDepth, 4, &device_mode, 104)
EncodeInteger(screenWidth, 4, &device_mode, 108)
EncodeInteger(screenHeight, 4, &device_mode, 112)
EncodeInteger(refreshRate, 4, &device_mode, 120)

DllCall("ChangeDisplaySettings", "uint", &device_mode, "uint", 0)

3. Force Restart XBMC with press of button for when it has crashed or something like it. In this case I've chosen ctrl + X
Code:
;forced exit & restart of XBMC
^x::
Process, Close, XBMC.exe ;close current session
sleep, 5000 ;wait 5 sec
Run, C:\Program Files\XBMC\XBMC.exe "-fs" ;restart session
return

4. Force Restart/Reboot when windows has stopped functioning. In this case I've chosen ctrl + w. If you want a forced shutdown use "shutdown, 5"
Code:
;forced restart
^w::
shutdown, 6
return

5. bring XBMC to front.
Code:
;Brings XBMC to front
^o::WinActivate, XBMC Media Center
return

6. execute resolution script by pressing button ctrl+k
Code:
;Change resolution as specified in resolution.ahk
^k::
Run C:\Resolution.ahk
return
Reply
#2
Thanks very much for this!
Reply
#3
thanks for this it helped me out alot
Reply
#4
Nice. Thank you!
Reply

Logout Mark Read Team Forum Stats Members Help
Scripts for Resolution, Resume, AlwaysOnTop, ForceRestart of XBMC/PC & more2