; Rocker ; Author: Adam Pash ; A mouse rocker application - ; Script Function: ; Rocker lets you navigate certain applications ; by rocking across the left and right mouse buttons ; #SingleInstance,Force #NoEnv SendMode Input SetWorkingDir, "%A_ScriptDir%" disable := 0 Gosub,RESOURCES Gosub,TRAYMENU Gosub,READINI if update = 1 SetTimer,UpdateCheck,200000 RButton:: direction = GetKeyState,leftMouse,LButton if leftMouse = D { direction = right active_window := WinExist("A") rock(direction, active_window) } else { MouseGetPos,before_x,before_y Loop { MouseGetPos,after_x,after_y if (before_x != after_x) or (before_y != after_y) { ;Msgbox,%before_x%, %after_x% ;Msgbox,%before_y%, %after_y% Send,{RButton down} break } GetKeyState,leftMouse,LButton if leftMouse = D { active_window := WinExist("A") direction = left rock(direction, active_window) break } GetKeyState,rightMouse,RButton,P if rightMouse = U break } } KeyWait,RButton if direction <> return else Send,{RButton} return rock(direction, active_window){ alt_group = firefox.exe,iexplore.exe,opera.exe,feeddemon.exe ctrl_group = itunes.exe ctrl_tab = notepad++.exe,excel.exe,dreamweaver.exe,pidgin.exe WinGet,process,ProcessName,ahk_id %active_window% ;MsgBox,Rock %direction% in %process% if process in %alt_group% { Send,!{%direction%} } else if process in %ctrl_group% { Send,^{%direction%} } else if process = explorer.exe { Sleep,150 if direction = left Send,{BS} else Send,!{Left} } else if process in %ctrl_tab% { if process = excel.exe Sleep,150 if direction = right Send,^{Tab} else Send,^+{Tab} } } return TRAYMENU: Menu,TRAY,NoStandard Menu,TRAY,DeleteAll Menu,TRAY,Add,&Preferences,PREFS ;;; Set up preferences in later release Menu,TRAY,Add,&Help,HOMEPAGE Menu,TRAY,Add Menu,TRAY,Add,&About...,ABOUT Menu,TRAY,Add,&Disable,DISABLE_TOGGLE ;;; Fix disable in later release ;if disable = 1 ; Menu,Tray,Check,&Disable Menu,TRAY,Add,E&xit,EXIT Menu,TRAY,Default,&Preferences ;;; Set up preferences in later release Menu,Tray,Tip,Rocker Menu, Tray, Icon, resources/rocker.ico, , 1 return PREFS: Gui, Font, S8 CDefault, arial Gui, Add, CheckBox,vCheck x36 y20 w280 h30 Checked%update%, Check for updates when Rocker starts? IniRead,OnStartup,rocker.ini,Preferences,Startup Gui, Add, CheckBox, vStartup x36 y60 w280 h30 Checked%OnStartup%, Run Rocker when Windows starts? Gui, Add, Button, x286 y100 w100 h28 gCancel,&Cancel Gui, Add, Button, x176 y100 w100 h28 Default gOK,&OK ; Generated using SmartGUI Creator 4.0 Gui, Show, h138 w396, Rocker Preferences Return OK: Gui,Submit Gui,Destroy If Startup = 1 { IfNotExist %A_StartMenu%\Programs\Startup\Rocker.lnk ;Get icon for shortcut link: ;1st from compiled EXE if %A_IsCompiled% { IconLocation=%A_ScriptFullPath% } ;2nd from icon in resources folder else IfExist %A_WorkingDir%\resources\rocker.ico { IconLocation=%A_WorkingDir%\resources\rocker.ico } ;3rd from the AutoHotkey application itself else { IconLocation=%A_AhkPath% } ;use %A_ScriptFullPath% instead of %A_WorkingDir%\texter.exe ;to allow compatibility with source version FileCreateShortcut,%A_ScriptFullPath%,%A_StartMenu%\Programs\Startup\Rocker.lnk,%A_WorkingDir%,,,%IconLocation% } else { IfExist %A_StartMenu%\Programs\Startup\Rocker.lnk { FileDelete %A_StartMenu%\Programs\Startup\Rocker.lnk } } IniWrite,%Startup%,rocker.ini,Preferences,Startup IniWrite,%Check%,rocker.ini,Preferences,UpdateCheck Gosub,READINI return CANCEL: Gui,Destroy return DISABLE_TOGGLE: ;;; Suspending hotkeys for some reason doesn't work for this Suspend,Toggle ;;; Fix in later version Menu,Tray,ToggleCheck,&Disable return READINI: IfNotExist rocker.ini { MsgBox,4,Check for Updates?,Would you like Rocker to automatically check for updates when it's run? IfMsgBox,Yes updatereply = 1 else updatereply = 0 } update := GetValFromIni("Preferences","UpdateCheck",updatereply) IniWrite,0.2,rocker.ini,Preferences,Version return GetValFromIni(section, key, default) { IniRead,IniVal,rocker.ini,%section%,%key% if IniVal = ERROR { IniWrite,%default%,rocker.ini,%section%,%key% IniVal := default } return IniVal } UpdateCheck: ;MsgBox,Checking SetTimer, UpdateCheck, Off UrlDownloadToFile,http://svn.adampash.com/rocker/CurrentVersion.txt,%A_WorkingDir%\VersionCheck.txt if ErrorLevel = 0 { FileReadLine, Latest, %A_WorkingDir%\VersionCheck.txt,1 IniRead,Current,rocker.ini,Preferences,Version if Latest != %Current% { MsgBox,4,A new version of Rocker is available!,Would you like to visit the Rocker homepage and download the latest version? IfMsgBox,Yes Goto,Homepage } FileDelete,%A_WorkingDir%\VersionCheck.txt ;; delete version check } return HOMEPAGE: Run,http://lifehacker.com/software/lifehacker-code/rocker-mouse-navigation-tool-windows-257609.php return ABOUT: Gui,2: Destroy Gui,2: Add, Picture, x16 y20 w60 h60 , resources/rocker.png Gui,2: Font, S28 CDefault, Verdana Gui,2: Add, Text, x96 y20 w340 h60 , Rocker 0.2 Gui,2: Font, S8 CDefault, Arial Gui,2: Add, Text, x36 y100 w380 h60 , Rocker adds mouse rocker navigation to many popular windows programs, allowing you to, for example, navigate forward and backward in your favorite web browser by rocking your fingers across the mouse keys. Gui,2: Add, Text, x36 y145 w380 h70 , `nRocker is written by Adam Pash and distributed by Lifehacker under the GNU Public License. For details on how to use Rocker`, check out the Gui,2: Font, S8 Cblue Underline, Arial Gui,2: Add, Text, x347 y173 w170 h30 gHomepage, Rocker homepage ; Generated using SmartGUI Creator 4.0 Gui,2: Show, h225 w459, About Rocker return RESOURCES: IfNotExist,resources { FileCreateDir,resources FileInstall,resources\rocker.png,%A_ScriptDir%\resources\rocker.png,0 FileInstall,resources\rocker.ico,%A_ScriptDir%\resources\rocker.ico,0 } return EXIT: ExitApp return