Advertisement
Guest User

Autohotkey scripts for Surface Pro 3 Typecover

a guest
Jul 13th, 2014
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv
  2. #AllowSameLineComments
  3. #SingleInstance force
  4. #InstallKeybdHook
  5. #HotkeyInterval 2000  
  6. #MaxHotkeysPerInterval 300
  7.  
  8. ; remap surface pen button to launch any program
  9. #F20::
  10. ; change this file location to launch whatever program you desire
  11. Run C:\Program Files\Microsoft Office 15\root\office15\OneNote.exe
  12. return
  13.  
  14. ;;media keys
  15. #^!Left::Send {Media_Prev}
  16. #^!SPACE::Send {Media_Play_Pause}
  17. #^!Right::Send {Media_Next}
  18. #^!Down::Send {Volume_Down}
  19. #^!Up::Send {Volume_Up}
  20. #^!Enter::Send {Volume_Mute}
  21.  
  22. ; alt-enter to replace missing RContrl-enter on type cover (for appending "*.com" url in browser)
  23. !Enter::
  24. send {Control Down}
  25. send {Enter}
  26. sleep 1000
  27. send {Control Up}
  28. return
  29.  
  30. ;;;;;;;;;;; turn wifi connection back on ;;;;;;;;;;;
  31. ^#!i::
  32. send #i
  33. Sleep 500
  34. MouseClick, left, 80, 760
  35. Sleep 500
  36. MouseClick, left, 120, 340, 2
  37. Sleep 3000
  38. send {Escape}
  39. if WinActive("ahk_class Shell_CharmWindow")
  40. {
  41.     Sleep 2000
  42.     send {Escape}
  43. }
  44. return
  45. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  46.  
  47.  
  48. ;;;;;;;;;;;;;;;; trackpad for surface type cover ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  49.  
  50. ;;-----swipe left for backward navigation---------------
  51. WheelRight::
  52.  winc_pressesR += 1
  53.  SetTimer, Whright, 400 ; Wait for more presses within a 400 millisecond window.
  54. return
  55.  
  56. Whright:
  57.  SetTimer, Whright, off ; Disable timer after first time its called.
  58.  if winc_pressesR >= 16 ; The key was pressed once or more.
  59.  {
  60.   SendInput, !{Left} ; Send alt + left for back button (in Chrome at least)
  61.  }
  62.  ; Regardless of which action above was triggered, reset the count to prepare for the next series of presses:
  63.  winc_pressesR = 0
  64. return
  65. ;-----------------------------------------------
  66.  
  67. ;;-----swipe right for forward navigation---------------
  68. WheelLeft::
  69.  winc_pressesL += 1
  70.  SetTimer, Whleft, 400 ; Wait for more presses within a 400 millisecond window.
  71. return
  72.  
  73. Whleft:
  74.  SetTimer, Whleft, off ; Disable timer after first time its called.
  75.  if winc_pressesL >= 16 ; The key was pressed once or more.
  76.  {
  77.   SendInput, !{Right} ; Send alt + left for forward button (in Chrome at least)
  78.  }
  79.  ; Regardless of which action above was triggered, reset the count to prepare for the next series of presses:
  80.  winc_pressesL = 0
  81.  return
  82. ;-----------------------------------------------
  83.  
  84.  
  85. ;for left edge swiping to switch apps
  86. #^Tab::
  87. Run, "C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk"
  88. sleep 100
  89. send {Left}
  90. send {Left}
  91. send {Left}
  92. send {Enter}
  93. return
  94.  
  95. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  96.  
  97.  
  98. ;;;;;;;;;;;;;;;; brightness shortcuts for surface type cover ;;;;;;;;;;;;;;;;;;
  99.  
  100. toggle := false
  101.  
  102. SetWorkingDir %A_ScriptDir%
  103. SendMode, Input
  104.  
  105. ;;SC108::  ; SAMSUNG brightness up FN key
  106. ;;^+#!Up::
  107. #F2::
  108. MoveBrightness(10)
  109. return
  110.  
  111. ;;SC109::  ; SAMSUNG brightness down FN key
  112. ;;^+#!Down::
  113. #F1::
  114. MoveBrightness(-10)
  115. return
  116.  
  117. #Escape::SendMessage 0x112, 0xF170, 2, , Program Manager
  118.  
  119. ;############################################################################
  120. ; Functions
  121. ;############################################################################
  122.  
  123. MoveBrightness(IndexMove)
  124. {
  125.  
  126.     VarSetCapacity(SupportedBrightness, 256, 0)
  127.     VarSetCapacity(SupportedBrightnessSize, 4, 0)
  128.     VarSetCapacity(BrightnessSize, 4, 0)
  129.     VarSetCapacity(Brightness, 3, 0)
  130.    
  131.     hLCD := DllCall("CreateFile"
  132.     , Str, "\\.\LCD"
  133.     , UInt, 0x80000000 | 0x40000000 ;Read | Write
  134.     , UInt, 0x1 | 0x2  ; File Read | File Write
  135.     , UInt, 0
  136.     , UInt, 0x3  ; open any existing file
  137.     , UInt, 0
  138.       , UInt, 0)
  139.    
  140.     if hLCD != -1
  141.     {
  142.        
  143.         DevVideo := 0x00000023, BuffMethod := 0, Fileacces := 0
  144.           NumPut(0x03, Brightness, 0, "UChar")   ; 0x01 = Set AC, 0x02 = Set DC, 0x03 = Set both
  145.           NumPut(0x00, Brightness, 1, "UChar")      ; The AC brightness level
  146.           NumPut(0x00, Brightness, 2, "UChar")      ; The DC brightness level
  147.         DllCall("DeviceIoControl"
  148.           , UInt, hLCD
  149.           , UInt, (DevVideo<<16 | 0x126<<2 | BuffMethod<<14 | Fileacces) ; IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
  150.           , UInt, 0
  151.           , UInt, 0
  152.           , UInt, &Brightness
  153.           , UInt, 3
  154.           , UInt, &BrightnessSize
  155.           , UInt, 0)
  156.        
  157.         DllCall("DeviceIoControl"
  158.           , UInt, hLCD
  159.           , UInt, (DevVideo<<16 | 0x125<<2 | BuffMethod<<14 | Fileacces) ; IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
  160.           , UInt, 0
  161.           , UInt, 0
  162.           , UInt, &SupportedBrightness
  163.           , UInt, 256
  164.           , UInt, &SupportedBrightnessSize
  165.           , UInt, 0)
  166.        
  167.         ACBrightness := NumGet(Brightness, 1, "UChar")
  168.         ACIndex := 0
  169.         DCBrightness := NumGet(Brightness, 2, "UChar")
  170.         DCIndex := 0
  171.         BufferSize := NumGet(SupportedBrightnessSize, 0, "UInt")
  172.         MaxIndex := BufferSize-1
  173.  
  174.         Loop, %BufferSize%
  175.         {
  176.         ThisIndex := A_Index-1
  177.         ThisBrightness := NumGet(SupportedBrightness, ThisIndex, "UChar")
  178.         if ACBrightness = %ThisBrightness%
  179.             ACIndex := ThisIndex
  180.         if DCBrightness = %ThisBrightness%
  181.             DCIndex := ThisIndex
  182.         }
  183.        
  184.         if DCIndex >= %ACIndex%
  185.           BrightnessIndex := DCIndex
  186.         else
  187.           BrightnessIndex := ACIndex
  188.  
  189.         BrightnessIndex += IndexMove
  190.        
  191.         if BrightnessIndex > %MaxIndex%
  192.            BrightnessIndex := MaxIndex
  193.            
  194.         if BrightnessIndex < 0
  195.            BrightnessIndex := 0
  196.  
  197.         NewBrightness := NumGet(SupportedBrightness, BrightnessIndex, "UChar")
  198.        
  199.         NumPut(0x03, Brightness, 0, "UChar")   ; 0x01 = Set AC, 0x02 = Set DC, 0x03 = Set both
  200.         NumPut(NewBrightness, Brightness, 1, "UChar")      ; The AC brightness level
  201.         NumPut(NewBrightness, Brightness, 2, "UChar")      ; The DC brightness level
  202.        
  203.         DllCall("DeviceIoControl"
  204.             , UInt, hLCD
  205.             , UInt, (DevVideo<<16 | 0x127<<2 | BuffMethod<<14 | Fileacces) ; IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
  206.             , UInt, &Brightness
  207.             , UInt, 3
  208.             , UInt, 0
  209.             , UInt, 0
  210.             , UInt, 0
  211.             , Uint, 0)
  212.        
  213.         DllCall("CloseHandle", UInt, hLCD)
  214.    
  215.     }
  216.  
  217. }
  218. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement