Advertisement
sixlsix

Autohotkey Scripts for Surface 3 Typecover

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