AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ultimate MX Revolution Hotkey list!

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Thu Nov 01, 2007 2:06 am    Post subject: Ultimate MX Revolution Hotkey list! Reply with quote

As a long standing fan of Logitech Mice and Microsoft Keyboards, and after using the great MX 1000 and then the superb G7, I finally succumbed and bought the latest Logitech Mouse "MX Revolution".

This mouse is the best I've ever used. With its superb design, it fits on the hand like a glove. The 8 extra keys are well placed on the various surfaces of the mouse, the "Micro-Gear" Wheel is a genius concept and the craftsmanship is simply magnificent.

There are only two weak points:
1. The accuracy is slightly worse than G7's (though you won't notice after a while)
2. Logitech SetPoint (still, you can fix all the shortcomings)

MX Revolution is a 12-button mouse!! Giving you vast options for customization. Theoretically this mouse can give up to 100 Exclamation combinations to dispatch various hotkeys, though for practical reasons this number falls down to 90 due to hotkeys that would need 2 hands to be pressed.

In order to avoid SetPoint's shortcomings install immediately UberOptions and map your mouse like this:

Code:

01. LButton - Click
02. RButton - Right Click
03. MButton - Reserved (Micro-Gear Wheel)
04. SButton - Middle Click
05. WheelUp - Wheel Up
06. WheelDown - Wheel Down
07. WheelLeft - F14
08. WheelRight - F15
09. ThumbUp - F18
10. ThumbDown - F19
11. ThumbWheelUp - F16
12. ThumbWheelDown - F17
13. ThumbWheelPush - F13


Here is the keymap file:

Code:

MX Revolution Hotkey List & Combinations
Buttons:
01. LButton - Click
02. RButton - Right Click
03. MButton - Reserved (Micro-Gear Wheel)
04. SButton - Middle Click
05. WheelUp - Wheel Up
06. WheelDown - Wheel Down
07. WheelLeft - F14: Back
08. WheelRight - F15: Forward
09. ThumbUp - F18: Copy
10. ThumbDown - F19: Paste
11. ThumbWheelUp - F16: Rotate Windows Left
12. ThumbWheelDown - F17: Rotate Windows Right
13. ThumbWheelPush - F13: Close Windows

RButton Modifiers:
01. RButton & LButton -
02. RButton & WheelUp -
03. RButton & WheelDown -
04. RButton & WheelLeft - Firefox: New Tab
05. RButton & WheelRight
06. RButton & SButton - Firefox: Undo Close Tab
07. RButton & ThumbUp -
08. RButton & ThumbDown -
09. RButton & ThumbWheelUp - Firefox: Cycle Tab Forward
10. RButton & ThumbWheelDown - Firefox: Cycle Tab Backward
11. RButton & ThumbWheelPush - Firefox: Close Current Tab

SButton Modifiers:
01. SButton & LButton - Enter
02. SButton & RButton - Escape
03. SButton & ThumbUp - Clipboard History Forward
04. SButton & ThumbDown - Clipboard History Backward
05. SButton & ThumbWheelUp - Undo
06. SButton & ThumbWheelDown - Redo
07. SButton & ThumbWheelPush - Select All

WheelLeft Modifiers:
01. WheelLeft & LButton -
02. WheelLeft & RButton -
03. WheelLeft & WheelUp -
04. WheelLeft & WheelDown -
05. WheelLeft & SButton -
06. WheelLeft & ThumbUp -
07. WheelLeft & ThumbDown -
08. WheelLeft & ThumbWheelUp -
09. WheelLeft & ThumbWheelDown -
10. WheelLeft & ThumbWheelPush -

WheelRight Modifiers:
01. WheelRight & LButton -
02. WheelRight & RButton -
03. WheelRight & WheelUp -
04. WheelRight & WheelDown -
05. WheelRight & SButton -
06. WheelRight & ThumbUp -
07. WheelRight & ThumbDown -
08. WheelRight & ThumbWheelUp -
09. WheelRight & ThumbWheelDown -
10. WheelRight & ThumbWheelPush -

ThumbUp Modifiers:
01. ThumbUp & LButton - Move Cursor Left
02. ThumbUp & RButton - Move Cursor Right
03. ThumbUp & WheelUp - Move Cursor Up
04. ThumbUp & WheelDown - Move Cursor Down
05. ThumbUp & WheelLeft - Backspace
06. ThumbUp & WheelRight - Delete
07. ThumbUp & SButton - Move Active Window to Tray
08. ThumbUp & ThumbDown - Cut

ThumbDown Modifiers:
01. ThumbDown & LButton - Window Minimize
02. ThumbDown & RButton - Window Maximize
03. ThumbDown & WheelUp - Transparency On
04. ThumbDown & WheelDown - Transparency Off
05. ThumbDown & WheelLeft - Tile/Untile Windows Vertically
06. ThumbDown & WheelRight - Tile/Untile Windows Horizontally
07. ThumbDown & SButton - Toggle Shading of Active Window
08. ThumbDown & ThumbUp - Show Desktop

ThumbWheelUp Modifiers:
01. ThumbWheelUp & LButton - Resize Window Up
02. ThumbWheelUp & RButton - Hold Shift Down
03. ThumbWheelUp & WheelUp - Master Volume Up
04. ThumbWheelUp & WheelDown - Master Volume Down
05. ThumbWheelUp & WheelLeft - Show Desktop Selection Menu
06. ThumbWheelUp & WheelRight - Show "To Desktop" Selection Menu
07. ThumbWheelUp & SButton - Hide Active Window

ThumbWheelDown Modifiers:
01. ThumbWheelDown & LButton - Resize Window Down
02. ThumbWheelDown & RButton - Hold Control Down
03. ThumbWheelDown & WheelUp - Wave Volume Up
04. ThumbWheelDown & WheelDown - Wave Volume Down
05. ThumbWheelDown & WheelLeft - Toggle Master Mute
06. ThumbWheelDown & WheelRight - Toggle Wave Mute
07. ThumbWheelDown & SButton - UnHide Previous Hidden Window

ThumbWheelPush Modifiers:
01. ThumbWheelPush & LButton - Open File in Notepad
02. ThumbWheelPush & RButton -
03. ThumbWheelPush & WheelUp - ShiftAltTab
04. ThumbWheelPush & WheelDown - AltTab
05. ThumbWheelPush & WheelLeft -
06. ThumbWheelPush & WheelRight -
07. ThumbWheelPush & SButton - Show Clipboard Menu Selection
08. ThumbWheelPush & ThumbWheelUp -
09. ThumbWheelPush & ThumbWheelDown -

Total: 60 out of 90 Hotkeys with MX Revolution


Here is the main script:
Code:

#NoTrayIcon
#SingleInstance force
#MaxHotkeysPerInterval 500
#WinActivateForce

; Multiple Desktop Initialization
SetWinDelay, -1
SetBatchLines, -1   ; maximize script speed!

numDesktops := 4
curDesktop := 1
k := curDesktop

; Clipboard and Hidden Windows Initialization
Number := 0
HiddenWins := 0
Menu, Tray, UseErrorLevel, On

; Procedure before exiting the script
OnExit, CleanUp

return ; End of Auto-Start

; Before exit show all hidden Windows
CleanUp:
    ShowAllDesktops()
    GoSub, UnHideAll
    ExitApp
return

; TEMP Fix Slow Mouse Scroll Wheel
WheelUp:: MouseClick, WheelUp,,,
WheelDown:: MouseClick, WheelDown,,,

; Application only keys
; Change Tabs Forward/Backward and Close Current Tab
; If the Buttons are hold then we execute the normal behaviour
#ifWinActive, ahk_class MozillaUIWindowClass
RButton & F16:: Send ^+{Tab}
RButton & F17:: Send ^{Tab}
RButton & F13:: Send ^{F4}
RButton & F14:: Send ^{SC014} ; t
RButton & MButton:: Send ^+{SC014} ; T
RButton & LButton:: Send ^{F5}
RButton:: Send {RButton}
#ifWinActive, ahk_class IEFrame
RButton & F16:: Send ^+{Tab}
RButton & F17:: Send ^{Tab}
RButton & F13:: Send ^{F4}
RButton & F14:: Send ^{SC014} ; t
RButton & MButton:: Send ^+{SC014} ; T
RButton & LButton:: Send ^{F5}
RButton:: Send {RButton}
#ifWinActive

; Browser Back/Forward
; If the button is hold scroll horizontally
F14:: Send !{Left}
F15:: Send !{Right}

; Close Active Window
F13:: WinClose, A

; AltTab
F13 & WheelUp:: ShiftAltTab
F13 & WheelDown:: AltTab

; Click and open file with Notepad
F13 & LButton::
    MouseClick, L
    Lock := 1
    Sleep 100
    Send ^{Insert}
    Sleep 100

    Run, % "Notepad " Clipboard
return

; Show Clip History Menu
F13 & MButton:: ClipMenu()

; Maximize, Minimize or restore Active Window
F19 & RButton:: MinMaxWindow(1)
F19 & LButton:: MinMaxWindow(-1)

; Minimize/Maximize Function
MinMaxWindow(State)
{
    WinGet, output, MinMax, A
    if(output = 1)
    {
        if(State = 1)
            PostMessage, 0x112, 0xF120,,, A ; restore
        else if(State = -1)
            PostMessage, 0x112, 0xF020,,, A ; minimize
    }
    else if(output = -1)
    {
        if(State = 1)
            PostMessage, 0x112, 0xF030,,, A ; maximize
        else if(State = -1)
            PostMessage, 0x112, 0xF120,,, A ; restore
    }
    else if(output = 0)
    {
        if(State = 1)
            PostMessage, 0x112, 0xF030,,, A ; maximize
        else if(State = -1)
            PostMessage, 0x112, 0xF020,,, A ; minimize
    }
}

; Show Desktop
F19 & F18:: Send #{SC020} ; D

; Minimize to tray
F18 & MButton::
    WinGet, WinID, ID, A
    WinGetClass, WinClass, A

    ; Don't minimize special windows
    if(WinID = "" || WinClass = "Progman" || WinClass = "Shell_TrayWnd" || WinClass = "WorkerW" || WinClass = "MsgrIMEWindowClass")
        return

    Run, AutoHotkey.exe SendToTray.ahk %WinID%
return

; Tile/Untile Windows Vertically
F19 & F14::
    if(!UnVTile)
    {
        WinGet, WinID, ID, A
        Send #b
        Send {AppsKey}
        Send {SC012} ; e
        WinActivate, ahk_id %WinID%
        UnVTile := 1
    }
    else
    {
        WinGet, WinID, ID, A
        Send #b
        Send {AppsKey}
        Send {SC016} ; u
        WinActivate, ahk_id %WinID%
        UnVTile := 0
    }
return

; Tile/Untile Windows Horizontally
F19 & F15::
    if(!UnHTile)
    {
        WinGet, WinID, ID, A
        Send #b
        Send {AppsKey}
        Send {SC023} ; h
        WinActivate, ahk_id %WinID%
        UnHTile := 1
    }
    else
    {
        WinGet, WinID, ID, A
        Send #b
        Send {AppsKey}
        Send {SC016} ; u
        WinActivate, ahk_id %WinID%
        UnHTile := 0
    }
return

; Set Transparency of Windows
F19 & WheelUp:: SetTransparency(10)
F19 & WheelDown:: SetTransparency(-10)

SetTransparency(Alpha)
{
    WinGet, WinID, ID, A
    WinGetClass, WinClass, A
    WinGet, Trans, Transparent, ahk_id %WinID%

    ; Don't make Transparent those special Windows
    if(WinID = "" || WinClass = "Progman" || WinClass = "Shell_TrayWnd" || WinClass = "WorkerW" || WinClass = "MsgrIMEWindowClass")
        return

    ; Set Transparency On
    if(Trans = "")
        Trans := 250

    ; Set Transparency Level
    Trans := Trans + Alpha
    if(Trans < 30)
        Trans := 30

    if(Trans >= 255)
        Trans := "Off"

    ToolTip, % "Transparency: " Trans
    SetTimer, ReSetToolTip, 1000
    WinSet, Transparent, %Trans%, ahk_id %WinID%
}

; Clear the ToolTip
ReSetToolTip:
    ToolTip
    SetTimer, ReSetToolTip, Off
return

; Toggle Shading of Active Window
F19 & MButton::
    WinGet, WinID, ID, A

    if(shade%WinID%)
    {
        WinMove, A,, tx%WinID%, ty%WinID%, Width%WinID%, Height%WinID%

        ; Release Memory
        shade%WinID% := ""
        tx%WinID% := ""
        ty%WinID% := ""
        Width%WinID% := ""
        Height%WinID% := ""
    }
    else
    {
        marginY := ""
        shade%WinID% := 1
        WinGetPos, tx%WinID%, ty%WinID%, Width%WinID%, Height%WinID%, ahk_id %WinID%
        tytemp := ty%WinID%
        txtemp := tx%WinID%

        ; Make sure that windows won't overlap after being shaded
        WinGet, WinIDs, List,,, Program Manager
ReRun:
        ReRun := 0
        Loop, %WinIDs%
        {
            ThisID := WinIDs%A_Index%
            if(WinID = ThisID)
                continue

            WinGetPos, tx, ty,,, ahk_id %ThisID%
            if(Abs(ty - tytemp) < 35 && Abs(tx - txtemp) < 350)
            {
                marginY := ty + 35
                tytemp := marginY
                ReRun := 1
            }
        }

        if(ReRun)
            GoTo, ReRun

        if(Width%WinID% >= 350)
            WinMove, A,,, marginY, 350, 24
        else
            WinMove, A,,, marginY, Width%WinID%, 24
    }
return

; Cut/Copy/Paste
F18 & F19:: Send ^{sc02D} ; X
F18:: Send ^{sc02E} ; C
F19:: Send ^{sc02F} ; V

; Move Cursor Left
F18 & LButton::
    Loop
    {
        GetKeyState, state, LButton, P
        if(state = "U")
            break
        Send {Left}
        Sleep 50
    }
return

; Move Cursor Right
F18 & RButton::
    Loop
    {
        GetKeyState, state, RButton, P
        if(state = "U")
            break
        Send {Right}
        Sleep 50
    }
return

; Backspace/Delete
F18 & F14:: Send {Backspace}
F18 & F15:: Send {Delete}

; Move the cursor left and right
F18 & WheelUp:: Send {Up}
F18 & WheelDown:: Send {Down}

; Select all/Undo/Redo
MButton & F13:: Send ^{sc01E} ; A
MButton & F16:: Send ^{sc02C} ; Z
MButton & F17:: Send ^{sc015} ; Y

; Enter/Escape
MButton & LBUtton:: Send {Enter}
MButton & RButton:: Send {Escape}

; Clipboard
; Change Clipboard Variable
MButton & F18:: ClipChange(-1)
MButton & F19:: ClipChange(1)

; Change Clipboard function
ClipChange(Direction)
{
    global Clip1, Clip2, Clip3, Clip4, Clip5
    global Clip6, Clip7, Clip8, Clip9, Clip10
    global Number, Lock
    i := 0

    Loop, 10
    {
        i++
        Number := Number + Direction
        if(Number > 10)
            Number := 1
        else if(Number < 1)
            Number := 10
        if(Clip%Number%)
            break
    }

    if(i = 10)
    {
        Number := 0
        return
    }

    Lock := 1
    Clipboard := Clip%Number%
    StringLeft, i, Clip%Number%, 15

    if(StrLen(Clip%Number%) > 15)
        StringRight, k, Clip%Number%, 15

    ToolTip, % Number ") " i k
    SetTimer, ReSetToolTip, 1000
}

; Clipboard History Menu Selection
ClipMenu()
{
    global Clip1, Clip2, Clip3, Clip4, Clip5
    global Clip6, Clip7, Clip8, Clip9, Clip10

    Loop, 10
    {
        StringLeft, i, Clip%A_Index%, 25
        Menu, ClipMenu, Add, % A_Index ") " i, ShowClipMenu
    }

    Menu, ClipMenu, Show
    Menu, ClipMenu, DeleteAll
}

; Clip Menu Procedure
ShowClipMenu:
    Lock := 1
    Clipboard := Clip%A_ThisMenuItemPos%
return

; Clipboard Management
OnClipboardChange:
    if(Lock = 0)
    {
        Number++
        if(Number > 10)
            Number := 1
        Clip%Number% := Clipboard
    }
    else
        Lock := 0
return

; ScrollWindows Forward/Backward
F17:: ScrollTaskButton(1)
F16:: ScrollTaskButton(-1)

; Scroll Taskbar Buttons Function
ScrollTaskButton(Direction)
{
    ; Get IDs of all and current Task Buttons
    WinGet, WinID, ID, A
    AllButtons := TaskButtons()
    CurrentButton := TaskButtons(WinID)

    ; Parse the Task Button list
    Loop, Parse, AllButtons, `n
    {
        if(A_LoopField != "")
        {
            Button%A_Index% := A_LoopField "`n"
            ButtonsNum := A_Index
        }
    }

    ; Check where we are on the Button list
    Loop, % ButtonsNum
    {
        if(CurrentButton = Button%A_Index%)
        {
            NextPos := A_Index + Direction
            if(NextPos > ButtonsNum)
                NextPos := 1
            else if(NextPos < 1)
                NextPos := ButtonsNum
        }
    }

    if(NextPos = "" && Direction = 1)
        NextPos := 1
    else if(NextPos = "" && Direction = -1)
        NextPos := ButtonsNum

    ; Saperate the ID from the idx and activate the window
    StringMid, FinID, Button%NextPos%, InStr(Button%NextPos%, "|") + 1
    WinActivate, ahk_id %FinID%
}

; Hold Shift Key
F16 & RButton:: Send {Shift Down}
F16 & RButton Up:: Send {Shift UP}

; Hold Control Key
F17 & RBUtton:: Send {Control Down}
F17 & RBUtton Up:: Send {Control Up}

; Master Volume Up/Down
F16 & WheelUp::
    SoundSet +5
    SoundGet, Volume
    ToolTip, % "Master Volume: " Round(Volume)
    SetTimer, ResetToolTip, 1000
return
F16 & WheelDown::
    SoundSet -5
    SoundGet, Volume
    ToolTip, % "Master Volume: " Round(Volume)
    SetTimer, ResetToolTip, 1000
return

; Wave Volume Up/Down
F17 & WheelUp::
    SoundSet +5, Wave
    SoundGet, Volume, Wave
    ToolTip, % "Wave Volume: " Round(Volume)
    SetTimer, ResetToolTip, 1000
return

F17 & WheelDown::
    SoundSet -5, Wave
    SoundGet, Volume, Wave
    ToolTip, % "Wave Volume: " Round(Volume)
    SetTimer, ResetToolTip, 1000
return

; Toggle Master & Wave Mute
F17 & F14::
    SoundSet, +1,, Mute
    SoundGet, Volume,, Mute
    ToolTip, % "Master Mute: " Volume
    SetTimer, ResetToolTip, 1000
return
F17 & F15::
    SoundSet, +1, Wave, Mute
    SoundGet, Volume, Wave, Mute
    ToolTip, % "Master Mute: " Volume
    SetTimer, ResetToolTip, 1000
return

; Resize Window Up
F16 & LButton::
    if(GetKeyState("RButton", "P") = 0)
        Loop
        {
            GetKeyState, state, LButton, P
            if(state = "U")
                break
            WinGetPos, tx, ty, Width, Height, A

            ; Calculate Width to avoid exceeding the screen
            if((tx + Width + 25) > A_ScreenWidth)
                if((tx - 25) <= 0)
                {
                    marginX := A_ScreenWidth
                    posX := 0
                }
                else
                {
                    marginX := Width +25
                    posX := tx - 25
                }
            else
            {
                marginX := Width + 25
                posX := tx
            }
            ; Calculate Height to avoid exceeding the screen
            if((ty + Height + 25) > A_ScreenHeight - 30)
                if((ty - 25) <= 0)
                {
                    marginY := A_ScreenHeight - 30
                    posY := 0
                }
                else
                {
                    marginY := Height + 25
                    posY := ty - 25
                }
            else
            {
                marginY := Height + 25
                posY := ty
            }

            WinMove, A,, posX, posY, marginX, marginY
            Sleep 50
        }
    else
        MouseClick
return

; Resize Window Down
F17 & LButton::
    if(GetKeyState("RButton", "P") = 0)
        Loop
        {
            GetKeyState, state, LButton, P
            if(state = "U")
                break
            WinGetPos, tx, ty, Width, Height, A
            WinMove, A,,,, Width - 25, Height - 25
            Sleep 50
        }
    else
        MouseClick
return

; Choose and Send to Specific Desktop
F16 & F15:: ChooseSendDesktop("To ")
F16 & F14:: ChooseSendDesktop("")

; Menu to choose Destkop
ChooseSendDesktop(Prefix = "")
{
    global numDesktops

    Loop, % numDesktops
        Menu, ChooseSendDesktop, Add, % Prefix "Desktop: " A_Index, ShowDesktopMenu

    Menu, ChooseSendDesktop, Show
    Menu, ChooseSendDesktop, DeleteAll
}

; Show the chosen Desktop
ShowDesktopMenu:
    if(InStr(A_ThisMenuItem, "To "))
        SendActiveToDesktop(A_ThisMenuItemPos)
    else
        SwitchToDesktop(A_ThisMenuItemPos)
return

; Function to Send to Specific Desktop
SendDesktop(Direction)
{
    global k, NumDesktops

    k := k + Direction
    if(k < 1)
        k := NumDesktops
    else if(k > NumDesktops)
        k := 1

    ToolTip, % "To Desktop: " k
    SetTimer, ReSetToolTip, 1000
    SetTimer, SendDesktop, 1000
}

; Run this after Showing the Desktop Banner
SendDesktop:
    SendActiveToDesktop(k)
    if(k = 1)
        k := NumDesktops
    else
        K--
    SetTimer, SendDesktop, Off
return

; UnHide previously Hidden Window
F17 & MButton::
    if(HiddenWins <= 0)
        return

    DetectHiddenWindows, On
    WinGetTitle, WinTitle, % "ahk_id" All%HiddenWins%
    DetectHiddenWindows, Off

    WinShow, % "ahk_id" All%HiddenWins%
    WinActivate, % "ahk_id" All%HiddenWins%

    MenuTitle := WinTitle " - " temp

    HiddenWins--
    if(HiddenWins = 0)
    {
        Menu, ShowMenu, DeleteAll
        Menu, Tray, Delete, UnHide All
        Menu, Tray, Delete, UnHide Windows
    }
    else
        Menu, ShowMenu, Delete, %MenuTitle%
return

; Hide Active Window
F16 & MButton::
    WinGet, WinID, ID, A
    WinGetClass, WinClass, A
    WinGetTitle, WinTitle, A

    ; Don't make Transparent those special Windows
    if(WinID = "" || WinClass = "Progman" || WinClass = "Shell_TrayWnd" || WinClass = "WorkerW" || WinClass = "MsgrIMEWindowClass")
        return

    HiddenWins++
    All%HiddenWins% := WinID

    if(HiddenWins = 1)
        Menu, Tray, Add, UnHide All, UnHideAll

    Menu, ShowMenu, Add, % WinTitle " - " WinID, ShowWin
    Menu, Tray, Add, UnHide Windows, :ShowMenu

    ; Activate another window and hide the current
    WinGet, IDList, List
    WinHide, ahk_id %WinID%
    WinActivate, % "ahk_id" IDList3
return

; Menu for Showing Hidden windows
ShowWin:
    StringMid, temp, A_ThisMenuItem, InStr(A_ThisMenuItem, "0x")
    WinShow, ahk_id %temp%
    WinActivate, ahk_id %temp%

    HiddenWins--
    if(HiddenWins = 0)
    {
        Menu, ShowMenu, DeleteAll
        Menu, Tray, Delete, UnHide All
        Menu, Tray, Delete, UnHide Windows
    }
    else
        Menu, ShowMenu, Delete, %A_ThisMenuItem%
return

; UnHide all Hidden Windows
UnHideAll:
    Loop, %HiddenWins%
        WinShow, % "ahk_id" All%A_Index%

    WinActivate, % "ahk_id" All%HiddenWins%

    HiddenWins := 0
    Menu, ShowMenu, DeleteAll
    Menu, Tray, Delete, UnHide All
    Menu, Tray, Delete, UnHide Windows
return

MButton:: Send {MButton}

SwitchToDesktop(ToDesktop)
{
    global Desktop1, Desktop2, Desktop3, Desktop4
    global Active1, Active2, Active3, Active4
    global curDesktop

    ; Don't run if Target is the same
    if(curDesktop = ToDesktop)
        return
       
    ; Get IDs of all Task Buttons and TaskButtonless Windows
    Desktop%curDesktop% := TaskButtons()
    WinGet, WinIDs, List,, Program Manager
   
    ; Store the Active Window
    WinGet, Active%curDesktop%, ID, A
   
    ; Add Windows without Task Button to Desktop
    Loop, % WinIDs
    {
        Found := 0
        i := A_Index
        WinGetClass, WinClass, % "ahk_id" WinIDs%i%
       
        Loop, Parse, Desktop%curDesktop%
        {
            ; Saperate the ID from the idx
            StringMid, FinID, A_LoopField, InStr(A_LoopField, "|") + 1
           
            if(WinIDs%i% = "" || WinClass = "Progman" || WinClass = "Shell_TrayWnd" || WinClass = "WorkerW" || WinClass = "MsgrIMEWindowClass" || WinIDs%i% = FinID)
            {
                Found := 1
                break
            }
            else
                Found := 0
        }
       
        if(Found = 0)
            Desktop%curDesktop% := Desktop%curDesktop% "idx:x|" WinIDs%i% "`n"
    }
   
    ; Parse the Task Button list, Hide all Task Buttons
    Loop, Parse, Desktop%curDesktop%, `n
    {
        if(A_LoopField != "")
        {
            ; Saperate the ID from the idx and hide each window
            StringMid, FinID, A_LoopField, InStr(A_LoopField, "|") + 1
            WinHide, ahk_id %FinID%
        }
    }
   
    ; Show all Task Buttons of the new Desktop
    Loop, Parse, Desktop%ToDesktop%, `n
    {
        if(A_LoopField != "")
        {           
            ; Saperate the ID from the idx and hide each window
            StringMid, FinID, A_LoopField, InStr(A_LoopField, "|") + 1
            WinShow, ahk_id %FinID%
        }
    }
   
    ; Activate the active window of the new Desktop else show the Desktop
    WinGetClass, Class, % "ahk_id" Active%ToDesktop%
    if(Class)
        WinActivate, % "ahk_id" Active%ToDesktop%
    else
        Send #{SC020} ; D
   
    curDesktop := ToDesktop
    ToolTip, % "Desktop: " ToDesktop
    SetTimer, ReSetToolTip, 1000
}

SendActiveToDesktop(ToDesktop)
{
    global Desktop1, Desktop2, Desktop3, Desktop4
    global curDesktop
   
    ; Don't run if Target is the same
    if(curDesktop = ToDesktop)
        return

    ; Get Active Window details
    WinGet, WinID, ID, A
    WinGetClass, WinClass, A
   
    ; Don't move those special Windows
    if(WinID = "" || WinClass = "Progman" || WinClass = "Shell_TrayWnd" || WinClass = "WorkerW" || WinClass = "MsgrIMEWindowClass")
        return

    ; Hide and send to new Desktop the Active Window
    WinGet, IDList, List
    WinHide, ahk_id %WinID%
    WinActivate, % "ahk_id" IDList3
    Desktop%ToDesktop% := Desktop%ToDesktop% "idx:x|" WinID "`n"
}

ShowAllDesktops()
{
    global Desktop1, Desktop2, Desktop3, Desktop4
    global Active1, Active2, Active3, Active4
    global curDesktop, numDesktops
   
    Loop, % numDesktops
        if(curDesktop != Desktop%A_Index%)
        {
            Loop, Parse, Desktop%A_Index%, `n
            {
                if(A_LoopField != "")
                {           
                    ; Saperate the ID from the idx and hide each window
                    StringMid, FinID, A_LoopField, InStr(A_LoopField, "|") + 1
                    WinShow, ahk_id %FinID%
                }
            }
           
            Desktop%A_Index% := ""
            Active%A_Index% := ""
        }
       
    ; Reset curDesktop
    curDesktop := 1
}

DetectHiddenWindows, On

TaskButtons(sExeName = "")
{
   idxTB := GetTaskSwBar()
   WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd

   hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
   pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)

   VarSetCapacity(btn, 20)
   VarSetCapacity(sTooltip, 128)
   VarSetCapacity(wTooltip, 128 * 2)

   SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_BUTTONCOUNT

   Loop, %ErrorLevel%
   {
      SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETBUTTON

      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)

      iBitmap   := NumGet(btn, 0)
      idn   := NumGet(btn, 4)
      Statyle := NumGet(btn, 8)
      dwData   := NumGet(btn,12)
      iString   := NumGet(btn,16)

      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "UintP", hWnd, "Uint", 4, "Uint", 0)

      If   !hWnd
         Continue

      WinGet, pid, PID,              ahk_id %hWnd%
      WinGet, sProcess, ProcessName, ahk_id %hWnd%
      WinGetClass, sClass,           ahk_id %hWnd%

      If !sExeName || (sExeName = sProcess) || (sExeName = pid) || (sExeName = hwnd)
      {
         DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128 * 2, "Uint", 0)
         DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
         ;sTaskButtons .= "idx: " . A_Index - 1 . " | idn: " . idn . " | pid: " . pid . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . "   | Tooltip: " . sTooltip . "`n"
         sTaskButtons .= A_Index - 1 "|" hwnd "`n"
      }
   }

   DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
   DllCall("CloseHandle", "Uint", hProc)

   Return   sTaskButtons
}

HideButton(idn, bHide = True)
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x404, idn, bHide, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_HIDEBUTTON
}

DeleteButton(idx)
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x416, idx, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_DELETEBUTTON
}

MoveButton(idxOld, idxNew)
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd    ; TB_MOVEBUTTON
}

GetTaskSwBar()
{
   WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
   RegExMatch(ControlList, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)", nTB)

   Loop, %nTB%
   {
      ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
      hParent := DllCall("GetParent", "Uint", hWnd)
      WinGetClass, sClass, ahk_id %hParent%
      If (sClass <> "MSTaskSwWClass")
         Continue
      idxTB := A_Index
         Break
   }

   Return   idxTB
}

GetHotItem()
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETHOTITEM
   Return ErrorLevel << 32 >> 32
}


And if you want to use the hotkey to minimize windows on tray, then change the path of the F18 & SButton hotkey to the location that you will copy the following script:

Code:

; Auto Execute Section
#Persistent
#NoTrayIcon
#SingleInstance Off
#WinActivateForce

WinID = %1%
WinGetTitle, WinTitle, ahk_id %WinID%
WinGet, WinPID, PID, ahk_id %WinID%

; Activate another window and hide the current
WinGet, IDList, List
WinHide, ahk_id %WinID%
WinActivate, % "ahk_id" IDList3

; Set the Tray Menu
WinIcon := GetModuleFileNameEx(WinPID)
Menu, Tray, UseErrorLevel, On
if(InStr(WinIcon, "explorer.exe"))
    Menu, Tray, Icon, Shell32.dll, 4
else
    Menu, Tray, Icon, %WinIcon%, 1
   
Menu, Tray, Icon
Menu, Tray, NoStandard
Menu, Tray, Add, % "Show " WinTitle, ShowWin
Menu, Tray, Default, % "Show " WinTitle
Menu, Tray, Tip, % WinTitle
Menu, Tray, Click, 1
return
   
ShowWin:
    DetectHiddenWindows, On
    WinShow, ahk_id %WinID%
    WinActivate, ahk_id%WinID%
    ExitApp
return

GetModuleFileNameEx( p_pid )
{
   if A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
      MsgBox, This Windows version (%A_OSVersion%) is not supported.
      return
   }

   h_process := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", p_pid )
   if ( ErrorLevel or h_process = 0 )
      return
   
   name_size = 255
   VarSetCapacity( name, name_size )
   
   result := DllCall( "psapi.dll\GetModuleFileNameExA", "uint", h_process, "uint", 0, "str", name, "uint", name_size )
   
   DllCall( "CloseHandle", h_process )
   
   return, name
}

_________________
One hotkey to rule them all!


Last edited by XavierGr on Thu Jan 10, 2008 2:21 am; edited 3 times in total
Back to top
View user's profile Send private message
sam.reckoner



Joined: 11 Oct 2007
Posts: 10

PostPosted: Thu Nov 01, 2007 5:34 pm    Post subject: Reply with quote

Quote:
10. ThumbDown - F19
11. ThumbWheelUp - F16
12. ThumbWheelDown - F17
13. ThumbWheelPush - F13


where are you getting the above thumb actions from? From setpoint, uberoptions, or AHK?

I have a VX revolution, so maybe it's different.
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Thu Nov 01, 2007 7:51 pm    Post subject: Reply with quote

sam.reckoner wrote:
Quote:
10. ThumbDown - F19
11. ThumbWheelUp - F16
12. ThumbWheelDown - F17
13. ThumbWheelPush - F13


where are you getting the above thumb actions from? From setpoint, uberoptions, or AHK?

I have a VX revolution, so maybe it's different.


In my case UberOptions can let me configure those buttons from F13-F24, then from Autohotkey I make a shortcut for each one.

VX Revolution doesn't have a ThumbWheel, instead it has two zoom buttons next to LButton. I am not sure if you can configure those with UberOptions because I don't own a VX revolution mouse.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
lilljimpa



Joined: 18 Apr 2007
Posts: 80

PostPosted: Fri Dec 14, 2007 11:42 am    Post subject: Reply with quote

...dont you have like a old script for mx1000 laser mouse

i have that one, and your script realy make me won´t buy the new one Sad
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Fri Dec 14, 2007 4:29 pm    Post subject: Reply with quote

lilljimpa wrote:
...dont you have like a old script for mx1000 laser mouse

i have that one, and your script realy make me won´t buy the new one Sad


You mean that you want to buy an MX Revolution cause of my script? Smile

Anyway, this script is rather old (and sometimes buggy). I discovered that using the proper uberoptions (and editing user.xml) you can make all the buttons to have an up/down event. That means that the modifier keys are now 9 and you can have a total of 90 Shocked Exclamation hotkeys in your palm!!

I will try to update it with more actions but I don't think that I will come up with 30 more actions to fill all those hotkeys.

As for the MX1000, I think that you could easily remove the unnecessary hotkeys that you don't want (and don't fit in the MX1000) and map those that you like in your script. I can't help you more on that because currently I don't have my MX1000.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
ronaldjeremy



Joined: 13 Dec 2007
Posts: 6

PostPosted: Wed Jan 09, 2008 11:09 pm    Post subject: Reply with quote

XavierGr wrote:
I will try to update it with more actions but I don't think that I will come up with 30 more actions to fill all those hotkeys.


Please do! Also, can you expand upon how you configured the up/down events in uberoptions?
_________________
Ronald Jeremy
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Thu Jan 10, 2008 2:02 am    Post subject: Reply with quote

I've updated my main post with the new script. There are some changes in the keys. Some features were removed while others were reordered. Read the keymap file for further details.

Also I've included a subscript that will minimize the active window to the tray when the user presses the corresponding hotkey.

To make all your keys to have up/down events use my user.xml file http://www.autohotkey.net/~XavierGr/user.xml. Copy it to "C:\Documents and Settings\Xavier\Application Data\Logitech\SetPoint" (Application Data is a hidden folder).
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group