├── Custom ├── CustomHotkeys.ahk └── CustomLogic.ahk ├── Images ├── Disabled.ico ├── Disabled.png ├── Insert.png ├── Kommand.ico ├── Kommand.png ├── Viper.png ├── vi_insert_mode.ico └── vi_normal_mode.ico ├── Kommand.ahk ├── Modes ├── Disabled.ahk ├── ViInsertMode.ahk └── ViNormalMode.ahk ├── README ├── Scripts ├── .Kommand-v.0.1alpha.ahk.swp ├── .Kommand-v.0.1beta.ahk.swp ├── CoreHotkeys.ahk └── WindowPad.ahk ├── Utilities ├── CloseWindows.exe ├── NoMouse.exe └── SnarlCMD.exe └── iTunes ├── BackTrack.vbs ├── DeleteTrack.js ├── FastForward.vbs ├── FindDeadTracks.js ├── GetPlayState.vbs ├── Mute.vbs ├── Next.vbs ├── Pause.vbs ├── Play.vbs ├── PlayFile.vbs ├── PlayPause.vbs ├── PlayPlaylist.vbs ├── PlaySong.vbs ├── Previous.vbs ├── RemoveDeadTracks.js ├── Rewind.vbs ├── ScriptEngineCache-Start.vbs ├── ScriptEngineCache-Stop.vbs ├── SetVolume.vbs ├── Stop.vbs ├── VolumeDown.vbs ├── VolumeUp.vbs └── iTunesAlarm.js /Custom/CustomHotkeys.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; CustomHotkeys.ahk 3 | ; 4 | ; This file contains custom keybindings ONLY. 5 | ; 6 | 7 | ; Special Characters ============================================ ; 8 | 9 | #UseHook on 10 | 11 | `:: 12 | if (KMD_Enabled == true) 13 | { 14 | if (KMD_ViperMode == true) 15 | KMD_StartKommandMode(false) 16 | else if (KMD_InsertMode == true) 17 | KMD_StartViperMode(false) 18 | } 19 | else 20 | Send, `` 21 | return 22 | 23 | #UseHook off 24 | 25 | #`:: 26 | if (KMD_Enabled == true) 27 | Send, `` 28 | else 29 | Send, #` 30 | return 31 | 32 | #Space:: RunAndFocusInMode("http://docs.google.com/", 1) 33 | 34 | #Backspace:: 35 | EnvGet, UserProfile, USERPROFILE 36 | RunAndFocusInMode("""C:\Program Files (x86)\Prism\prism.exe"" -override """ UserProfile "\AppData\Roaming\WebApps\k.rss@prism.app\override.ini"" -webapp k.rss@prism.app", 1) 37 | return 38 | 39 | #Enter:: RunAndFocusInMode("http://localhost/Cityworks.WebApp/Login.aspx", 1) 40 | #+Enter:: RunAndFocusInMode("http://localhost/CwPortal/Login.aspx", 1) 41 | #Insert:: RunAndFocusInMode("http://www.rememberthemilk.com/home/kylir/", 1) 42 | #+Insert:: RunAndFocus("C:\Program Files (x86)\Focus Booster\Focus Booster.exe") 43 | 44 | #Delete:: 45 | EnvGet, UserProfile, USERPROFILE 46 | RunAndFocusInMode("""C:\Program Files (x86)\Prism\prism.exe"" -override """ UserProfile "\AppData\Roaming\WebApps\k.cal@prism.app\override.ini"" -webapp k.cal@prism.app", 1) 47 | return 48 | 49 | ;#Home:: 50 | ;#End:: 51 | ;#PgUp:: 52 | ;#PgDn:: 53 | 54 | ; Arrows ======================================================== ; 55 | 56 | #Up:: Run iTunes\PlayPause.vbs,,UseErrorLevel 57 | #Down:: Run iTunes\DeleteTrack.js,,UseErrorLevel 58 | #+Down:: Run iTunes\FindDeadTracks.js,,UseErrorLevel 59 | #^Down:: Run iTunes\RemoveDeadTracks.js,,UseErrorLevel 60 | #Left:: Run iTunes\BackTrack.vbs,,UseErrorLevel 61 | #Right:: Run iTunes\Next.vbs,,UseErrorLevel 62 | 63 | ; Numbers ======================================================= ; 64 | 65 | #1:: RunAndFocusInMode("C:\Cityworks\Cityworks.WebApp", 3) 66 | #+1:: RunAndFocusInMode("C:\Cityworks", 3) 67 | 68 | ^1:: 69 | if (KMD_KommandMode == true) 70 | Send, #1 71 | else 72 | Send, ^1 73 | return 74 | 75 | #2:: RunAndFocusInMode("C:\Azteca", 3) 76 | 77 | ^2:: 78 | if (KMD_KommandMode == true) 79 | Send, #2 80 | else 81 | Send, ^2 82 | return 83 | 84 | #3:: RunAndFocusInMode("C:\Vast", 3) 85 | 86 | ^3:: 87 | if (KMD_KommandMode == true) 88 | Send, #3 89 | else 90 | Send, ^3 91 | return 92 | 93 | #4:: RunAndFocusInMode("C:\Downloads", 3) 94 | #+4:: RunAndFocusInMode("C:\Files\Public", 3) 95 | 96 | ^4:: 97 | if (KMD_KommandMode == true) 98 | Send, #4 99 | else 100 | Send, ^4 101 | return 102 | 103 | #5:: RunAndFocusInMode("C:\Kylir", 3) 104 | 105 | #+5:: 106 | EnvGet, UserProfile, USERPROFILE 107 | RunAndFocusInMode(UserProfile, 3) 108 | return 109 | 110 | ^5:: 111 | if (KMD_KommandMode == true) 112 | Send, #5 113 | else 114 | Send, ^5 115 | return 116 | 117 | #6:: RunAndFocusInMode("C:\Mindy", 3) 118 | 119 | ^6:: 120 | if (KMD_KommandMode == true) 121 | Send, #6 122 | else 123 | Send, ^6 124 | return 125 | 126 | #7:: RunAndFocusInMode("C:\Resources", 3) 127 | 128 | ^7:: 129 | if (KMD_KommandMode == true) 130 | Send, #7 131 | else 132 | Send, ^7 133 | return 134 | 135 | #8:: RunAndFocusInMode("C:\Application", 3) 136 | 137 | ^8:: 138 | if (KMD_KommandMode == true) 139 | Send, #8 140 | else 141 | Send, ^8 142 | return 143 | 144 | #9:: RunAndFocusInMode("C:\Program Files (x86)", 3) 145 | #+9:: RunAndFocusInMode("C:\Program Files", 3) 146 | 147 | ^9:: 148 | if (KMD_KommandMode == true) 149 | Send, #9 150 | else 151 | Send, ^9 152 | return 153 | 154 | #0:: RunAndFocusInMode("Control", 3) 155 | #+0:: RunAndFocusInMode("C:\Windows", 3) 156 | 157 | ^0:: 158 | if (KMD_KommandMode == true) 159 | Send, #0 160 | else 161 | Send, ^0 162 | return 163 | 164 | ; Letters ======================================================= ; 165 | 166 | #a:: RunAndFocusInMode("C:\Files", 3) 167 | ;#b:: Run Highlight System Tray 168 | #c:: RunAndFocus("C:\Program Files (x86)\Adobe\Photoshop CS4\PhotoshopPortable.exe") 169 | ;#d:: Run Reveal Desktop 170 | ;#e:: Run Computer 171 | #+e:: RunAndFocusInMode("C:\", 3) 172 | ;#f:: Run Search 173 | #g:: RunAndFocus("C:\Program Files (x86)\iTunes\iTunes.exe") 174 | #h:: RunAndFocus("C:\Program Files\Windows Media Player\wmplayer.exe /prefetch:1") 175 | #+h:: Run %SystemRoot%\system32\drivers\etc\,,UseErrorLevel ;TODO - Fix this so it uses RunAndFocus. 176 | #i:: RunAndFocus("C:\Program Files (x86)\Pidgin\pidgin.exe") 177 | #+i:: RunAndFocus("C:\Windows\system32\inetsrv\iis.msc") 178 | #j:: RunAndFocusInMode("C:\Junk", 3) 179 | #+j:: RunAndFocusInMode("C:\Junk\Projects", 3) 180 | 181 | #k:: KMD_StartKommandMode(false) 182 | #l:: 183 | sleep 1000 184 | SendMessage, 0x112, 0xF170, 2,, Program Manager 185 | ;Run rundll32.exe user32.dll LockWorkStation, C:\Windows\System32,,UseErrorLevel ; Not needed because #l already locks the machine. 186 | return 187 | 188 | #m:: Run C:\Program Files (x86)\BasiliskII\BasiliskII.exe, C:\Program Files (x86)\BasiliskII,,UseErrorLevel 189 | #+m:: Run C:\Program Files (x86)\BasiliskII\BasiliskIIGUI.exe, C:\Program Files (x86)\BasiliskII,,UseErrorLevel 190 | #!m:: RunAndFocus("C:\Program Files (x86)\DOSBox-0.72\dosbox.exe -conf C:\Application\Games\dosbox.conf") 191 | #!^m:: Run, Utilities\nomousy.exe /hide 192 | 193 | #n:: 194 | if WinExist("ahk_class Vim") 195 | { 196 | WinActivate 197 | KMD_StartInsertMode(false) 198 | } 199 | else 200 | RunAndFocusInMode("C:\Vim\vim72\gvim.exe", 1) 201 | return 202 | 203 | #+n:: RunAndFocusInMode("C:\Junk\Notes", 3) 204 | #!n:: RunAndFocusInMode("C:\Program Files (x86)\Notepad++\notepad++.exe", 1) 205 | #o:: RunAndFocusInMode("C:\Videos", 3) 206 | #p:: RunAndFocusInMode("C:\Pictures", 3) 207 | 208 | #q:: 209 | if WinExist("ahk_class CalcFrame") 210 | WinActivate 211 | else 212 | RunAndFocus("C:\Windows\system32\calc.exe") 213 | return 214 | 215 | ;#r:: Run "Open Run" dialog 216 | #+r:: RunAndFocus("regedit") 217 | #s:: RunAndFocusInMode("explorer.exe ftp://www.kylirhorton.com", 3) 218 | #+s:: RunAndFocus("C:\Program Files (x86)\Allway Sync\Bin\syncappw.exe") 219 | #t:: RunAndFocus("C:\Windows\system32\mstsc.exe") 220 | 221 | 222 | #^t:: RunAndFocusInMode("https://secure.logmein.com/computers.asp", 1) 223 | #u:: RunAndFocus("C:\Program Files (x86)\uTorrent\uTorrent.exe") 224 | 225 | #v:: 226 | if WinExist("ahk_class wndclass_desked_gsk") 227 | { 228 | WinActivate 229 | KMD_StartInsertMode(false) 230 | } 231 | else 232 | RunAndFocusInMode("C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe", 1) 233 | return 234 | 235 | #+v:: 236 | if WinExist("ahk_class SWT_Window0") 237 | { 238 | WinActivate 239 | KMD_StartInsertMode(false) 240 | } 241 | else 242 | RunAndFocusInMode("C:\Program Files (x86)\Eclipse\eclipse.exe", 1) 243 | return 244 | 245 | #!v:: RunAndFocusInMode("C:\Program Files (x86)\Adobe\Dreamweaver CS4\DreamweaverPortable.exe", 1) 246 | ;#w:: EMPTY!!! 247 | 248 | #x:: 249 | EnvGet, UserProfile, USERPROFILE 250 | RunAndFocusInMode("""C:\Program Files (x86)\Prism\prism.exe"" -override """ UserProfile "\AppData\Roaming\WebApps\k.mail@prism.app\override.ini"" -webapp k.mail@prism.app", 1) 251 | return 252 | 253 | 254 | #+x:: RunAndFocus("C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE /recycle") 255 | #y:: RunAndFocus("C:\Program Files (x86)\Yahoo!\Widgets\YahooWidgets.exe") 256 | 257 | #z:: 258 | if WinExist("K.FOX") 259 | { 260 | WinActivate 261 | KMD_StartInsertMode(false) 262 | } 263 | else if WinExist("Vimperator") 264 | { 265 | WinActivate 266 | KMD_StartInsertMode(false) 267 | } 268 | else 269 | RunAndFocusInMode("C:\Program Files (x86)\Mozilla Firefox\firefox.exe", 1) 270 | return 271 | 272 | #+z:: 273 | if WinExist("K.FOX") 274 | { 275 | WinActivate 276 | KMD_StartInsertMode(false) 277 | } 278 | else if WinExist("Vimperator") 279 | { 280 | WinActivate 281 | KMD_StartInsertMode(false) 282 | } 283 | else 284 | RunAndFocusInMode("C:\Program Files (x86)\Mozilla Firefox\firefox.exe --profilemanager", 1) 285 | return 286 | 287 | #!z:: RunAndFocusInMode("C:\Program Files (x86)\Mozilla Firefox\newInstance.bat", 1) 288 | 289 | ; Function Keys ================================================= ; 290 | 291 | #F1:: Run %USERPROFILE%\AppData\Local\Google\Chrome\Application\chrome.exe,,UseErrorLevel ;TODO - Fix this so it uses RunAndFocus. 292 | #F2:: RunAndFocusInMode("C:\Program Files (x86)\Internet Explorer\iexplore.exe", 1) 293 | #F3:: RunAndFocusInMode("C:\Program Files (x86)\Safari\Safari.exe", 1) 294 | #F4:: RunAndFocusInMode("C:\Program Files (x86)\Opera\Opera.exe", 1) 295 | #F5:: RunAndFocusInMode("C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE", 1) 296 | #F6:: RunAndFocusInMode("C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE", 1) 297 | #F7:: RunAndFocusInMode("C:\Program Files (x86)\Microsoft Office\Office12\POWERPNT.EXE", 1) 298 | #F8:: RunAndFocusInMode("C:\Program Files (x86)\Microsoft Office\Office12\ONENOTE.EXE", 1) 299 | #F9:: RunAndFocus("C:\Program Files (x86)\Adobe\Illustrator CS3\Illustrator.exe") 300 | #F10:: RunAndFocus("C:\Program Files (x86)\Adobe\Adobe InDesign CS2\InDesign.exe") 301 | #F11:: RunAndFocus("C:\Program Files (x86)\NexusFont\NexusFont.exe") 302 | #F12:: Reload 303 | -------------------------------------------------------------------------------- /Custom/CustomLogic.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; CustomLogic.ahk 3 | ; 4 | ; This file contains logic. Do not put keybindings in this file as they will break stuff. 5 | ; 6 | 7 | ShowMessage("KOMMAND", "Welcome to Kommand", "Kommand.png") ; Show a custom Snarl message. 8 | KMD_Silent = true ; Turn off Snarl messages. 9 | 10 | ; Disable Kommand's window keybindings on wife's machine. 11 | if (A_ComputerName = "JENIVICE") 12 | KMD_Disable(true) 13 | -------------------------------------------------------------------------------- /Images/Disabled.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/Disabled.ico -------------------------------------------------------------------------------- /Images/Disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/Disabled.png -------------------------------------------------------------------------------- /Images/Insert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/Insert.png -------------------------------------------------------------------------------- /Images/Kommand.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/Kommand.ico -------------------------------------------------------------------------------- /Images/Kommand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/Kommand.png -------------------------------------------------------------------------------- /Images/Viper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/Viper.png -------------------------------------------------------------------------------- /Images/vi_insert_mode.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/vi_insert_mode.ico -------------------------------------------------------------------------------- /Images/vi_normal_mode.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Images/vi_normal_mode.ico -------------------------------------------------------------------------------- /Kommand.ahk: -------------------------------------------------------------------------------- 1 | ;||=================================||; 2 | ;|| ||; 3 | ;|| -= KOMMAND =- ||; 4 | ;|| ||; 5 | ;||=================================||; 6 | 7 | ; 8 | ; Kommand.ahk 9 | ; Version: 0.3 10 | ; Last Updated: 11/5/2009 11 | ; Author: Kylir Horton 12 | ; Website: http://www.kylirhorton.com/kommand 13 | ; 14 | ; This is the main executable file for Kommand. All other files are loaded from 15 | ; this one and some basic functions and global variables are defined. 16 | ; 17 | ; Mon Apr 25 05:23:15 CEST 2011 18 | ; heavily modified by Marc Weber: 19 | ; Vi: support running actions n times 20 | ; refactor modes to make code more scalable and more maintainable 21 | 22 | 23 | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. 24 | #SingleInstance, Force ; Make sure there is only one instance of Kommand running at a time. 25 | #WinActivateForce ; Forces windows to appear when they're called. 26 | 27 | 28 | ; include modes 29 | #Include Modes\Disabled.ahk 30 | #Include Modes\ViNormalMode.ahk 31 | #Include Modes\ViInsertMode.ahk 32 | 33 | ; Initialize Kommand and load custom logic and supporting functions. 34 | KMD_Init() 35 | ; #Include Custom\CustomLogic.ahk 36 | ; #Include Scripts\WindowPad.ahk 37 | 38 | ; Initialize the script and load hotkeys. 39 | ; KMD_ComponentInit(false) 40 | ; #Include Scripts\CoreHotkeys.ahk 41 | ; #Include Custom\CustomHotkeys.ahk 42 | 43 | 44 | return 45 | 46 | KMD_Init() 47 | { 48 | global 49 | DetectHiddenWindows, on ; Be able to find hidden windows. 50 | SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 51 | SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 52 | SetBatchlines, -1 ; Make the script run as fast as possible. 53 | SetKeyDelay, -1 ; Make sure it is fast! 54 | 55 | KMD_SENDING := 0 56 | 57 | KMD_Modes := Object() 58 | 59 | KMD_Modes["vi_normal_mode"] := vi_normal_mode 60 | KMD_Modes["vi_insert_mode"] := vi_insert_mode 61 | KMD_Modes["disabled"] := disabled_mode 62 | 63 | KMD_Mode := "disabled" 64 | start_disabled_mode() 65 | } 66 | 67 | KMD_Send(keys) 68 | { 69 | global KMD_SENDING 70 | KMD_SENDING :=1 71 | Send, %keys% 72 | KMD_SENDING :=0 73 | } 74 | 75 | KMD_SetMode(mode){ 76 | global KMD_Mode 77 | 78 | if KMD_Mode != "" 79 | KMD_Modes[KMD_Mode]["end"]() 80 | 81 | ; set early so that "start" can switch mode again 82 | KMD_Mode := mode 83 | KMD_Modes[mode]["start"]() 84 | Menu, Tray, Icon, %A_ScriptDir%\Images\%mode%.ico, 0, 1 85 | } 86 | 87 | ShowMessage(title, message, icon) 88 | { 89 | Run Utilities\SnarlCMD.exe snShowMessage 5 "%title%" "%message%" "%A_ScriptDir%\Images\%icon%",,UseErrorLevel 90 | } 91 | 92 | 93 | Capslock:: 94 | if (KMD_Mode == "vi_insert_mode"){ 95 | KMD_SetMode("vi_normal_mode") 96 | }else if (KMD_Mode != "disabled") { 97 | KMD_SetMode("disabled") 98 | } else { 99 | ; set / toggle mode depending on Window? 100 | KMD_SetMode("vi_normal_mode") 101 | } 102 | return 103 | 104 | ; Boy this is insane! 105 | ; But its the onlsy modular way which came to my mind! 106 | 107 | #if (KMD_SENDING == 0) 108 | 109 | Enter:: 110 | KMD_Modes[KMD_Mode]["handle_keys"]("{Enter}") 111 | return 112 | -:: 113 | KMD_Modes[KMD_Mode]["handle_keys"]("-") 114 | return 115 | /:: 116 | KMD_Modes[KMD_Mode]["handle_keys"]("/") 117 | return 118 | *:: 119 | KMD_Modes[KMD_Mode]["handle_keys"]("*") 120 | return 121 | ?:: 122 | KMD_Modes[KMD_Mode]["handle_keys"]("?") 123 | return 124 | #:: 125 | KMD_Modes[KMD_Mode]["handle_keys"]("#") 126 | return 127 | 128 | 129 | 0:: 130 | KMD_Modes[KMD_Mode]["handle_keys"]("0") 131 | return 132 | 1:: 133 | KMD_Modes[KMD_Mode]["handle_keys"]("1") 134 | return 135 | 2:: 136 | KMD_Modes[KMD_Mode]["handle_keys"]("2") 137 | return 138 | 3:: 139 | KMD_Modes[KMD_Mode]["handle_keys"]("3") 140 | return 141 | 4:: 142 | KMD_Modes[KMD_Mode]["handle_keys"]("4") 143 | return 144 | 5:: 145 | KMD_Modes[KMD_Mode]["handle_keys"]("5") 146 | return 147 | 6:: 148 | KMD_Modes[KMD_Mode]["handle_keys"]("6") 149 | return 150 | 7:: 151 | KMD_Modes[KMD_Mode]["handle_keys"]("7") 152 | return 153 | 8:: 154 | KMD_Modes[KMD_Mode]["handle_keys"]("8") 155 | return 156 | 9:: 157 | KMD_Modes[KMD_Mode]["handle_keys"]("9") 158 | return 159 | 160 | $:: 161 | KMD_Modes[KMD_Mode]["handle_keys"]("$") 162 | return 163 | 164 | a:: 165 | KMD_Modes[KMD_Mode]["handle_keys"]("a") 166 | return 167 | b:: 168 | KMD_Modes[KMD_Mode]["handle_keys"]("b") 169 | return 170 | c:: 171 | KMD_Modes[KMD_Mode]["handle_keys"]("c") 172 | return 173 | d:: 174 | KMD_Modes[KMD_Mode]["handle_keys"]("d") 175 | return 176 | e:: 177 | KMD_Modes[KMD_Mode]["handle_keys"]("e") 178 | return 179 | f:: 180 | KMD_Modes[KMD_Mode]["handle_keys"]("f") 181 | return 182 | g:: 183 | KMD_Modes[KMD_Mode]["handle_keys"]("g") 184 | return 185 | h:: 186 | KMD_Modes[KMD_Mode]["handle_keys"]("h") 187 | return 188 | i:: 189 | KMD_Modes[KMD_Mode]["handle_keys"]("i") 190 | return 191 | j:: 192 | KMD_Modes[KMD_Mode]["handle_keys"]("j") 193 | return 194 | k:: 195 | KMD_Modes[KMD_Mode]["handle_keys"]("k") 196 | return 197 | l:: 198 | KMD_Modes[KMD_Mode]["handle_keys"]("l") 199 | return 200 | m:: 201 | KMD_Modes[KMD_Mode]["handle_keys"]("m") 202 | return 203 | n:: 204 | KMD_Modes[KMD_Mode]["handle_keys"]("n") 205 | return 206 | o:: 207 | KMD_Modes[KMD_Mode]["handle_keys"]("o") 208 | return 209 | p:: 210 | KMD_Modes[KMD_Mode]["handle_keys"]("p") 211 | return 212 | q:: 213 | KMD_Modes[KMD_Mode]["handle_keys"]("q") 214 | return 215 | r:: 216 | KMD_Modes[KMD_Mode]["handle_keys"]("r") 217 | return 218 | s:: 219 | KMD_Modes[KMD_Mode]["handle_keys"]("s") 220 | return 221 | t:: 222 | KMD_Modes[KMD_Mode]["handle_keys"]("t") 223 | return 224 | u:: 225 | KMD_Modes[KMD_Mode]["handle_keys"]("u") 226 | return 227 | v:: 228 | KMD_Modes[KMD_Mode]["handle_keys"]("v") 229 | return 230 | w:: 231 | KMD_Modes[KMD_Mode]["handle_keys"]("w") 232 | return 233 | x:: 234 | KMD_Modes[KMD_Mode]["handle_keys"]("x") 235 | return 236 | y:: 237 | KMD_Modes[KMD_Mode]["handle_keys"]("y") 238 | return 239 | z:: 240 | KMD_Modes[KMD_Mode]["handle_keys"]("z") 241 | return 242 | 243 | +a:: 244 | KMD_Modes[KMD_Mode]["handle_keys"]("+a") 245 | return 246 | +b:: 247 | KMD_Modes[KMD_Mode]["handle_keys"]("+b") 248 | return 249 | +c:: 250 | KMD_Modes[KMD_Mode]["handle_keys"]("+c") 251 | return 252 | +d:: 253 | KMD_Modes[KMD_Mode]["handle_keys"]("+d") 254 | return 255 | +e:: 256 | KMD_Modes[KMD_Mode]["handle_keys"]("+e") 257 | return 258 | +f:: 259 | KMD_Modes[KMD_Mode]["handle_keys"]("+f") 260 | return 261 | +g:: 262 | KMD_Modes[KMD_Mode]["handle_keys"]("+g") 263 | return 264 | +h:: 265 | KMD_Modes[KMD_Mode]["handle_keys"]("+h") 266 | return 267 | +i:: 268 | KMD_Modes[KMD_Mode]["handle_keys"]("+i") 269 | return 270 | +j:: 271 | KMD_Modes[KMD_Mode]["handle_keys"]("+j") 272 | return 273 | +k:: 274 | KMD_Modes[KMD_Mode]["handle_keys"]("+k") 275 | return 276 | +l:: 277 | KMD_Modes[KMD_Mode]["handle_keys"]("+l") 278 | return 279 | +m:: 280 | KMD_Modes[KMD_Mode]["handle_keys"]("+m") 281 | return 282 | +n:: 283 | KMD_Modes[KMD_Mode]["handle_keys"]("+n") 284 | return 285 | +o:: 286 | KMD_Modes[KMD_Mode]["handle_keys"]("+o") 287 | return 288 | +p:: 289 | KMD_Modes[KMD_Mode]["handle_keys"]("+p") 290 | return 291 | +q:: 292 | KMD_Modes[KMD_Mode]["handle_keys"]("+q") 293 | return 294 | +r:: 295 | KMD_Modes[KMD_Mode]["handle_keys"]("+r") 296 | return 297 | +s:: 298 | KMD_Modes[KMD_Mode]["handle_keys"]("+s") 299 | return 300 | +t:: 301 | KMD_Modes[KMD_Mode]["handle_keys"]("+t") 302 | return 303 | +u:: 304 | KMD_Modes[KMD_Mode]["handle_keys"]("+u") 305 | return 306 | +v:: 307 | KMD_Modes[KMD_Mode]["handle_keys"]("+v") 308 | return 309 | +w:: 310 | KMD_Modes[KMD_Mode]["handle_keys"]("+w") 311 | return 312 | +x:: 313 | KMD_Modes[KMD_Mode]["handle_keys"]("+x") 314 | return 315 | +y:: 316 | KMD_Modes[KMD_Mode]["handle_keys"]("+y") 317 | return 318 | +z:: 319 | KMD_Modes[KMD_Mode]["handle_keys"]("+z") 320 | return 321 | 322 | ; Does not work :-( try alt-d in notepad! 323 | ; !a:: 324 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!a") 325 | ; return 326 | ; !b:: 327 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!b") 328 | ; return 329 | ; !c:: 330 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!c") 331 | ; return 332 | ; !d:: 333 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!d") 334 | ; return 335 | ; !e:: 336 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!e") 337 | ; return 338 | ; !f:: 339 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!f") 340 | ; return 341 | ; !g:: 342 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!g") 343 | ; return 344 | ; !h:: 345 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!h") 346 | ; return 347 | ; !i:: 348 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!i") 349 | ; return 350 | ; !j:: 351 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!j") 352 | ; return 353 | ; !k:: 354 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!k") 355 | ; return 356 | ; !l:: 357 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!l") 358 | ; return 359 | ; !m:: 360 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!m") 361 | ; return 362 | ; !n:: 363 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!n") 364 | ; return 365 | ; !o:: 366 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!o") 367 | ; return 368 | ; !p:: 369 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!p") 370 | ; return 371 | ; !q:: 372 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!q") 373 | ; return 374 | ; !r:: 375 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!r") 376 | ; return 377 | ; !s:: 378 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!s") 379 | ; return 380 | ; !t:: 381 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!t") 382 | ; return 383 | ; !u:: 384 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!u") 385 | ; return 386 | ; !v:: 387 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!v") 388 | ; return 389 | ; !w:: 390 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!w") 391 | ; return 392 | ; !x:: 393 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!x") 394 | ; return 395 | ; !y:: 396 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!y") 397 | ; return 398 | ; !z:: 399 | ; KMD_Modes[KMD_Mode]["handle_keys"]("!z") 400 | ; return 401 | 402 | ^a:: 403 | KMD_Modes[KMD_Mode]["handle_keys"]("^a") 404 | return 405 | ^b:: 406 | KMD_Modes[KMD_Mode]["handle_keys"]("^b") 407 | return 408 | ^c:: 409 | KMD_Modes[KMD_Mode]["handle_keys"]("^c") 410 | return 411 | ^d:: 412 | KMD_Modes[KMD_Mode]["handle_keys"]("^d") 413 | return 414 | ^e:: 415 | KMD_Modes[KMD_Mode]["handle_keys"]("^e") 416 | return 417 | ^f:: 418 | KMD_Modes[KMD_Mode]["handle_keys"]("^f") 419 | return 420 | ^g:: 421 | KMD_Modes[KMD_Mode]["handle_keys"]("^g") 422 | return 423 | ^h:: 424 | KMD_Modes[KMD_Mode]["handle_keys"]("^h") 425 | return 426 | ^i:: 427 | KMD_Modes[KMD_Mode]["handle_keys"]("^i") 428 | return 429 | ^j:: 430 | KMD_Modes[KMD_Mode]["handle_keys"]("^j") 431 | return 432 | ^k:: 433 | KMD_Modes[KMD_Mode]["handle_keys"]("^k") 434 | return 435 | ^l:: 436 | KMD_Modes[KMD_Mode]["handle_keys"]("^l") 437 | return 438 | ^m:: 439 | KMD_Modes[KMD_Mode]["handle_keys"]("^m") 440 | return 441 | ^n:: 442 | KMD_Modes[KMD_Mode]["handle_keys"]("^n") 443 | return 444 | ^o:: 445 | KMD_Modes[KMD_Mode]["handle_keys"]("^o") 446 | return 447 | ^p:: 448 | KMD_Modes[KMD_Mode]["handle_keys"]("^p") 449 | return 450 | ^q:: 451 | KMD_Modes[KMD_Mode]["handle_keys"]("^q") 452 | return 453 | ^r:: 454 | KMD_Modes[KMD_Mode]["handle_keys"]("^r") 455 | return 456 | ^s:: 457 | KMD_Modes[KMD_Mode]["handle_keys"]("^s") 458 | return 459 | ^t:: 460 | KMD_Modes[KMD_Mode]["handle_keys"]("^t") 461 | return 462 | ^u:: 463 | KMD_Modes[KMD_Mode]["handle_keys"]("^u") 464 | return 465 | ^v:: 466 | KMD_Modes[KMD_Mode]["handle_keys"]("^v") 467 | return 468 | ^w:: 469 | KMD_Modes[KMD_Mode]["handle_keys"]("^w") 470 | return 471 | ^x:: 472 | KMD_Modes[KMD_Mode]["handle_keys"]("^x") 473 | return 474 | ^y:: 475 | KMD_Modes[KMD_Mode]["handle_keys"]("^y") 476 | return 477 | ^z:: 478 | KMD_Modes[KMD_Mode]["handle_keys"]("^z") 479 | return 480 | -------------------------------------------------------------------------------- /Modes/Disabled.ahk: -------------------------------------------------------------------------------- 1 | start_disabled_mode(){ 2 | Menu, Tray, Icon, %A_ScriptDir%\Images\Disabled.ico, 0, 1 3 | } 4 | 5 | end_disabled_mode(){ 6 | } 7 | 8 | disabled_mode_handle_keys(key){ 9 | KMD_Send(key) 10 | } 11 | 12 | disabled_mode := {} 13 | disabled_mode["start"] := "start_disabled_mode" 14 | disabled_mode["end"] := "end_disabled_mode" 15 | disabled_mode["shortcut"] := "d" 16 | disabled_mode["handle_keys"] := "disabled_mode_handle_keys" 17 | -------------------------------------------------------------------------------- /Modes/ViInsertMode.ahk: -------------------------------------------------------------------------------- 1 | start_vi_insert_mode(){ 2 | global vi_insert_mode 3 | vi_insert_mode["repeat_count"] := 0 4 | } 5 | 6 | end_vi_insert_mode(){ 7 | 8 | } 9 | 10 | vi_insert_mode_handle_keys(key){ 11 | ; MsgBox, %key% 12 | global vi_insert_mode 13 | 14 | if (vi_insert_mode["simple_commands"].HasKey(key)) { 15 | KMD_ViperDoRepeat(vi_insert_mode["simple_commands"][key]) 16 | return 17 | } 18 | 19 | ; drop repeat count 20 | vi_insert_mode["repeat_count"] := 0 21 | vi_insert_mode["last_chars"] := "" 22 | KMD_Send(key) 23 | } 24 | 25 | vi_insert_mode := {} 26 | vi_insert_mode["start"] := "start_vi_insert_mode" 27 | vi_insert_mode["end"] := "end_vi_insert_mode" 28 | vi_insert_mode["shortcut"] := "v" 29 | vi_insert_mode["repeat_count"] := 0 30 | vi_insert_mode["handle_keys"] := "vi_insert_mode_handle_keys" 31 | 32 | vi_insert_mode["simple_commands"] := {} 33 | ; vi_insert_mode["simple_commands"]["^w"] := "" 34 | -------------------------------------------------------------------------------- /Modes/ViNormalMode.ahk: -------------------------------------------------------------------------------- 1 | start_vi_normal_mode(){ 2 | global vi_normal_mode 3 | vi_normal_mode["repeat_count"] := 0 4 | vi_normal_mode["mode"] := "" 5 | vi_normal_mode["last_chars"] := "" 6 | } 7 | 8 | end_vi_normal_mode(){ 9 | 10 | } 11 | 12 | 13 | KMD_ViperDoRepeat(tosend) 14 | { 15 | 16 | global vi_normal_mode 17 | c := vi_normal_mode["repeat_count"] 18 | if (c == 0) 19 | c := 1 20 | 21 | ;; guard: 22 | ;; should use confirmation instead 23 | if (c > 2000) 24 | c := 2000 25 | 26 | Loop %c% 27 | { 28 | S := S . tosend 29 | } 30 | KMD_Send(S) 31 | vi_normal_mode["repeat_count"] := 0 32 | } 33 | 34 | ; Beide wichtige Konstanten 35 | WM_HSCROLL := 0x114 36 | WM_VSCROLL := 0x115 37 | 38 | ; Vertikal scrollen 39 | SB_BOTTOM := 7 40 | SB_ENDSCROLL := 8 41 | SB_LINEDOWN := 1 42 | SB_LINEUP := 0 43 | SB_PAGEDOWN := 3 44 | SB_PAGEUP := 2 45 | SB_THUMBPOSITION := 4 46 | SB_THUMBTRACK := 5 47 | SB_TOP := 6 48 | 49 | KMD_Scroll(a, b, amount) 50 | { 51 | ; a = WM_HSCROLL or WM_VSCROLL 52 | ; b = one of SB_ above 53 | ControlGetFocus, FocusedControl, A 54 | Loop %amount% 55 | { 56 | SendMessage, %a%, %b%, 0, %FocusedControl%, A ; 0x114 is WM_HSCROLL ; 1 vs. 0 causes SB_LINEDOWN vs. UP } 57 | } 58 | } 59 | 60 | vi_search_not_implemented(direction, word) 61 | { 62 | ; direction one of -1/1 -2/2 abs(direction) > 1 means repeat. 63 | ; if word is "" user should be able to type in the word to search for 64 | MsgBox, "not implemented!" 65 | } 66 | 67 | ; delphi 2009 implementation {{{1 68 | vi_delphi_2009_goto_line(nr) 69 | { 70 | ; Delphi yells if number is too high! 71 | KMD_Send("!g") 72 | WinWaitActive, Zu Zeilennummer gehen 73 | KMD_Send("{Del}" . nr . "{Del}{Enter}") 74 | } 75 | 76 | vi_delphi_2009_search(direction, word) 77 | { 78 | global 79 | local requested_direction 80 | 81 | if (direction * direction == 4){ 82 | ; repeat search 83 | requested_direction := round(direction / 2) * vi_normal_mode["last_search_direction"] 84 | s := vi_normal_mode["delphi2009-last-search-direction"] 85 | 86 | if (requested_direction . "" == vi_normal_mode["delphi2009-last-search-direction"] . "") 87 | { 88 | KMD_Send("{F3}") 89 | return 90 | } 91 | else 92 | { 93 | vi_delphi_2009_search(requested_direction, vi_normal_mode["search_chars"]) 94 | return 95 | } 96 | } 97 | vi_normal_mode["delphi2009-last-search-direction"] := direction 98 | KMD_Send("^f") 99 | WinWaitActive, Text suchen 100 | if (direction == 1) 101 | { 102 | KMD_Send("!v") 103 | } else if (direction == -1) 104 | { 105 | KMD_Send("!w") 106 | } else 107 | { 108 | MsgBox, error search dir is %direction% 109 | } 110 | ; !c: from cursor 111 | ; !s: focus search input field 112 | KMD_Send("!c!s{Del}"+word) 113 | if (word != "") 114 | { 115 | ; del to remove completion 116 | KMD_Send("{Del}{Enter}") 117 | } else 118 | { 119 | KMD_SetMode("vi_insert_mode") 120 | } 121 | } 122 | 123 | EDITOR_API() 124 | { 125 | ; this function get's called whenever the window id changes 126 | ; some code should be added here changing implementation depending on 127 | ; application / window name etc. 128 | 129 | api := {} 130 | api["goto_line"] := "vi_slow_goto_line" 131 | api["search"] := "vi_search_not_implemented" 132 | 133 | ; DELPHI 2009 specific - because that's the app I'm using right now: 134 | ; TODO only asign this if the target is Delphi 2009 135 | api["goto_line"] := "vi_delphi_2009_goto_line" 136 | api["search"] := "vi_delphi_2009_search" 137 | 138 | return api 139 | } 140 | 141 | vi_slow_goto_line(nr) 142 | { 143 | ; goto line 144 | ; this implementation of G can be optimized. Most editiors support "goto line" 145 | vi_normal_mode["repeat_count"] := vi_normal_mode["repeat_count"] -1 146 | KMD_Send("^{Home}") 147 | KMD_ViperDoRepeat("{Down}") 148 | } 149 | 150 | 151 | vi_normal_mode_handle_keys(key) 152 | { 153 | ; MsgBox, %key% 154 | global 155 | local t 156 | local c 157 | 158 | WinGet, win_id, ID, A 159 | 160 | if (win_id != vi_normal_mode["win_id"]) 161 | { 162 | local api := EDITOR_API() 163 | } 164 | 165 | 166 | ;; / ? handling. You have to type blindly 167 | if (vi_normal_mode["mode"] == "gather-search-chars") 168 | { 169 | if (key == "{Enter}") 170 | { 171 | Menu, Tray, Icon, %A_ScriptDir%\Images\vi_normal_mode.ico, 0, 1 172 | vi_normal_mode["mode"] := "" 173 | api["search"](vi_normal_mode["last_search_direction"], vi_normal_mode["search_chars"]) 174 | }else 175 | { 176 | ; TODO handle +A (shift) 177 | vi_normal_mode["search_chars"] := vi_normal_mode["search_chars"] . key 178 | } 179 | return 180 | } 181 | if (key == "/" || key == "?") 182 | { 183 | vi_normal_mode["mode"] := "gather-search-chars" 184 | if (key == "/") 185 | vi_normal_mode["last_search_direction"] := 1 186 | else 187 | vi_normal_mode["last_search_direction"] := -1 188 | vi_normal_mode["search_chars"] := "" 189 | Menu, Tray, Icon, %A_ScriptDir%\Images\gather.ico, 0, 1 190 | return 191 | } 192 | if (key == "n" || key == "+n") 193 | { 194 | if (key == "n") 195 | api["search"](2,"") 196 | else 197 | api["search"](-2,"") 198 | return 199 | } 200 | 201 | 202 | if (vi_normal_mode["last_chars"] == "g") 203 | { 204 | ;; gg gT gt 205 | if (key == "g") 206 | { 207 | KMD_ViperDoRepeat("^{Home}") 208 | } else if (key == "t") 209 | { 210 | KMD_ViperDoRepeat("^{Tab}") 211 | } else if (key == "+t") 212 | { 213 | KMD_ViperDoRepeat("^+{Tab}") 214 | } 215 | vi_normal_mode["last_chars"] := "" 216 | return 217 | } 218 | 219 | if (key == "+g") 220 | { 221 | if (vi_normal_mode["repeat_count"] == 0){ 222 | KMD_Send("^{End}") 223 | } else 224 | { 225 | api["goto_line"](vi_normal_mode["repeat_count"]) 226 | vi_normal_mode["repeat_count"] := 0 227 | } 228 | return 229 | } 230 | 231 | if (key == "g") 232 | { 233 | vi_normal_mode["last_chars"] := vi_normal_mode["last_chars"] . key 234 | return 235 | } 236 | if (key == "^d" || key="^u") 237 | { 238 | ;; I'm not sure whether PgUp/PgDn should be used 239 | ;; PgUp/Don moves cursor 240 | if (key == "^d") 241 | { 242 | KMD_Scroll(WM_VSCROLL, SB_PAGEDOWN, 1) 243 | }else if (key == "^u") 244 | { 245 | KMD_Scroll(WM_VSCROLL, SB_PAGEUP, 1) ; scroll up 246 | } 247 | return 248 | } 249 | 250 | if (key == "n") 251 | { 252 | WinGet, FocusedControl, ID, A 253 | MsgBox %FocusedControl% 254 | } 255 | if (key == "z") 256 | { 257 | c := vi_normal_mode["repeat_count"] ** 2 258 | if c > 100 259 | c := 100 260 | vi_normal_mode["repeat_count"] := c 261 | KMD_ViperDoRepeat("{Up}") 262 | vi_normal_mode["repeat_count"] := c 263 | KMD_ViperDoRepeat("{Down}") 264 | vi_normal_mode["repeat_count"] := c 265 | KMD_ViperDoRepeat("{Down}") 266 | vi_normal_mode["repeat_count"] := c 267 | KMD_ViperDoRepeat("{Up}") 268 | return 269 | } 270 | 271 | if (key == "0" && vi_normal_mode["repeat_count"] == 0) 272 | { 273 | KMD_Send("{Home}") 274 | return 275 | } 276 | if (key == 0 || key == 1 || key == 2 || key == 3 || key == 4 || key == 5 || key == 6 || key == 7 || key == 8 || key == 9) 277 | { 278 | vi_normal_mode["repeat_count"] := vi_normal_mode["repeat_count"] * 10 + key 279 | return 280 | } 281 | 282 | if (vi_normal_mode["last_chars"] == "d"){ 283 | if (key == "d"){ 284 | KMD_Send("{Home}+{Down}") 285 | } 286 | else if (key == "j"){ 287 | KMD_Send("{Home}+{Down}") 288 | KMD_ViperDoRepeat("+{Down}") 289 | } 290 | else if (key == "k"){ 291 | KMD_Send("{Home}{Down}+{Up}") 292 | KMD_ViperDoRepeat("+{Up}") 293 | } 294 | KMD_Send("{Del}") 295 | vi_normal_mode["last_chars"] := "" 296 | return 297 | } 298 | if (key == "d"){ 299 | vi_normal_mode["last_chars"] := "d" 300 | return 301 | } 302 | 303 | 304 | if (vi_normal_mode["simple_commands"].HasKey(key)) 305 | { 306 | KMD_ViperDoRepeat(vi_normal_mode["simple_commands"][key]) 307 | return 308 | } 309 | if (vi_normal_mode["goto_insert_mode"].HasKey(key)) 310 | { 311 | KMD_ViperDoRepeat(vi_normal_mode["goto_insert_mode"][key]) 312 | KMD_SetMode("vi_insert_mode") 313 | return 314 | } 315 | 316 | ; drop repeat count 317 | vi_normal_mode["repeat_count"] := 0 318 | vi_normal_mode["last_chars"] := "" 319 | KMD_Send(key) 320 | } 321 | 322 | 323 | vi_normal_mode := {} 324 | vi_normal_mode["start"] := "start_vi_normal_mode" 325 | vi_normal_mode["end"] := "end_vi_normal_mode" 326 | vi_normal_mode["shortcut"] := "v" 327 | vi_normal_mode["repeat_count"] := 0 328 | vi_normal_mode["handle_keys"] := "vi_normal_mode_handle_keys" 329 | 330 | vi_normal_mode["simple_commands"] := {} 331 | vi_normal_mode["simple_commands"]["h"] := "{Left}" 332 | vi_normal_mode["simple_commands"]["j"] := "{Down}" 333 | vi_normal_mode["simple_commands"]["k"] := "{Up}" 334 | vi_normal_mode["simple_commands"]["l"] := "{Right}" 335 | 336 | vi_normal_mode["simple_commands"]["w"] := "^{Right}" 337 | vi_normal_mode["simple_commands"]["e"] := "^{Right}{Left}" 338 | vi_normal_mode["simple_commands"]["b"] := "^{Left}" 339 | 340 | vi_normal_mode["simple_commands"]["x"] := "{Del}" 341 | vi_normal_mode["simple_commands"]["+x"] := "{BS}" 342 | vi_normal_mode["simple_commands"]["+d"] := "+{END}{Del}" 343 | 344 | vi_normal_mode["simple_commands"]["$"] := "{END}" 345 | ; vi_normal_mode["simple_commands"]["^u"] := "{PgUp}" 346 | ; vi_normal_mode["simple_commands"]["^d"] := "{PgDn}" 347 | vi_normal_mode["simple_commands"]["u"] := "^z" 348 | vi_normal_mode["simple_commands"]["{Enter}"] := "{Home}{Down}" 349 | vi_normal_mode["simple_commands"]["-"] := "{Home}{Up}" 350 | 351 | vi_normal_mode["goto_insert_mode"] := {} 352 | vi_normal_mode["goto_insert_mode"]["o"] := "{End}{Enter}" 353 | vi_normal_mode["goto_insert_mode"]["+o"] := "{Up}{End}{Enter}" 354 | vi_normal_mode["goto_insert_mode"]["i"] := "" 355 | vi_normal_mode["goto_insert_mode"]["+i"] := "{Home}" 356 | vi_normal_mode["goto_insert_mode"]["a"] := "{Right}" 357 | vi_normal_mode["goto_insert_mode"]["+a"] := "{End}" 358 | vi_normal_mode["goto_insert_mode"]["+c"] := "+{End}{Del}" 359 | 360 | ; vi_normal_mode["app_depending_commands"] := {} 361 | ; vi_normal_mode["app_depending_commands"]["CodeGear"] := {} 362 | ; vi_normal_mode["app_depending_commands"]["CodeGear"]["/"] := {} 363 | ; vi_normal_mode["app_depending_commands"]["CodeGear"]["?"] := {} 364 | 365 | KMD_ViperRepeatCount := 0 366 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This project implements vi like keys for any arbitrary editor like app on 2 | windows as far as possible. 3 | 4 | Eg w es emulated by and e is emulated by 5 | 6 | This is a rewrite of 7 | http://www.autohotkey.com/forum/topic44762.html 8 | cleaning up the code removing much repetition. 9 | 10 | 11 | TODO: 12 | implement searches: 13 | /?*# (depend on window. Probably ctl-f can be used almost everywhere, but setting forward / backward might be different) 14 | 15 | implement visual selection mode (needs state) 16 | 17 | 18 | implement things like { } etc. Strategy: Copy whole buffer to clipboard, use 19 | shift-END or such to find position of cursor 20 | using this "current" line calculate movement options 21 | 22 | 23 | 24 | Note: Don't think that this comes even close to Vim features. But it works everywhere 25 | 26 | 27 | TODO: 28 | - make it switch off vi mode if user changes app manually eg by alt-tab 29 | -------------------------------------------------------------------------------- /Scripts/.Kommand-v.0.1alpha.ahk.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Scripts/.Kommand-v.0.1alpha.ahk.swp -------------------------------------------------------------------------------- /Scripts/.Kommand-v.0.1beta.ahk.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Scripts/.Kommand-v.0.1beta.ahk.swp -------------------------------------------------------------------------------- /Scripts/CoreHotkeys.ahk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Scripts/CoreHotkeys.ahk -------------------------------------------------------------------------------- /Scripts/WindowPad.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; WindowPad.ahk 3 | ; Version: 0.4 4 | ; Last Updated: 11/5/2009 5 | ; 6 | ; This file contains functions which are useful for manipulating and moving windows. 7 | ; This is a stripped down version of WindowPad v.1.56 by Lexikos. 8 | ; Downloaded from http://www.autohotkey.com/forum/topic21703.html 9 | ; 10 | 11 | WindowPadMove(P) 12 | { 13 | StringSplit, P, P, `,, %A_Space%%A_Tab% 14 | ; Params: 1:dirX, 2:dirY, 3:widthFactor, 4:heightFactor, 5:window 15 | 16 | if P1 = 17 | P1 = R 18 | if P2 = 19 | P2 = R 20 | 21 | WindowPad_WinExist(P5) 22 | 23 | if !WinExist() 24 | return 25 | 26 | ; Determine width/height factors. 27 | if (P1 or P2) { ; to a side 28 | widthFactor := P3+0 ? P3 : (P1 ? 0.5 : 1.0) 29 | heightFactor := P4+0 ? P4 : (P2 ? 0.5 : 1.0) 30 | } else { ; to center 31 | widthFactor := P3+0 ? P3 : 1.0 32 | heightFactor := P4+0 ? P4 : 1.0 33 | } 34 | 35 | ; Move the window! 36 | MoveWindowInDirection(P1, P2, widthFactor, heightFactor) 37 | } 38 | 39 | MaximizeToggle(P) 40 | { 41 | WindowPad_WinExist(P) 42 | 43 | WinGet, state, MinMax 44 | if state 45 | WinRestore 46 | else 47 | WinMaximize 48 | } 49 | 50 | ; Does the grunt work of the script. 51 | MoveWindowInDirection(sideX, sideY, widthFactor, heightFactor) 52 | { 53 | WinGetPos, x, y, w, h 54 | 55 | hwnd:=WinExist() 56 | if (can_restore := GetWindowProperty(hwnd,"wpHasRestorePos")) 57 | { ; Window has restore info. Check if it is where we last put it. 58 | last_x := GetWindowProperty(hwnd,"wpLastX") 59 | last_y := GetWindowProperty(hwnd,"wpLastY") 60 | last_w := GetWindowProperty(hwnd,"wpLastW") 61 | last_h := GetWindowProperty(hwnd,"wpLastH") 62 | } 63 | if (can_restore && last_x = x && last_y = y && last_w = w && last_h = h) 64 | { ; Window is where we last put it. Check if user wants to restore. 65 | if SubStr(sideX,1,1) = "R" 66 | { ; Restore on X-axis. 67 | restore_x := GetWindowProperty(hwnd,"wpRestoreX") 68 | restore_w := GetWindowProperty(hwnd,"wpRestoreW") 69 | StringTrimLeft, sideX, sideX, 1 70 | } 71 | if SubStr(sideY,1,1) = "R" 72 | { ; Restore on Y-axis. 73 | restore_y := GetWindowProperty(hwnd,"wpRestoreY") 74 | restore_h := GetWindowProperty(hwnd,"wpRestoreH") 75 | StringTrimLeft, sideY, sideY, 1 76 | } 77 | if (restore_x != "" || restore_y != "") 78 | { ; If already at the "restored" size and position, do the normal thing instead. 79 | if ((restore_x = x || restore_x = "") && (restore_y = y || restore_y = "") 80 | && (restore_w = w || restore_w = "") && (restore_h = h || restore_h = "")) 81 | { 82 | restore_x = 83 | restore_y = 84 | restore_w = 85 | restore_h = 86 | } 87 | } 88 | } 89 | else 90 | { ; Next time user requests the window be "restored" use this position and size. 91 | SetWindowProperty(hwnd,"wpHasRestorePos",true) 92 | SetWindowProperty(hwnd,"wpRestoreX",x) 93 | SetWindowProperty(hwnd,"wpRestoreY",y) 94 | SetWindowProperty(hwnd,"wpRestoreW",w) 95 | SetWindowProperty(hwnd,"wpRestoreH",h) 96 | 97 | if SubStr(sideX,1,1) = "R" 98 | StringTrimLeft, sideX, sideX, 1 99 | if SubStr(sideY,1,1) = "R" 100 | StringTrimLeft, sideY, sideY, 1 101 | } 102 | 103 | ; If no direction specified, restore or only switch monitors. 104 | if (sideX+0 = "" && restore_x = "") 105 | restore_x := x, restore_w := w 106 | if (sideY+0 = "" && restore_y = "") 107 | restore_y := y, restore_h := h 108 | 109 | ; Determine which monitor contains the center of the window. 110 | m := GetMonitorAt(x+w/2, y+h/2) 111 | 112 | ; Get work area of active monitor. 113 | gosub CalcMonitorStats 114 | ; Calculate possible new position for window. 115 | gosub CalcNewSizeAndPosition 116 | 117 | ; If the window is already there, 118 | if (newx "," newy "," neww "," newh) = (x "," y "," w "," h) 119 | { ; ..move to the next monitor along instead. 120 | 121 | if (sideX or sideY) 122 | { ; Move in the direction of sideX or sideY. 123 | SysGet, monB, Monitor, %m% ; get bounds of entire monitor (vs. work area) 124 | x := (sideX=0) ? (x+w/2) : (sideX>0 ? monBRight : monBLeft) + sideX 125 | y := (sideY=0) ? (y+h/2) : (sideY>0 ? monBBottom : monBTop) + sideY 126 | newm := GetMonitorAt(x, y, m) 127 | } 128 | else 129 | { ; Move to center (Numpad5) 130 | newm := m+1 131 | SysGet, mon, MonitorCount 132 | if (newm > mon) 133 | newm := 1 134 | } 135 | 136 | if (newm != m) 137 | { m := newm 138 | ; Move to opposite side of monitor (left of a monitor is another monitor's right edge) 139 | sideX *= -1 140 | sideY *= -1 141 | ; Get new monitor's work area. 142 | gosub CalcMonitorStats 143 | } 144 | else 145 | { ; No monitor to move to, alternate size of window instead. 146 | if sideX 147 | widthFactor /= 2 148 | else if sideY 149 | heightFactor /= 2 150 | else 151 | widthFactor *= 1.5 152 | gosub CalcNewSizeAndPosition 153 | } 154 | 155 | ; Calculate new position for window. 156 | gosub CalcNewSizeAndPosition 157 | } 158 | 159 | ; Restore before resizing... 160 | WinGet, state, MinMax 161 | if state 162 | WinRestore 163 | 164 | WinDelay := A_WinDelay 165 | SetWinDelay, 0 166 | 167 | ; Move the window! 168 | WinMove,,, newx, newy, neww, newh 169 | 170 | ; For console windows and other windows which have size restrictions, check 171 | ; that the window was actually resized. If not, reposition based on actual size. 172 | WinGetPos, newx, newy, realw, realh 173 | if (neww != realw || newh != realh) 174 | { 175 | neww := realw 176 | newh := realh 177 | gosub CalcNewPosition 178 | if ((newm = "" || newm = m) && (newx "," newy "," realw "," realh)=(x "," y "," w "," h)) 179 | { 180 | if sideX 181 | neww //= 2 182 | else if sideY 183 | newh //= 2 184 | else 185 | neww := Round(neww*1.5) 186 | ; Size first, since the window size will probably be restricted in some way. 187 | WinMove,,,,, neww, newh 188 | WinGetPos,,, neww, newh 189 | gosub CalcNewPosition 190 | } 191 | WinMove,,, newx, newy 192 | } 193 | 194 | ; Explorer uses WM_EXITSIZEMOVE to detect when a user finishes moving a window 195 | ; in order to save the position for next time. May also be used by other apps. 196 | PostMessage, 0x232 197 | 198 | SetWinDelay, WinDelay 199 | 200 | ; Remember where we put it, to detect if the user moves it. 201 | SetWindowProperty(hwnd,"wpLastX",newx) 202 | SetWindowProperty(hwnd,"wpLastY",newy) 203 | SetWindowProperty(hwnd,"wpLastW",neww) 204 | SetWindowProperty(hwnd,"wpLastH",newh) 205 | return 206 | 207 | CalcNewSizeAndPosition: 208 | ; Calculate new size. 209 | if (IsResizable()) { 210 | neww := restore_w != "" ? restore_w : Round(monWidth * widthFactor) 211 | newh := restore_h != "" ? restore_h : Round(monHeight * heightFactor) 212 | } else { 213 | neww := w 214 | newh := h 215 | } 216 | CalcNewPosition: 217 | ; Calculate new position. 218 | newx := restore_x != "" ? restore_x : Round(monLeft + (sideX+1) * (monWidth - neww)/2) 219 | newy := restore_y != "" ? restore_y : Round(monTop + (sideY+1) * (monHeight - newh)/2) 220 | return 221 | 222 | CalcMonitorStats: 223 | ; Get work area (excludes taskbar-reserved space.) 224 | SysGet, mon, MonitorWorkArea, %m% 225 | monWidth := monRight - monLeft 226 | monHeight := monBottom - monTop 227 | return 228 | } 229 | 230 | ; Get/set window property. type should be int, uint or float. 231 | GetWindowProperty(hwnd, property_name, type="int") { 232 | return DllCall("GetProp", "uint", hwnd, "str", property_name, type) 233 | } 234 | SetWindowProperty(hwnd, property_name, data, type="int") { 235 | return DllCall("SetProp", "uint", hwnd, "str", property_name, type, data) 236 | } 237 | 238 | ; Get the index of the monitor containing the specified x and y co-ordinates. 239 | GetMonitorAt(x, y, default=1) 240 | { 241 | SysGet, m, MonitorCount 242 | ; Iterate through all monitors. 243 | Loop, %m% 244 | { ; Check if the window is on this monitor. 245 | SysGet, Mon, Monitor, %A_Index% 246 | if (x >= MonLeft && x <= MonRight && y >= MonTop && y <= MonBottom) 247 | return A_Index 248 | } 249 | 250 | return default 251 | } 252 | 253 | IsResizable() 254 | { 255 | WinGetClass, Class 256 | if Class = Chrome_XPFrame 257 | return true 258 | if Class = ConsoleWindowClass 259 | return false 260 | WinGet, Style, Style 261 | return (Style & 0x40000) ; WS_SIZEBOX 262 | } 263 | 264 | WindowPad_WinExist(WinTitle) 265 | { 266 | if WinTitle = P 267 | return WinPreviouslyActive() 268 | if WinTitle = M 269 | { 270 | MouseGetPos,,, win 271 | return WinExist("ahk_id " win) 272 | } 273 | return WinExist(WinTitle!="" ? WinTitle : "A") 274 | } 275 | 276 | ; Note: This may not work properly with always-on-top windows. (Needs testing) 277 | WinPreviouslyActive() 278 | { 279 | active := WinActive("A") 280 | WinGet, win, List 281 | 282 | ; Find the active window. 283 | ; (Might not be win1 if there are always-on-top windows?) 284 | Loop, %win% 285 | if (win%A_Index% = active) 286 | { 287 | if (A_Index < win) 288 | N := A_Index+1 289 | 290 | ; hack for PSPad: +1 seems to get the document (child!) window, so do +2 291 | ifWinActive, ahk_class TfPSPad 292 | N += 1 293 | 294 | break 295 | } 296 | 297 | ; Use WinExist to set Last Found Window (for consistency with WinActive()) 298 | return WinExist("ahk_id " . win%N%) 299 | } 300 | 301 | 302 | ; 303 | ; Switch without moving/resizing (relative to screen) 304 | ; 305 | WindowScreenMove(P) 306 | { 307 | SetWinDelay, 0 308 | 309 | StringSplit, P, P, `,, %A_Space%%A_Tab% 310 | ; 1:Next|Prev|Num, 2:Window 311 | 312 | WindowPad_WinExist(P2) 313 | 314 | WinGet, state, MinMax 315 | if state = 1 316 | WinRestore 317 | 318 | WinGetPos, x, y, w, h 319 | 320 | ; Determine which monitor contains the center of the window. 321 | ms := GetMonitorAt(x+w/2, y+h/2) 322 | 323 | SysGet, mc, MonitorCount 324 | 325 | ; Determine which monitor to move to. 326 | if P1 in ,N,Next 327 | { 328 | md := ms+1 329 | if (md > mc) 330 | md := 1 331 | } 332 | else if P1 in P,Prev,Previous 333 | { 334 | md := ms-1 335 | if (md < 1) 336 | md := mc 337 | } 338 | else if P1 is integer 339 | md := P1 340 | 341 | if (md=ms or (md+0)="" or md<1 or md>mc) 342 | return 343 | 344 | ; Get source and destination work areas (excludes taskbar-reserved space.) 345 | SysGet, ms, MonitorWorkArea, %ms% 346 | SysGet, md, MonitorWorkArea, %md% 347 | msw := msRight - msLeft, msh := msBottom - msTop 348 | mdw := mdRight - mdLeft, mdh := mdBottom - mdTop 349 | 350 | ; Calculate new size. 351 | if (IsResizable()) { 352 | w := Round(w*(mdw/msw)) 353 | h := Round(h*(mdh/msh)) 354 | } 355 | 356 | ; Move window, using resolution difference to scale co-ordinates. 357 | WinMove,,, mdLeft + (x-msLeft)*(mdw/msw), mdTop + (y-msTop)*(mdh/msh), w, h 358 | 359 | if state = 1 360 | WinMaximize 361 | } 362 | 363 | 364 | ; 365 | ; "Gather" windows on a specific screen. 366 | ; 367 | GatherWindows(md=1) 368 | { 369 | global ProcessGatherExcludeList 370 | 371 | SetWinDelay, 0 372 | 373 | ; List all visible windows. 374 | WinGet, win, List 375 | 376 | ; Copy bounds of all monitors to an array. 377 | SysGet, mc, MonitorCount 378 | Loop, %mc% 379 | SysGet, mon%A_Index%, MonitorWorkArea, %A_Index% 380 | 381 | if md = M 382 | { ; Special exception for 'M', since the desktop window 383 | ; spreads across all screens. 384 | CoordMode, Mouse, Screen 385 | MouseGetPos, x, y 386 | md := GetMonitorAt(x, y, 0) 387 | } 388 | else if md is not integer 389 | { ; Support A, P and WinTitle. 390 | ; (Gather at screen containing specified window.) 391 | WindowPad_WinExist(md) 392 | WinGetPos, x, y, w, h 393 | md := GetMonitorAt(x+w/2, y+h/2, 0) 394 | } 395 | if (md<1 or md>mc) 396 | return 397 | 398 | ; Destination monitor 399 | mdx := mon%md%Left 400 | mdy := mon%md%Top 401 | mdw := mon%md%Right - mdx 402 | mdh := mon%md%Bottom - mdy 403 | 404 | Loop, %win% 405 | { 406 | ; If this window matches the GatherExclude group, don't touch it. 407 | if (WinExist("ahk_group GatherExclude ahk_id " . win%A_Index%)) 408 | continue 409 | 410 | ; Set Last Found Window. 411 | if (!WinExist("ahk_id " . win%A_Index%)) 412 | continue 413 | 414 | WinGet, procname, ProcessName 415 | ; Check process (program) exclusion list. 416 | if procname in %ProcessGatherExcludeList% 417 | continue 418 | 419 | WinGetPos, x, y, w, h 420 | 421 | ; Determine which monitor this window is on. 422 | xc := x+w/2, yc := y+h/2 423 | ms := 0 424 | Loop, %mc% 425 | if (xc >= mon%A_Index%Left && xc <= mon%A_Index%Right 426 | && yc >= mon%A_Index%Top && yc <= mon%A_Index%Bottom) 427 | { 428 | ms := A_Index 429 | break 430 | } 431 | ; If already on destination monitor, skip this window. 432 | if (ms = md) 433 | continue 434 | 435 | WinGet, state, MinMax 436 | if (state = 1) { 437 | WinRestore 438 | WinGetPos, x, y, w, h 439 | } 440 | 441 | if ms 442 | { 443 | ; Source monitor 444 | msx := mon%ms%Left 445 | msy := mon%ms%Top 446 | msw := mon%ms%Right - msx 447 | msh := mon%ms%Bottom - msy 448 | 449 | ; If the window is resizable, scale it by the monitors' resolution difference. 450 | if (IsResizable()) { 451 | w *= (mdw/msw) 452 | h *= (mdh/msh) 453 | } 454 | 455 | ; Move window, using resolution difference to scale co-ordinates. 456 | WinMove,,, mdx + (x-msx)*(mdw/msw), mdy + (y-msy)*(mdh/msh), w, h 457 | } 458 | else 459 | { ; Window not on any monitor, move it to center. 460 | WinMove,,, mdx + (mdw-w)/2, mdy + (mdh-h)/2 461 | } 462 | 463 | if state = 1 464 | WinMaximize 465 | } 466 | } 467 | 468 | GetLastMinimizedWindow() 469 | { 470 | WinGet, w, List 471 | 472 | Loop %w% 473 | { 474 | wi := w%A_Index% 475 | WinGet, m, MinMax, ahk_id %wi% 476 | if m = -1 ; minimized 477 | { 478 | lastFound := wi 479 | break 480 | } 481 | } 482 | 483 | return "ahk_id " . (lastFound ? lastFound : 0) 484 | } 485 | -------------------------------------------------------------------------------- /Utilities/CloseWindows.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Utilities/CloseWindows.exe -------------------------------------------------------------------------------- /Utilities/NoMouse.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Utilities/NoMouse.exe -------------------------------------------------------------------------------- /Utilities/SnarlCMD.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/Utilities/SnarlCMD.exe -------------------------------------------------------------------------------- /iTunes/BackTrack.vbs: -------------------------------------------------------------------------------- 1 | rem This script calls the iTunes "back track" feature. 2 | rem If you're only a few seconds into the current track 3 | rem then this will move to the previous track. If you're 4 | rem further into the current track then it will restart 5 | rem the current track. 6 | rem You can instead use the script Previous.vbs to always 7 | rem go to the previous track, regardless of your position 8 | rem in the current track. 9 | 10 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 11 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 12 | rem Version 2004-12-09-1 13 | 14 | 15 | ' Variables 16 | dim iTunes 17 | 18 | 19 | ' Connect to iTunes app 20 | set iTunes = CreateObject("iTunes.Application") 21 | 22 | 23 | ' Go to previous track or restart current track 24 | iTunes.BackTrack 25 | 26 | 27 | ' Done; release object 28 | set iTunes = nothing 29 | 30 | 31 | rem End of script. 32 | -------------------------------------------------------------------------------- /iTunes/DeleteTrack.js: -------------------------------------------------------------------------------- 1 | var iTunesApp = WScript.CreateObject("iTunes.Application"); 2 | var oTrackToDelete = iTunesApp.CurrentTrack; 3 | 4 | if (oTrackToDelete != null) { 5 | var objWSH = WScript.CreateObject("Wscript.Shell"); 6 | var intChoice = objWSH.Popup("Do you really want to perminantly delete " + oTrackToDelete.Name + "?", 5000, "Delete " + oTrackToDelete.Name + "?", 52); 7 | if (intChoice == 6) { 8 | iTunesApp.NextTrack(); 9 | var fs = new ActiveXObject("Scripting.FileSystemObject"); 10 | fs.DeleteFile(oTrackToDelete.Location); 11 | oTrackToDelete.Delete(); 12 | } 13 | } -------------------------------------------------------------------------------- /iTunes/FastForward.vbs: -------------------------------------------------------------------------------- 1 | rem This script causes iTunes to "fast forward" through the current track. 2 | rem Call the Play or PlayPause script to resume playing. 3 | 4 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 5 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 6 | rem Version 2004-12-09-1 7 | 8 | 9 | ' Variables 10 | dim iTunes 11 | 12 | 13 | ' Connect to iTunes app 14 | set iTunes = CreateObject("iTunes.Application") 15 | 16 | 17 | ' Start fast forwarding 18 | iTunes.FastForward 19 | 20 | 21 | ' Done; release object 22 | set iTunes = nothing 23 | 24 | 25 | rem End of script. 26 | -------------------------------------------------------------------------------- /iTunes/FindDeadTracks.js: -------------------------------------------------------------------------------- 1 | /* Rename me to FindDeadTracks.js 2 | Double Click in Explorer to run 3 | 4 | Script by Otto - http://ottodestruct.com */ 5 | 6 | var ITTrackKindFile = 1; 7 | var iTunesApp = WScript.CreateObject("iTunes.Application"); 8 | var deletedTracks = 0; 9 | var mainLibrary = iTunesApp.LibraryPlaylist; 10 | var tracks = mainLibrary.Tracks; 11 | var numTracks = tracks.Count; 12 | var i; 13 | 14 | var fso, tf; 15 | fso = new ActiveXObject("Scripting.FileSystemObject"); 16 | tf = fso.CreateTextFile("Dead Tracks.txt", true); 17 | 18 | while (numTracks != 0) 19 | { 20 | var currTrack = tracks.Item(numTracks); 21 | 22 | // is this a file track? 23 | if (currTrack.Kind == ITTrackKindFile) 24 | { 25 | // yes, does it have an empty location? 26 | if (currTrack.Location == "") 27 | { 28 | // write info about the track to a file 29 | tf.WriteLine(currTrack.Artist + "," + currTrack.Album + "," + currTrack.Name); 30 | deletedTracks++; 31 | } 32 | } 33 | 34 | numTracks--; 35 | } 36 | 37 | if (deletedTracks > 0) 38 | { 39 | if (deletedTracks == 1) 40 | { 41 | WScript.Echo("Found 1 dead track."); 42 | } 43 | else 44 | { 45 | WScript.Echo("Found " + deletedTracks + " dead tracks."); 46 | } 47 | } 48 | else 49 | { 50 | WScript.Echo("No dead tracks were found."); 51 | } 52 | tf.Close(); 53 | 54 | -------------------------------------------------------------------------------- /iTunes/GetPlayState.vbs: -------------------------------------------------------------------------------- 1 | rem This script immediately exits, setting the ERRORLEVEL value to 2 | rem indicate the current play state of iTunes. 3 | 4 | rem Possible return values: 5 | rem 0 = Stopped 6 | rem 1 = Playing 7 | rem 2 = Fast-forwarding 8 | rem 3 = Rewinding 9 | 10 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 11 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 12 | rem Version 2004-12-09-1 13 | 14 | 15 | ' Variables 16 | dim iTunes, CurState 17 | 18 | 19 | ' Connect to iTunes app 20 | set iTunes = CreateObject("iTunes.Application") 21 | 22 | 23 | ' Get current state 24 | CurState = iTunes.PlayerState 25 | 26 | 27 | ' Done; release object 28 | set iTunes = nothing 29 | 30 | 31 | ' Quit, returning state 32 | Wscript.Quit CurState 33 | 34 | 35 | rem End of script. 36 | -------------------------------------------------------------------------------- /iTunes/Mute.vbs: -------------------------------------------------------------------------------- 1 | rem Set or toggle iTunes muting. 2 | rem Note that this is a different mute control than 3 | rem that provided by your sound card (which can be easily 4 | rem accessed by double-clicking on the speaker icon in the 5 | rem system tray). 6 | rem Use of this script to control the iTunes muting is 7 | rem not recommended (unless you've got a special need in mind). 8 | 9 | rem Syntax: 10 | rem Mute [on|off] 11 | rem Examples: 12 | rem Mute toggles the current muting state 13 | rem Mute on turns on muting 14 | rem Mute off turns off muting 15 | 16 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 17 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 18 | rem Version 2004-12-09-1 19 | 20 | 21 | Dim iTunes 22 | Dim ArgStr 23 | Dim Msg 24 | 25 | 26 | ' Create app object 27 | Set iTunes = WScript.CreateObject("iTunes.Application") 28 | 29 | 30 | ' Get the argument 31 | Select Case Wscript.Arguments.Count 32 | Case 0 33 | ArgStr = "" 34 | 35 | Case 1 36 | ArgStr = Lcase(Trim(Wscript.Arguments.Item(0))) 37 | 38 | Case Else 39 | ArgStr = "error!" 40 | End Select 41 | 42 | 43 | ' Now interpret the argument and act accordingly 44 | Select Case ArgStr 45 | Case "on" 46 | iTunes.Mute = True 47 | 48 | Case "off" 49 | iTunes.Mute = False 50 | 51 | Case "" 52 | ' Toggle 53 | iTunes.Mute = Not (iTunes.Mute) 54 | 55 | Case Else 56 | Msg = "Please specify 'Mute on' or 'Mute off' to set the mute state, or 'Mute'" 57 | Msg = Msg + " (without an argument) to toggle the mute state." 58 | Wscript.Echo Msg 59 | 60 | End Select 61 | 62 | 63 | ' Done; release object 64 | set iTunes = nothing 65 | 66 | 67 | rem End of script. 68 | -------------------------------------------------------------------------------- /iTunes/Next.vbs: -------------------------------------------------------------------------------- 1 | rem This script tells iTunes to play the next track. 2 | 3 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 4 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 5 | rem Version 2004-12-09-1 6 | 7 | 8 | Dim iTunes 9 | 10 | 11 | ' Connect to iTunes app 12 | Set iTunes = CreateObject("iTunes.Application") 13 | 14 | 15 | ' Go to next track 16 | iTunes.NextTrack 17 | 18 | 19 | ' Done; release object 20 | set iTunes = nothing 21 | 22 | 23 | rem End of script. 24 | -------------------------------------------------------------------------------- /iTunes/Pause.vbs: -------------------------------------------------------------------------------- 1 | rem This script pauses iTunes, regardless of its current state. 2 | 3 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 4 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 5 | rem Version 2004-12-09-1 6 | 7 | 8 | ' Variables 9 | dim iTunes 10 | 11 | 12 | ' Connect to iTunes app 13 | set iTunes = CreateObject("iTunes.Application") 14 | 15 | 16 | ' Pause 17 | iTunes.Pause 18 | 19 | 20 | ' Done; release object 21 | set iTunes = nothing 22 | 23 | 24 | rem End of script. 25 | -------------------------------------------------------------------------------- /iTunes/Play.vbs: -------------------------------------------------------------------------------- 1 | rem This script makes sure that iTunes is playing. 2 | rem If paused, it will start playing. 3 | rem If fast-forwarding or rewinding, it will resume normal playback. 4 | 5 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 6 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 7 | rem Version 2004-12-09-1 8 | 9 | 10 | ' Variables 11 | dim iTunes, CurState 12 | 13 | 14 | ' Connect to iTunes app 15 | set iTunes = CreateObject("iTunes.Application") 16 | 17 | 18 | ' Get current state 19 | CurState = iTunes.PlayerState 20 | 21 | 22 | ' Do the appropriate thing 23 | select case CurState 24 | case 0 25 | ' Stopped 26 | iTunes.PlayPause 27 | 28 | case 1 29 | ' Playing 30 | ' Do nothing! 31 | 32 | case 2 33 | ' Fast-forwarding 34 | iTunes.Resume 35 | 36 | case 3 37 | ' Rewinding 38 | iTunes.Resume 39 | 40 | end select 41 | 42 | 43 | ' Done; release object 44 | set iTunes = nothing 45 | 46 | 47 | rem End of script. 48 | -------------------------------------------------------------------------------- /iTunes/PlayFile.vbs: -------------------------------------------------------------------------------- 1 | rem This script will cause iTunes play the specified file. 2 | rem The file will also be added to your iTunes "Library" 3 | rem if it isn't already in it. 4 | 5 | rem Syntax: 6 | rem PlayFile "FullPath" 7 | rem Example: 8 | rem PlayFile "C:\My Music\Devo\Freedom of Choice\Whip It.MP3" 9 | rem Be sure to enclose the path in quotes if it includes spaces. 10 | 11 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 12 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 13 | rem Version 2004-12-09-1 14 | 15 | 16 | ' Variables 17 | dim iTunes, FullPath 18 | 19 | 20 | ' Get the full path of the file to play 21 | if Wscript.Arguments.Count <> 1 then 22 | ' Error! 23 | Wscript.Echo "Error! Please specify the full path (enclosed in quotes) to the music file that you wish to play." 24 | Wscript.Quit 25 | end if 26 | 27 | FullPath = Wscript.Arguments.Item(1) 28 | 29 | 30 | ' Connect to iTunes app 31 | set iTunes = CreateObject("iTunes.Application") 32 | 33 | 34 | ' Play the file 35 | iTunes.PlayFile FullPath 36 | 37 | 38 | ' Done; release object 39 | set iTunes = nothing 40 | 41 | 42 | rem End of script. 43 | -------------------------------------------------------------------------------- /iTunes/PlayPause.vbs: -------------------------------------------------------------------------------- 1 | rem This script toggles iTunes between playing and pausing. 2 | rem It can also resume playing if currently fast-forwarding or rewinding. 3 | 4 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 5 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 6 | rem Version 2004-12-09-1 7 | 8 | 9 | ' Variables 10 | dim iTunes, CurState 11 | 12 | 13 | ' Connect to iTunes app 14 | set iTunes = CreateObject("iTunes.Application") 15 | 16 | 17 | ' Get current state 18 | CurState = iTunes.PlayerState 19 | 20 | 21 | ' Do the appropriate thing 22 | select case CurState 23 | case 0 24 | ' Stopped 25 | iTunes.PlayPause 26 | 27 | case 1 28 | ' Playing 29 | iTunes.PlayPause 30 | 31 | case 2 32 | ' Fast-forwarding 33 | iTunes.Resume 34 | 35 | case 3 36 | ' Rewinding 37 | iTunes.Resume 38 | 39 | end select 40 | 41 | 42 | ' Done; release object 43 | set iTunes = nothing 44 | 45 | 46 | rem End of script. 47 | -------------------------------------------------------------------------------- /iTunes/PlayPlaylist.vbs: -------------------------------------------------------------------------------- 1 | rem This script will cause iTunes play the first song in the specified playlist. 2 | 3 | rem Examples: 4 | rem PlayPlaylist "5 stars" 5 | rem PlayPlaylist /playlist:"5 stars" 6 | rem Be sure to enclose the playlist name in quotes if it includes spaces. 7 | 8 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 9 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 10 | rem Version 2004-12-09-1 11 | 12 | 13 | rem ================================================= 14 | function GetNamedArg(ArgName) 15 | 16 | 17 | with Wscript.Arguments.Named 18 | if .Exists(ArgName) then 19 | GetNamedArg = .Item(ArgName) 20 | else 21 | GetNamedArg = "" 22 | end if 23 | end with 24 | 25 | 26 | end function 27 | rem ================================================= 28 | 29 | 30 | 31 | 32 | rem ================================================= 33 | rem Main script: 34 | 35 | 36 | ' Variables 37 | Dim iTunes 'As iTunes 38 | Dim ArgPlaylist 'As String 39 | Dim ArgPlaylistLcase 'As String 40 | Dim Playlist 'As IITPlaylist 41 | Dim TempPlaylist 'As IITPlaylist 42 | Dim SyntaxErr 'As Boolean 43 | Dim Msg 'As String 44 | 45 | 46 | ' Init 47 | ArgPlaylist = GetNamedArg("playlist") 48 | Set Playlist = Nothing 49 | 50 | ' Special support: if they provide exactly one unnamed argument, then 51 | ' assume that it's the playlist name (assuming /playlist hasn't been specified) 52 | If (ArgPlaylist = "") And (Wscript.Arguments.Unnamed.Count = 1) Then 53 | ' Use it! 54 | ArgPlaylist = Wscript.Arguments.Unnamed.Item(0) 55 | End If 56 | 57 | 58 | ' Bounds check 59 | SyntaxErr = False 60 | If ArgPlaylist = "" Then SyntaxErr = True 61 | 62 | If SyntaxErr = True Then 63 | Msg = "Please specify the playlist to play." + vbCrLf + vbCrLf 64 | Msg = Msg + "Examples:" + vbCrLf 65 | Msg = Msg + vbTab + "PlayPlaylist ""5 stars""" + vbCrLf 66 | Msg = Msg + vbTab + "PlayPlaylist /playlist:""5 stars""" 67 | Wscript.echo Msg 68 | Wscript.Quit 69 | End If 70 | 71 | 72 | ' Connect to iTunes app 73 | Set iTunes = Wscript.CreateObject("iTunes.Application") 74 | 75 | 76 | ' Find the specified playlist 77 | Set Playlist = Nothing 78 | ArgPlaylistLcase = LCase(ArgPlaylist) 79 | For Each TempPlaylist In iTunes.LibrarySource.Playlists 80 | If LCase(TempPlaylist.Name) = ArgPlaylistLcase Then 81 | ' Match! 82 | Set Playlist = TempPlaylist 83 | Exit For 84 | End If 85 | Next 'TempPlaylist 86 | 87 | ' Did we find one? 88 | If Playlist Is Nothing Then 89 | Wscript.echo "The playlist """ + ArgPlaylist + """ could not be found." 90 | Wscript.Quit 91 | Else 92 | ' Start playing the playlist 93 | Playlist.PlayFirstTrack 94 | End If 95 | 96 | 97 | ' Done; clean up 98 | Set Playlist = Nothing 99 | Set iTunes = Nothing 100 | 101 | 102 | Rem End of script. 103 | -------------------------------------------------------------------------------- /iTunes/PlaySong.vbs: -------------------------------------------------------------------------------- 1 | rem This script will cause iTunes play the specified song. 2 | 3 | rem Examples: 4 | rem PlaySong /song:"Whip It" 5 | rem PlaySong /song:"Whip It" /album:"Freedom of Choice" 6 | rem PlaySong /song:"Whip It" /artist:"Devo" 7 | rem PlaySong /song:"Whip It" /album:"Freedom of Choice" /artist:Devo 8 | rem PlaySong /song:"Whip It" /album:"Freedom of Choice" /artist:"Devo" 9 | rem PlaySong /song:"Whip It" /album:"Freedom of Choice" /artist:"Devo" /playlist:"5 stars" 10 | rem PlaySong "Whip It" 11 | rem Be sure to enclose the names in quotes if they include spaces. 12 | 13 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 14 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 15 | rem Version 2004-12-09-1 16 | 17 | 18 | rem ================================================= 19 | function GetNamedArg(ArgName) 20 | 21 | 22 | with Wscript.Arguments.Named 23 | if .Exists(ArgName) then 24 | GetNamedArg = .Item(ArgName) 25 | else 26 | GetNamedArg = "" 27 | end if 28 | end with 29 | 30 | 31 | end function 32 | rem ================================================= 33 | 34 | 35 | 36 | 37 | rem ================================================= 38 | rem Main script: 39 | 40 | 41 | ' Variables 42 | Dim iTunes 'As iTunes 43 | Dim ArgPlaylist 'As String 44 | Dim ArgPlaylistLcase 'As String 45 | Dim ArgArtist 'As String 46 | Dim ArgAlbum 'As String 47 | Dim ArgSongName 'As String 48 | Dim Tracks_Artist 'As IITTrackCollection 49 | Dim Tracks_Album 'As IITTrackCollection 50 | Dim Tracks_SongName 'As IITTrackCollection 51 | Dim FoundEverwhere 'As Boolean 52 | Dim Track 'As IITTrack 53 | Dim TempTrack 'As IITTrack 54 | Dim FoundTrack 'As IITTrack 55 | Dim Playlist 'As IITPlaylist 56 | Dim TempPlaylist 'As IITPlaylist 57 | Dim SyntaxErr 'As Boolean 58 | Dim Msg 'As String 59 | 60 | 61 | ' Init 62 | ArgPlaylist = GetNamedArg("playlist") 63 | ArgArtist = GetNamedArg("artist") 64 | ArgAlbum = GetNamedArg("album") 65 | ArgSongName = GetNamedArg("song") 66 | Set Playlist = Nothing 67 | Set Tracks_Artist = Nothing 68 | Set Tracks_Album = Nothing 69 | Set Tracks_SongName = Nothing 70 | 71 | ' Special support: if they provide exactly one unnamed argument, then 72 | ' assume that it's the song name (assuming /song hasn't been specified) 73 | If (ArgSongName = "") And (Wscript.Arguments.Unnamed.Count = 1) Then 74 | ' Use it! 75 | ArgSongName = Wscript.Arguments.Unnamed.Item(0) 76 | End If 77 | 78 | 79 | ' Bounds check 80 | SyntaxErr = False 81 | If ArgSongName = "" Then SyntaxErr = True 82 | If (ArgAlbum = "") And (ArgArtist = "") And (ArgSongName = "") Then SyntaxErr = True 83 | 84 | If SyntaxErr = True Then 85 | Msg = "Please specify the song to play. You can also specify an album, artist, or playlist name." + vbCrLf + vbCrLf 86 | Msg = Msg + "Examples:" + vbCrLf 87 | Msg = Msg + vbTab + "PlaySong /song:""Girl U Want""" + vbCrLf 88 | Msg = Msg + vbTab + "PlaySong /song:""Girl U Want"" /artist:Devo" + vbCrLf 89 | Msg = Msg + vbTab + "PlaySong /song:""Girl U Want"" /artist:Devo /album:""Freedom of Choice""" + vbCrLf 90 | Msg = Msg + vbTab + "PlaySong /song:""Girl U Want"" /artist:Devo /album:""Freedom of Choice"" /playlist:""5 stars""" 91 | Wscript.echo Msg 92 | Wscript.Quit 93 | End If 94 | 95 | 96 | ' Connect to iTunes app 97 | Set iTunes = Wscript.CreateObject("iTunes.Application") 98 | 99 | 100 | ' Did they specify a playlist? 101 | If ArgPlaylist <> "" Then 102 | ArgPlaylistLcase = LCase(ArgPlaylist) 103 | ' Find the specified playlist 104 | For Each TempPlaylist In iTunes.LibrarySource.Playlists 105 | If LCase(TempPlaylist.Name) = ArgPlaylistLcase Then 106 | ' Match! 107 | Set Playlist = TempPlaylist 108 | Exit For 109 | End If 110 | Next 'TempPlaylist 111 | 112 | ' Did we find one? 113 | If Playlist Is Nothing Then 114 | Wscript.echo "The playlist """ + ArgPlaylist + """ could not be found." 115 | Wscript.Quit 116 | End If 117 | Else 118 | ' No special playlist, so use the default (library) 119 | Set Playlist = iTunes.LibraryPlaylist 120 | End If 121 | 122 | 123 | ' Get the collections of tracks for the specified fields 124 | If ArgSongName <> "" Then 125 | Set Tracks_SongName = Playlist.Search(ArgSongName, 5) 126 | End If 127 | 128 | If Tracks_SongName Is Nothing Then 129 | ' No matching songs found 130 | Wscript.echo "The song """ + ArgSongName + """ was not found." 131 | Wscript.Quit 132 | End If 133 | 134 | If ArgArtist <> "" Then 135 | Set Tracks_Artist = Playlist.Search(ArgArtist, 2) 136 | End If 137 | 138 | If ArgAlbum <> "" Then 139 | Set Tracks_Album = Playlist.Search(ArgAlbum, 3) 140 | End If 141 | 142 | 143 | ' Now iterate through the found songs. 144 | ' We're going to play the first song we find which is also in 145 | ' Tracks_Artist and Tracks_Album if specified 146 | Set FoundTrack = Nothing 147 | For Each Track In Tracks_SongName 148 | ' Assume success 149 | FoundEverwhere = True 150 | 151 | ' Album? 152 | If Not (Tracks_Album Is Nothing) Then 153 | Set TempTrack = Nothing 154 | Set TempTrack = Tracks_Album.ItemByName(Track.Name) 155 | If TempTrack Is Nothing Then 156 | ' Song not found in this album 157 | FoundEverwhere = False 158 | Else 159 | ' Found! Do nothing. 160 | End If 161 | End If 162 | 163 | ' Artist? 164 | If (FoundEverwhere = True) And (Not (Tracks_Artist Is Nothing)) Then 165 | Set TempTrack = Nothing 166 | Set TempTrack = Tracks_Artist.ItemByName(Track.Name) 167 | If TempTrack Is Nothing Then 168 | ' Song not found in this Artist 169 | FoundEverwhere = False 170 | Else 171 | ' Found! Do nothing. 172 | End If 173 | End If 174 | 175 | ' Result? 176 | If FoundEverwhere = True Then 177 | ' Success! 178 | Set FoundTrack = Track 179 | Exit For 180 | End If 181 | 182 | Next 'Track 183 | 184 | 185 | If FoundTrack Is Nothing Then 186 | ' Explain that the song wasn't found 187 | Wscript.echo "The song """ + ArgSongName + """ was not found." 188 | Else 189 | ' Play it! 190 | FoundTrack.Play 191 | End If 192 | 193 | 194 | ' Done; clean up 195 | Set Track = Nothing 196 | Set FoundTrack = Nothing 197 | Set TempTrack = Nothing 198 | Set Playlist = Nothing 199 | Set Tracks_Artist = Nothing 200 | Set Tracks_Album = Nothing 201 | Set Tracks_SongName = Nothing 202 | Set iTunes = Nothing 203 | 204 | 205 | Rem End of script. 206 | -------------------------------------------------------------------------------- /iTunes/Previous.vbs: -------------------------------------------------------------------------------- 1 | rem This script tells iTunes to play the previous track. 2 | rem Note that this will always move to the previous track, 3 | rem regardless of the position within the current track. 4 | rem You can use the script BackTrack.vbs to use the "back track" 5 | rem feature of iTunes, which restarts the current track if you're 6 | rem at least a few seconds into it, or goes to the previous track 7 | rem if you're within the first few seconds of the current track. 8 | 9 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 10 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 11 | rem Version 2004-12-09-1 12 | 13 | 14 | Dim iTunes 15 | 16 | 17 | ' Connect to iTunes app 18 | Set iTunes = CreateObject("iTunes.Application") 19 | 20 | 21 | ' Go to previous track 22 | iTunes.PreviousTrack 23 | 24 | 25 | ' Done; release object 26 | set iTunes = nothing 27 | 28 | 29 | rem End of script. 30 | -------------------------------------------------------------------------------- /iTunes/RemoveDeadTracks.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcWeber/autohotkey_viper/aadd930d93e119e27f69512e2d1287c5713b66a8/iTunes/RemoveDeadTracks.js -------------------------------------------------------------------------------- /iTunes/Rewind.vbs: -------------------------------------------------------------------------------- 1 | rem This script causes iTunes to "rewind" through the current track. 2 | rem Call the Play or PlayPause script to resume playing. 3 | 4 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 5 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 6 | rem Version 2004-12-09-1 7 | 8 | 9 | ' Variables 10 | dim iTunes 11 | 12 | 13 | ' Connect to iTunes app 14 | set iTunes = CreateObject("iTunes.Application") 15 | 16 | 17 | ' Start rewinding 18 | iTunes.Rewind 19 | 20 | 21 | ' Done; release object 22 | set iTunes = nothing 23 | 24 | 25 | rem End of script. 26 | -------------------------------------------------------------------------------- /iTunes/ScriptEngineCache-Start.vbs: -------------------------------------------------------------------------------- 1 | rem This script runs continuously in order to keep the script engine loaded. 2 | rem Run the script "ScriptEngineCache-Stop.vbs" in order to make -this- script exit. 3 | 4 | rem Modifying this script: 5 | rem You can change the MILLISECONDS_TO_SLEEP value to specify a different number of milliseconds 6 | rem to sleep. (1000 milliseconds equals 1 second.) The value doesn't matter much, as the overhead 7 | rem incurred when this script runs is minimal. You can even drop the value to 1000 or lower and 8 | rem you won't be able to see any performance impact on your system. The initial value of 5000 9 | rem (ie, 5 seconds) was chosen because it seems more 'polite' but in fact a much lower value 10 | rem would have the same (minimal) impact on your system. 11 | 12 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 13 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 14 | rem Version 2004-12-09-1 15 | 16 | 17 | ' Constants 18 | const REG_KEY = "HKCU\Software\Microsoft\Windows Script Host\Settings\ScriptEngineCache-VbScript" 19 | const REG_VALUE_FLAG = "1" 20 | const MILLISECONDS_TO_SLEEP = 5000 21 | 22 | 23 | ' Variables 24 | dim Shell, RegValue 25 | 26 | 27 | ' Init 28 | set Shell = WScript.CreateObject("WScript.Shell") 29 | 30 | 31 | ' Write "stay active" flag 32 | Shell.RegWrite REG_KEY , REG_VALUE_FLAG, "REG_SZ" 33 | 34 | 35 | ' Loop 36 | do 37 | Wscript.Sleep MILLISECONDS_TO_SLEEP 38 | RegValue = Shell.RegRead(REG_KEY) 39 | loop while RegValue = REG_VALUE_FLAG 40 | 41 | 42 | ' Done; clean up 43 | Shell.RegDelete REG_KEY 44 | set Shell = nothing 45 | 46 | 47 | rem End of script. 48 | -------------------------------------------------------------------------------- /iTunes/ScriptEngineCache-Stop.vbs: -------------------------------------------------------------------------------- 1 | rem Another script (ScriptEngineCache-Start.vbs) runs continuously in order to keep the script engine loaded. 2 | rem Run -this- script (ScriptEngineCache-Stop.vbs) in order to make the other script exit. 3 | 4 | rem Modifying this script: 5 | rem You can change the MILLISECONDS_TO_SLEEP value to specify a different number of milliseconds 6 | rem to sleep. (1000 milliseconds equals 1 second.) The value doesn't matter much, as the overhead 7 | rem incurred when this script runs is minimal. You can even drop the value to 1000 or lower and 8 | rem you won't be able to see any performance impact on your system. The initial value of 5000 9 | rem (ie, 5 seconds) was chosen because it seems more 'polite' but in fact a much lower value 10 | rem would have the same (minimal) impact on your system. 11 | 12 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 13 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 14 | rem Version 2004-12-09-1 15 | 16 | 17 | ' Constants 18 | const REG_KEY = "HKCU\Software\Microsoft\Windows Script Host\Settings\ScriptEngineCache-VbScript" 19 | 20 | 21 | ' Variables 22 | dim Shell 23 | 24 | 25 | ' Init 26 | set Shell = WScript.CreateObject("WScript.Shell") 27 | 28 | 29 | ' Clear the "stay active" flag 30 | Shell.RegWrite REG_KEY, "", "REG_SZ" 31 | 32 | 33 | ' Done; clean up 34 | set Shell = nothing 35 | 36 | 37 | rem End of script. 38 | -------------------------------------------------------------------------------- /iTunes/SetVolume.vbs: -------------------------------------------------------------------------------- 1 | rem Set the volume within iTunes. 2 | rem Note that this is a different volume control than 3 | rem that provided by your sound card (which can be easily 4 | rem accessed by double-clicking on the speaker icon in the 5 | rem system tray). 6 | rem Normally you will want to keep iTunes set to its maximum 7 | rem volume and adjust your sound card's volume using the 8 | rem normal mapping of your multimedia keyboard. Therefore, 9 | rem use of this script to control the iTunes volume is 10 | rem not recommended (unless you've got a special need in mind). 11 | 12 | rem Syntax: 13 | rem SetVolume [+|-]number 14 | rem Examples: 15 | rem SetVolume 0 sets volume to "off" (but not the same as "mute") 16 | rem SetVolume 100 sets volume to highest possible value 17 | rem SetVolume 50 sets volume to 50 (ie, half) 18 | rem SetVolume -10 turns volume down by 10% 19 | rem Note that the volume ranges from 0 to 100. 20 | 21 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 22 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 23 | rem Version 2004-12-09-1 24 | 25 | 26 | Dim iTunes 27 | Dim ArgErr 28 | Dim ArgStr 29 | Dim ArgVal 30 | Dim p 31 | Dim IsRelative 32 | Dim NewLevel 33 | 34 | 35 | ' Create app object 36 | Set iTunes = WScript.CreateObject("iTunes.Application") 37 | 38 | 39 | ' Get the argument 40 | ArgErr = false 41 | if Wscript.Arguments.Count <> 1 then 42 | ' Error! 43 | ArgErr = true 44 | else 45 | ' See if it's reasonable 46 | ArgStr = Wscript.Arguments.Item(0) 47 | ArgVal = -127 ' some unlikely value 48 | 49 | if IsNumeric(ArgStr) then 50 | ' Try to convert 51 | on error resume next 52 | Err.Clear 53 | ArgVal = cint(ArgStr) 54 | if (Err.Number <> 0) or (ArgVal = -127) then 55 | ' Couldn't convert string to a number 56 | ArgErr = true 57 | end if 58 | on error goto 0 59 | else 60 | ArgErr = true 61 | end if 62 | end if 63 | 64 | 65 | if ArgErr then 66 | ' Display error message 67 | Wscript.Echo "Error! Please specify a volume level between 0 and 100, or a relative value such as -10." 68 | else 69 | ' Calculate new volume level 70 | IsRelative = ( (left(ArgStr,1) = "+") or (left(ArgStr,1) = "-") ) 71 | if IsRelative then 72 | NewLevel = iTunes.SoundVolume + ArgVal 73 | else 74 | NewLevel = ArgVal 75 | end if 76 | 77 | ' Set the new level 78 | iTunes.SoundVolume = NewLevel 79 | end if 80 | 81 | 82 | ' Done; release object 83 | set iTunes = nothing 84 | 85 | 86 | rem End of script. 87 | -------------------------------------------------------------------------------- /iTunes/Stop.vbs: -------------------------------------------------------------------------------- 1 | rem This script stops iTunes, regardless of its current mode. 2 | rem (Possible modes are playing, paused, fast-forwarding, or rewinding.) 3 | rem Note that "stopping" means that iTunes will stop any playback 4 | rem and return to the beginning of the current track. 5 | rem Of course, this is different than pausing. 6 | 7 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 8 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 9 | rem Version 2004-12-09-1 10 | 11 | 12 | ' Variables 13 | dim iTunes, CurState 14 | 15 | 16 | ' Connect to iTunes app 17 | set iTunes = WScript.CreateObject("iTunes.Application") 18 | 19 | 20 | ' Stop and return to beginning of current track 21 | iTunes.Stop 22 | 23 | 24 | ' Done; release object 25 | set iTunes = nothing 26 | 27 | 28 | rem End of script. 29 | -------------------------------------------------------------------------------- /iTunes/VolumeDown.vbs: -------------------------------------------------------------------------------- 1 | rem Decrement the volume within iTunes by 10 points. 2 | rem Note that this is a different volume control than 3 | rem that provided by your sound card (which can be easily 4 | rem accessed by double-clicking on the speaker icon in the 5 | rem system tray). 6 | rem Normally you will want to keep iTunes set to its maximum 7 | rem volume and adjust your sound card's volume using the 8 | rem normal mapping of your multimedia keyboard. Therefore, 9 | rem use of this script to control the iTunes volume is 10 | rem not recommended (unless you've got a special need in mind). 11 | 12 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 13 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 14 | rem Version 2004-12-09-1 15 | 16 | 17 | Dim iTunes 18 | 19 | 20 | ' Create app object 21 | Set iTunes = WScript.CreateObject("iTunes.Application") 22 | 23 | 24 | ' Decrement volume by 10 points 25 | iTunes.SoundVolume = iTunes.SoundVolume - 10 26 | 27 | 28 | ' Done; release object 29 | set iTunes = nothing 30 | 31 | 32 | rem End of script. 33 | -------------------------------------------------------------------------------- /iTunes/VolumeUp.vbs: -------------------------------------------------------------------------------- 1 | rem Increment the volume within iTunes by 10 points. 2 | rem Note that this is a different volume control than 3 | rem that provided by your sound card (which can be easily 4 | rem accessed by double-clicking on the speaker icon in the 5 | rem system tray). 6 | rem Normally you will want to keep iTunes set to its maximum 7 | rem volume and adjust your sound card's volume using the 8 | rem normal mapping of your multimedia keyboard. Therefore, 9 | rem use of this script to control the iTunes volume is 10 | rem not recommended (unless you've got a special need in mind). 11 | 12 | rem Copyright 2004 Maximized Software, Inc. All rights reserved. 13 | rem More info is available at: http://www.maximized.com/freeware/ScriptsForiTunes/ 14 | rem Version 2004-12-09-1 15 | 16 | 17 | Dim iTunes 18 | 19 | 20 | ' Create app object 21 | Set iTunes = WScript.CreateObject("iTunes.Application") 22 | 23 | 24 | ' Increase volume by 10 points 25 | iTunes.SoundVolume = iTunes.SoundVolume + 10 26 | 27 | 28 | ' Done; release object 29 | set iTunes = nothing 30 | 31 | 32 | rem End of script. 33 | -------------------------------------------------------------------------------- /iTunes/iTunesAlarm.js: -------------------------------------------------------------------------------- 1 | var iTunesApp = WScript.CreateObject("iTunes.Application"); 2 | 3 | iTunesApp.Pause(); 4 | iTunesApp.SoundVolume = 0; 5 | iTunesApp.Play(); 6 | 7 | var i = 1; 8 | while (i <= 50) { 9 | iTunesApp.SoundVolume = i; 10 | WScript.Sleep(3000); 11 | i++; 12 | } 13 | while (i <= 100) { 14 | iTunesApp.SoundVolume = i; 15 | WScript.Sleep(6000); 16 | i++; 17 | } 18 | 19 | WScript.Quit(); --------------------------------------------------------------------------------