Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Ligius (2017) - try to make the Thinkpad keyboard backlight behave more like a normal one
  2. global START_WITH_BACKLIGHT := 1 ; set to 1 if you want backlight on startup, 0 otherwise
  3. global BACKLIGHT_LEVEL := 1 ; set to 0 for no backlight, 1 for the first (dim level), 2 for the brightest level
  4. global IDLE_DURATION := 15000 ; after how many milliseconds of inactivity the light should turn off
  5. ;global POLLING_PERIOD := 250 ; how often (ms) should the program check for inactivity; lower turns backlight on faster but drains cpu
  6.  
  7. ; TODO: make the backlight wake up after screen off
  8.  
  9. ;#InstallKeybdHook
  10. ;#InstallMouseHook
  11. ;SetTimer, Check, POLLING_PERIOD
  12. ;return
  13.  
  14. global wasOn := START_WITH_BACKLIGHT
  15. setBacklight(START_WITH_BACKLIGHT ? BACKLIGHT_LEVEL : 0)
  16.  
  17. ; https://autohotkey.com/board/topic/94002-send-escape-key-after-idle-time/
  18. #SingleInstance Force
  19. #Persistent
  20. SetTimer, Check, 250         ;set the timer. TODO: figure out how to get the parameter in here
  21. return
  22.  
  23. ; timer check
  24. Check:
  25. If (A_TimeIdle>=IDLE_DURATION)
  26. {
  27.   setBacklight(0)
  28.   ; SetTimer, Check, Off
  29. }
  30. else
  31. {
  32.   setBacklight(1)
  33. }
  34. return
  35.  
  36. ; set backlight on or off
  37. setBacklight(isOn)
  38. {
  39.   ; do not call backlight program if level is already set
  40.   if (wasOn != isOn){
  41.     wasOn := isOn
  42.     level := isOn ? BACKLIGHT_LEVEL : 0
  43.     Run, thinkpadlightv01.exe "c:\Users\All Users\Lenovo\ImController\Plugins\ThinkKeyboardPlugin\x86\Keyboard_Core.dll" %level% , , Hide
  44.   }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement