Navigating the viewport with: your choice of hotkeys.


#1

[b](For Windows)

                  See [post #2](http://forums.cgsociety.org/showpost.php?p=7124428&postcount=2) for using the mouse scroll wheel to cycle through four views.
              
              See [post #10](http://forums.cgsociety.org/showpost.php?p=7142262&postcount=10) for many other ways to use AHK with Max or any program.
             
             [/b][b]Would you like to hold down "a" (or any key) and move the mouse to zoom or orbit?
                                                   (no clicking at all!)[/b]
        
             You can accomplish this by using a free program called [AutoHotkey](http://www.autohotkey.com/).
                                                   All you are going to have to do is, download it, install it,
                                                   and copy and paste the scripts I've already made for you;
                                                   which I'll show you how to easily modify, if you want to use another hotkey.
                                                   
                                                   Once you have AutoHotkey installed:
                                                   make a scripts folder,
                                                   or just right-click
                                                   in any folder, or on the desktop
                                                   and Goto:
                                                   New→ AutoHotkey Script
                                                   [img]http://img836.imageshack.us/img836/4849/ahk1b.jpg[/img]
                                                
                                                   Name it whatever you want;
                                                   then right-click it
                                                   choose "Edit Script"
                                                 [img]http://img88.imageshack.us/img88/1275/ahk2.jpg[/img]
                                                 
                                                   and then paste the script I have provided
                                                   below the text that is already in there.
                                                   Then save and you're done.
                                                   
                                                   [u][b]Script:[/b][/u]
                                                   
        Hold
                                                   [b][a] for zoom,
        [s] for orbit
        [space] for pan:[/b]
 #IfWinActive ahk_class 3DSMAX ; this script only works inside of Max
                                
          ; ==== Pause ====
          
                               pause::suspend ; press [pause] if you need the [a] or [s] key to type inside of max
                               
          ; ==== Zoom ====
          
                               a:: ; change the [a] hotkey if you want
         send, {ctrl downtemp}{alt downtemp}{mbutton down}
        keywait, a ; waits for [a] to be released -- if you change [a] above change it here too
         send, {mbutton up}{ctrl up}{alt up}
        return ; end hotkeys with this
                               
          ; ==== Orbit ====
          
                               s::
        send, {alt downtemp}{mbutton down}
        keywait, s
        send, {mbutton up}{alt up}
        return
                               
          ; ==== Pan ====
          
        space::
        send, {mbutton down}
        keywait, space
        send, {mbutton up}
        return
        
          ; ==== Exit ====
          
                               esc::exitapp ; [esc] closes the script... you can delete this line if you want.
       

(I don’t know what’s up with the random indentation the code tags produce…)

                       Because apparently some people prefer the zoom tool,
                       here's an alternative that uses the zoom tool but functions the same as above:
 a::
                send, !{z 1}{lbutton down} ; switches to the zoom tool and holds left mouse down
               keywait, a
               send, {lbutton up}{q} ; releases left mouse and switches to the select tool
                return
     
                [b]Advanced functionality:[/b]
                  Tap [a] once and it act's like a normal [a]
                  Hold [a] and it zooms
                  Double tap [a] and it is [ctrl]+b[b]
 a::
      keywait, a, t0.3 ; waits for [a] to be released
      if errorlevel
      {
      sendinput, {ctrl downtemp}{alt downtemp}{mbutton down}
      keywait, a
      sendinput, {mbutton up}{ctrl up}{alt up}
      return
      }
      keywait, a, d, t0.3 ; if [a] is pressed again in 0.3 seconds it sends [ctrl]+[b]
      if errorlevel ; otherwise it sends [a]
        send, a
      else
        send, ^b
      return
                      
                                                   [http://www.autohotkey.com/docs/Hotkeys.htm](http://www.autohotkey.com/docs/Hotkeys.htm)
                                                  [http://www.autohotkey.com/docs/KeyList.htm](http://www.autohotkey.com/docs/KeyList.htm)
                                                  [http://www.autohotkey.com/docs/commands/Send.htm](http://www.autohotkey.com/docs/commands/Send.htm)
                                                  
                                                  The first and second links have all the info for
                                                  what you might want to press;
                                                  and the third has what you will want the script to press.
                                                 
                                                 [u]To run the script:[/u][/b]
                                                 double click on it,
                                                 or a shortcut of it.
                                                 
                                                 [u][b]To suspend the script,
                                                 or end it:[/b][/u]
                                                 right-click the green square with the white H
                                                 in the bottom right (system tray).
                                                 
                                                 [img]http://img200.imageshack.us/img200/5716/ahk3.jpg[/img]
                                                 
                                                 [b]If you need to type inside of Max,[/b]
                                                 and make use of the 'a' and 's' keys,
                                                 you can just suspend it (pause button).
                                
                                                 I hope you enjoy this. ;-]

#2

Scroll up with the mouse wheel to cycle through four views and “zoom extents selected” each.
In max I have
“zoom extents selected” as [d]
“front view” as [ctrl] + [alt] + 1
“right view” as [ctrl] + [alt] + 2
“back view” as [ctrl] + [alt] + 3
“left view” as [ctrl] + [alt] + 4

wheelup:: ; use mouse wheel up
    TimesCalled++
    If (TimesCalled = 5) ; on the 5th use (wheel up notch) start again at the beginning
      TimesCalled:=1
    If (TimesCalled = 1) ; on the first use
    {  
    Send, ^!1 ; front view
      send, d ; zoom extents selected
    }
    Else If (TimesCalled = 2) ; on the second use
    { 
    Send, ^!2 ; right view
      send, d ; and so on...
    }
    Else If (TimesCalled = 3)
    {  
    Send, ^!3
      send, d
    }
    Else If (TimesCalled = 4)
    {  
    Send, ^!4
      send, d
    }
    return
This doesn't have to be for the mouse wheel,
it could be for tapping any hotkey;
and it doesn't have to be four things,
it could be 2 or 7 or whatever.

Scroll down for top view.
The way this is written allows us to scroll down with the mouse wheel
and have it send [t]
but also allows for us to hold modifier keys (shift, ctrl, alt)
and scroll down to simulate [shift] + [t]
which I use as perspective view.
It also includes my “zoom extents selected”
the [d] key.

*wheeldown::
  send {blind}t
  send d
  return

#3

instead of

a::send {Ctrl down}{Alt down}{Mbutton down}
return
a up::send {Ctrl up}{Alt up}{Mbutton up}
return

you should use

a::^!MButton
which will evaluate faster because you're directly mapping the keys. I prefer doing this way with the commands where you keep holding your mouse button instead of clicking.

Here’s another tip.

!w::
Send, {MButton}
Send, !{w}
Return

When you’re maximizing your viewport you’ll no longer have to select the viewport first. Just hover your mouse on the viewport you want to maximize and click ctrl+w.


#4
The benefit of using send is that you can still use a hotkey like [alt + a]
which is part of MAX. Direct mapping doesn't allow [a] to be used again.

Have you tried your suggestion? It pans instead of zooming.

#5
          Very useful.
     
          Preferring Maya's hotkey: 
        I first set "Maximize Viewport Toggle" to spacebar in max,
          then modified the script.

             space::
              send {mbutton}{space}
              return

Update:
I’m now using space as pan (photoshop / illustrator carry over)
and hotkeys to switch views instead of minimizing to the four views.

Also, for the sake of information,
there is a Max script that auto selects a view that you move the mouse to,
if you like minimizing and using the four views.
http://www.scriptspot.com/3ds-max/scripts/autovp-mouseover-viewport-switcher


#6

Thanks for the pointer to AutoHotkey. It is most useful, and I especially like the ability to confine the changes to a single App (3DS Max).

I prefer to stick to my old habits, the Maya ALT+ mousebuttons, since that is what I have Maya and Mudbox set to. I got two out of three right, mapping ALT+LMB to orbit and ALT+RMB to zoom. ALT+MMB still does orbit, because I haven’t figured out how to trap the ALT, maybe you can’t. But if you let the ALT key go, it drops to pan mode immediately.

I won’t repeat all the stuff about starting with AutoHotkey, or the link, see Honest Abe’s posts above for that. But here is the part of the script I made, paste it at the bottom of the default script:


 ; for 3DS
 #IfWinActive ahk_class 3DSMAX
 !LButton::
 SendInput, {MButton Down}
 KeyWait, LButton
 SendInput, {MButton Up}
 return
 !RButton::
 SendInput, {Alt Down}{Ctrl Down}{MButton Down}
 KeyWait, RButton
 SendInput, {Ctrl Up}{Alt Up}{MButton Up}
 return
 

<* Wes *>


#7

Hey Wes,

 I'm happy to see you have found the joy of AHK.
 
 When I originally posted this topic
 it included those Maya hotkeys.
 It's actually what I first wanted to accomplish.
 
 The reason I remove them from this topic is that
 alt + click is the deselect in Max,
 as I'm sure you know.
 
 Of course this isn't a problem if you setup another hotkey,
 to deselect, with AHK.
 For example:
xbutton1::
     send !{lbutton}
     return
or
xbutton1::
      sendinput, {alt down}{lbutton down}
      keywait, xbutton1
      sendinput, {lbutton up}{alt up}
      return
 As a whimsical aside:
 have you noticed that if you release
 left click first: it cancels orbit as you would expect
 but if you release alt first:
 it switches to pan?
 Could be useful ;-]
 
 I could not get the alt+mbutton pan working either,
 the closest I came was a crazy pan and orbit at the same time hybrid LOL.
 I thought maybe #usehook or $ at the beginning might help,
 but no luck.
 
 Assume anything is possible with AHK,
 and seriously take advantage of the AHK forums.

#8

Thanks for the tip on deselect. No, I am not that proficient in 3DS Max… yet. In the past I have managed to set most things I use up to navigate Maya-style, and I missed that on Max. For me, I would trade other inconveniences for being able to navigate without thinking, letting muscle memory take over.

I got all three buttons working with ALT, and it seems to perform well enough… as you noted, releasing the ALT key in the middle of the process switches from orbit or zoom to pan, but I am happy for the moment, because that is not a habit I will need to break.

Here is the three-button solution (takes advantage of Ctrl-p left being mapped by default to pan):

; for 3DS
 #IfWinActive ahk_class 3DSMAX
 ; makes ALT+LMB perform orbit (native 3DS ALT+MMB)
 !LButton::
 SendInput, {MButton Down}
 KeyWait, LButton
 SendInput, {MButton Up}
 return
 ; makes ALT+RMB perform zoom (native 3DS CTL+ALT+MMB)
 !RButton::
 SendInput, {Alt Down}{Ctrl Down}{MButton Down}
 KeyWait, RButton
 SendInput, {Ctrl Up}{Alt Up}{MButton Up}
 return
 ; make ALT+MMB perform pan (Native 3DS MMB, uses CTL-P definition)
 !MButton::
 SendInput {Ctrl Down}{p Down}{LButton Down}
 KeyWait, MButton
 SendInput, {Ctrl Up}{p Up}{LButton Up}
 SendInput, {MButton Up}
 SendInput, {RButton Down}	;sent to clear the lagging hand cursor
 SendInput, {RButton Up}
 return

Tested on Max 2012 and Windows 7 (both 64-bit).

<* Wes *>


#9

I’m glad to see you got it to work.

You could cut out two lines if you wanted to:

 !mbutton::
   sendinput, {ctrl downtemp}{p down}{lbutton down}
   keywait, mbutton
   sendinput, {ctrl up}{p up}{lbutton up}
   sendinput, {rbutton}
   return

I’m always looking for a way to simplify ;-]
and in fact you might have helped me do that.

$a::
  sendinput, {ctrl downtemp}{alt downtemp}{mbutton down}
  keywait, a
  sendinput, {ctrl up}{alt up}{mbutton up}
  return

So far no failed releases…
we will see how it holds up to testing. :-]

I noticed that your orbit isn’t engaging a lot.
I think this is because you are relying on the pressed alt;
rather than, including it with the sendinput.

Adding it with the sendinput seems to prevent that from happening:

 !LButton::
   SendInput, {alt downtemp}{MButton Down}
   KeyWait, LButton
   SendInput, {alt up}{MButton Up}
   return

○ • ☼ • ○

Have you seen that AutoDesk certified driver 275.89 for the Quadro 4000 and Max2012?
I have not checked Maya and Mudbox.


#10

See the original post for a new advanced script,
that allows [a] to function differently depending on how you press it.
See the second post for a script to cycle views with the mouse scroll wheel.

 === ☼ ===
 
 There are so many useful possibilities with AHK,
 I wanted to share some more.
 
 You can make mouse menus:
          [link](http://www.autohotkey.com/forum/viewtopic.php?t=233&postdays=0&postorder=asc&start=0)
          Radial menus:
          [link](http://www.autohotkey.com/forum/viewtopic.php?t=50813)
 
          Mouse Gestures:
          [link](http://www.autohotkey.com/forum/viewtopic.php?t=25330&postdays=0&postorder=asc&highlight=using+keys+modifiers&start=105) (I use this one)
 [link2](http://www.autohotkey.com/forum/viewtopic.php?t=77271) (untested)
 [link3](http://www.autohotkey.com/forum/viewtopic.php?t=71666&highlight=mouse+gesture) (untested)
 
          Tap, double tap and/or hold keys for different results:
          [link](http://www.autohotkey.com/forum/topic16951.html)
          [link2](http://www.autohotkey.com/forum/viewtopic.php?t=8357&postdays=0&postorder=asc&highlight=double+click+fires+hotkey&start=0)

link3
link4 (triple tap)

 Other ways to have one key do different things depending on how many times you
 press it (like my mouse wheel cycling views script):
 [link](http://www.autohotkey.com/forum/viewtopic.php?t=32443) (all untested)
 [link2](http://www.autohotkey.com/forum/viewtopic.php?t=32692&highlight=different+press+sequence) (untested)

You can use any key like a modifier key (ctrl, alt, shift)
If you don't redefine the button you use as a modifier (like at the bottom of the example)
it will do nothing when pressed alone.
space & a::
    sendinput, {f12}
    return
    
    space::send {space} ; sends space upon release if nothing else is pressed
You can make use of the extra buttons on your mouse:
xbutton1::
       sendinput, {alt down}{lbutton down}
       keywait, xbutton1
       sendinput, {lbutton up}{alt up}
       return
You can make your mouse instantly move to any location 
(via coordinates found with the window spy) and click:
x::
     send {click 1605,105}
    sleep 100
    send {click 1728,165}
     return
That clicks the modify panel then opens the drop down list,
but I'm guessing the coordinates only work on a screen my size at 1920x1080.
I think a custom quad menu is really the way to go for modifiers anyhow.

I hope you've enjoyed stumbling onto the mother-load of hotkey magic.

#11

I like the idea of using autohotkey to optimize workflow.
Can you make MODO/LW style navigation? In my opinion it is the best for wacom, because you don’t have to use stylus side buttons.
It’s like this
Orbit - Alt+LMB
Zoom - Alt+Ctrl+LMB
Pan - Alt+Shift+LMB

I made Orbit and Zoom but got stuck with Pan. I searched forums and it seems that i’m not only one who have a problem with Alt+Shift+LMB combination in 3dsmax.
Can somebody help me?


#12

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.