RomanK Posted May 11, 2009 Share Posted May 11, 2009 (edited) hello everyone,I recently tried out Iron and I really like it. But unfortuanetly I can't switch through tabs or close them with my mouse.There are many programmes to add mouse gestures, but I'm still to lazy to move my mouse so much So I made this easy and simple script which basically does the same job what I was used to before, when using the Maxthon browser.You can switch to the previous / next tabs by scrolling with the mouse wheel up / down while holding the right mouse button pressed.Closing tabs is as easy: Hold the right mouse button and perform a short left click (it is important that the click is very quick because otherwise you'd close several tabs (see the sleep(200) in code if you experience problems).Have fun! Edit: Second version makes sure that context menus also close if they appear after it should have been closed.If you notice context menus don't work right after a combo anymore, lower the 'If $timerdiff < 1000' value. expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=ctrl.ico #AutoIt3Wrapper_outfile=ctrl+.exe #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Fileversion=0 #AutoIt3Wrapper_Res_LegalCopyright=2009, Roman Kilgus #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- -------------------------------------------------------------------------------- ctrl+ by Roman Kilgus, Copyright 2009 -------------------------------------------------------------------------------- If you want to improve this code and post it anywhere on the internet, don't remove my copyright. I'd wish to be informed about it, too. Thx! However, improvements of the code are very welcome! #ce ---------------------------------------------------------------------------- ; Script Start #include <Misc.au3> #include <WinAPI.au3> ; GUI & CO Initialization Opt("OnExitFunc", "exitfunc"); Calls the func below to release the hook and dll. Opt("TrayAutoPause", 0); don't pause the script when user clicks at the tray icon Opt("TrayMenuMode",1); hide the tray menu's default entries (exit & pause) TrayCreateItem("ctrl+") TrayItemSetState(-1, 128); disables item to make it a label TrayCreateItem(""); empty space $help = TrayCreateItem("Help"); msgbox help $setup = TrayCreateItem("Setup"); not used yet $exit = TrayCreateItem("Exit"); exits the program TraySetToolTip("ctrl+ ...Advancing your control!"); replacing silly default tooltip $dll = DllOpen("user32.dll"); open dll for _IsPressed() Dim $ActionPerformed; dim var to check whether the context menu appears because of a combo or not Dim $timer; dim the timer's var for later use ; WinAPI Mouse Capture Initialization Dim Const $WM_MOUSEWHEEL = 0x020A ;Dim Const $WM_MOUSELAST = 0x020A Dim Const $StructString = $tagPOINT&';dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo' $FuncHandle = DllCallbackRegister("action", "long", "int;wparam;lparam") $FuncPointer = DllCallbackGetPtr($FuncHandle) $HookHandle = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $FuncPointer, _WinAPI_GetModuleHandle(0)); mouse hook is now set up ; Main Loop While 1 $msg = TrayGetMsg() Switch $msg Case $exit, -3 Exit Case $setup MsgBox(0, "ctrl+", "There are no setup options to configure, yet.", 5) ; not used yet Case $help $info = "This program was designed to add missing mouse functions to Chromium (Google's Chrome or SRWare's Iron)." &@CRLF& _ "- Press and hold the right mouse button while using the mouse wheel to switch through the opened tabs." &@CRLF& _ "- Press and hold the right mouse button and perform a left mouse button click to close the currently opened tab." &@CRLF&@CRLF& _ "Copyright 2009, Roman Kilgus" MsgBox(0, "ctrl+", $info) $info = "" EndSwitch If _IsPressed(01, $dll) And _IsPressed(02, $dll) And WinActive("[CLASS:Chrome_WidgetWin_0]") Then; Left mouse button pressed closes tab Send("^w"); close tab. Sleep(200); Prevent the script from closing several tabs if you don't click to quickly. ;If you need more than 200ms for the click (= left button down & up), another tab will be closed. Adjust this to your like. $ActionPerformed = True; instead of the line below to enable the user to close several tabs without releasing right mouse button ;If WinWait("[CLASS:#32768]", "", 10) And WinActive("[CLASS:Chrome_WidgetWin_0]") Then Send("{ESCAPE}"); To close the opening context menu EndIf If $ActionPerformed = True And WinExists("[CLASS:#32768]") And WinActive("[CLASS:Chrome_WidgetWin_0]") Then; If context menu is 1. existant, 2. from inside the browser and 3. caused by a mouse-combo Send("{ESCAPE}"); To close the opening context menu $ActionPerformed = False If WinExists("[CLASS:#32768]") Then $timer = TimerInit() EndIf EndIf If $ActionPerformed = False And WinExists("[CLASS:#32768]") And WinActive("[CLASS:Chrome_WidgetWin_0]") Then; If there is still a context menu although it should have been closed before $timer_diff = TimerDiff($timer); Stop the time If $timer_diff < 1000 Then; Make sure the user didn't want to call the context menu Send("{ESCAPE}"); To close the opening context menu finally ;Sleep(200); for debugging ;MsgBox(0, "", "yes, finally it gets hidden"); message for debugging EndIf EndIf WEnd Func exitfunc(); release hook and dll DllClose($dll) _WinAPI_UnhookWindowsHookEx($HookHandle) DllCallbackFree($FuncHandle) EndFunc Func action($iCode, $iwParam, $ilParam); detect mouse actions If _IsPressed(02, $dll) Then; If right mouse button is pressed Local $Struct = DllStructCreate($StructString, $ilParam) If $iCode < 0 Then Return _WinAPI_CallNextHookEx($HookHandle, $iCode, $iwParam, $ilParam) EndIf If $iwParam = $WM_MOUSEWHEEL Then Local $iValue = DllStructGetData($Struct, 'mouseData')/2^16 If BitAND($iValue, 0x8000) Then $iValue = BitOR($iValue, 0xFFFF0000) If $iValue > 0 Then Send("^{PGUP}"); If $iValue = 120 Then switch a tab left $ActionPerformed = True Else Send("^{PGDN}"); If $iValue = - 120 Then switch a tab right $ActionPerformed = True EndIf EndIf Return _WinAPI_CallNextHookEx($HookHandle, $iCode, $iwParam, $ilParam) EndIf EndFunc ;==>_KeyProc ; Script Ending Edited May 11, 2009 by RomanK [font="Courier New"]http://RomanK.hondadesigns.com[/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now