PDA

View Full Version : Mouse Wheel Zoom via AHK, +defeating 's' key in Surf Editor



jeric_synergy
09-23-2014, 09:53 PM
(couldn't find the thread where erikals posted these, but they deserved a bump anyway...)

Is this olde news? I combined a couple of erikals' scripts to get two things:


Mousewheel Zoom in both Layout and Modeler (we didn't have that, right???)
defeating the 's' key in the Surface Ed and replacing it w/ 'q'

What I added was limiting the AHK effect to ONLY Layout and Modeler (or anything with "LightWave" in its title bar). That way the mousewheel didn't send a zillion commas to my word processor. I might add, with AHK, it was pretty much a doddle. Erikals did 99% of the work here.

Anyway, I can't recommend AHK enough: in many ways you can alter a host of program behaviors-- I haven't scratched the surface yet. My goal is to have hotkeys that set LWM Tool Falloff modes.


SetTitleMatchMode 2
#IfWinActive LightWave
; Zoom IN
; Default is "." "period" or CTRL+ALT+Mouse button (either left, right, or middle)
; in orthographic and perspective viewports

WheelUp:: ;When user scrolls mousewheel up,
Send {.} ;Send '.'
return


; Zoom OUT
; Default is "," "comma" or CTRL+ALT+mouse button (either left, right, or middle)
; in orthographic and perspective viewports

WheelDown:: ;when user scrolls mousewheel down,
Send {,} ;send ','
return

; remaps the "s" key so the Surface Editor doesn't save a preset: courtesy erikals.
; "q" now saves Surface preset

#IfWinActive Surface Editor
s::Alt
q::s

jeric_synergy
09-23-2014, 11:07 PM
A quick tuneup: I added the line:

#HotkeyInterval 4000
at line 002, to slow the speed of hotkey evaluation-- at the default 2000 I was getting error warnings of 'too many hotkey' event types. I actually prefer the slower evaluation as it seems to coordinate the zoom with the mousewheel action better. Win-win!

+++++
O.M.G.-- I get to MURDER that SAVE CONFIRM dialog!!!!! To death! Thank you AHK, I luvv yoooo. :heart:

jeric_synergy
09-24-2014, 11:55 PM
I changed:


#IfWinActive LightWave

to:
#IfWinActive NewTek LightWave

because otherwise the NewTek plugins page didn't scroll ('cuz it had 'Lightwave' in the title bar).

Ryan Roye
09-25-2014, 06:51 AM
When you start having AHK operate on a lot of programs, you're going to want to do something like this:

#include %A_ScriptDir%\AHK_Apps\ScriptName.ahk

Basically, instead of trying to make one gigantic script and trying to keep track of what does what, including scripts compartmentalizes your code. So, for each program, use #include and you'll keep your scripts neat and easily managable, it also makes troubleshooting easier as you can eliminate whole scripts temporarily to determine where coding errors lie.

erikals
09-25-2014, 08:20 AM
wonder if running many ahk scripts has any downsides, currently running 13 individual ones

so you have several Master scripts that calls up other scripts if i get it right ?



#IfWinActive LightWave to: #IfWinActive NewTek LightWave
yep, happened to me too http://erikalstad.com/backup/misc.php_files/smile.gif


Mousewheel Zoom in both Layout and Modeler (we didn't have that, right???)
defeating the 's' key in the Surface Ed and replacing it w/ 'q'
both Great additions!
Welcome to AHK jeric_synergy http://erikalstad.com/backup/misc.php_files/047.gif

btw, some ideas for falloff >
https://www.youtube.com/watch?v=OyTCjysl69Y

erikals
09-25-2014, 08:52 AM
seems i had to change from #IfWinActive LightWave to #IfWinActive Modeler
to get Zoom.ahk to work, but works great now http://erikalstad.com/backup/misc.php_files/smile.gif

youtube preview >
http://youtu.be/5WyWE8wbDak

Ryan Roye
09-25-2014, 09:50 AM
wonder if running many ahk scripts has any downsides, currently running 13 individual ones

Unless the scripts are constantly performing functions, or those functions involve things like scanning every pixel on the screen, the overhead is practically zero.

You may want to consolidate those scripts into a master script. Example; my master script has all of the code that I wish to work with every application, then at the end of the script I have this block of text:

#include %A_ScriptDir%\AHK_Apps\LWLayout.ahk
#include %A_ScriptDir%\AHK_Apps\LWModeler.ahk
#include %A_ScriptDir%\AHK_Apps\PaintShopPro.ahk
#include %A_ScriptDir%\AHK_Apps\Reaper.ahk
#include %A_ScriptDir%\AHK_Apps\SonyVegas.ahk
#include %A_ScriptDir%\AHK_Apps\WindowsExplorer.ahk
#include %A_ScriptDir%\AHK_Apps\WindowsFileChooser.ahk

This makes the script behave as if it contained all of the lines of code referenced by the includes.

erikals
09-25-2014, 09:52 AM
Nice! http://erikalstad.com/backup/misc.php_files/smile.gif

wonder, what is WindowsFileChooser for... ?

Ryan Roye
09-25-2014, 10:00 AM
Nice! http://erikalstad.com/backup/misc.php_files/smile.gif

wonder, what is WindowsFileChooser for... ?

F-key navigation. There are actually 2 types of windows explorer dialogues which is why I have windows explorer and file chooser as separate entries:

#IfWinActive ahk_class CabinetWClass <---- Standard windows explorer file browser (windows 7)

#IfWinActive ahk_class #32770 <---- Windows Save, Load, etc dialogues invoked by most programs including Lightwave (windows 7)

You'll need to look up the ahk class via windows spy for other versions of windows; XP differs from 7, and its likely 7 differs from 8.

jeric_synergy
09-25-2014, 10:30 AM
When you start having AHK operate on a lot of programs, you're going to want to do something like this:

#include %A_ScriptDir%\AHK_Apps\ScriptName.ahk
Wisdom. :bowdown: Thanks for the tip Chazriker-- that's no doubt why that function exists, which I had yet to encounter.

jeric_synergy
09-25-2014, 10:33 AM
seems i had to change from #IfWinActive LightWave to #IfWinActive Modeler
to get Zoom.ahk to work, but works great now http://erikalstad.com/backup/misc.php_files/smile.gif
Huh. At some point I changed it to : #IfWinActive NewTek LightWave
which works for both here.

Just using "Lightwave" also activated the script for browser tabs with "Lightwave" in their title, which is undesirable.

I gotta say, mousewheel zoom just feels SO organic.

erikals
09-25-2014, 10:55 AM
I gotta say, mousewheel zoom just feels SO organic.

i think many LightWavers will be grateful for this one http://erikalstad.com/backup/misc.php_files/smile.gif


F-key navigation.
ah,.! might look more into that http://erikalstad.com/emoti/matrix.gif

chippwalters
09-26-2014, 01:52 PM
Anyone know such a fix for Mac users?

spherical
09-26-2014, 05:30 PM
OK, so why isn't the script working? I've tried strings: "LightWave", "NewTek LightWave", "Modeler". Nada. Gotta be missing something really obvious.

I have changed the default editor to Notepad++. Got a way to store scripts NOT in \Documents? I want to keep unnecessary stuff off of the %SystemDrive% especially if it is an SSD.

We are using AHK at: ahkscript.org not autohotkey.com, yes?

jeric_synergy
09-26-2014, 05:48 PM
OK, so why isn't the script working? I've tried strings: "LightWave", "NewTek LightWave", "Modeler". Nada. Gotta be missing something really obvious.

I have changed the default editor to Notepad++. Got a way to store scripts NOT in \Documents? I want to keep unnecessary stuff off of the %SystemDrive% especially if it is an SSD.

We are using AHK at: ahkscript.org not autohotkey.com, yes?

Last: yes
My script is in STARTUP, so it's launched automagically. When you use "Edit This Script" by rclicking on the AHK icon, what script opens?
Did you alter the script at all? It's short-- repost it here. (Use the CODE tag.)
Obligatory "is the machine on" question: is AHK running?



+++
When I get around to it, I'll use Chazriker's "#include" tip, but right now I only have this one tiny script running, so not a problem.

spherical
09-26-2014, 06:16 PM
My script is in STARTUP, so it's launched automagically.

Doesn't make any difference, whether automatic at win-start or double-clicked to launch it. Additionally, when right-clicking the icon in the system tray, the script opens in the AHK window (with Press [F5] to refresh), so it's loaded.


When you use "Edit This Script" by rclicking on the AHK icon, what script opens?

That script.


Did you alter the script at all? It's short-- repost it here.

Whether as-posted or as-edited with your "4000" and "NewTek" changes, no difference.


Obligatory "is the machine on" question: is AHK running?

If the icon is in the system tray, it's running. Right-clicking and selecting Edit, launches Notepad++ (which is the default editor now), so yes, it's running.

erikals
09-26-2014, 06:20 PM
note, if changes are made, remember that you have to reloaded the script

spherical
09-26-2014, 06:23 PM
Doesn't make any difference. Reloaded, killed & reloaded. Changed order of launching the script and starting Modeler. Nada. Not even your original defeat "s" in Surface Editor script (which is the primary reason for doing this, BTW) has any influence. Tried changing to UNIX line endings as a debugging step. Nothin'.

jeric_synergy
09-26-2014, 06:46 PM
Do you have any other hotkey utilities running?

Please just post the script as you have it: perhaps a typo crept in somewhere along the road.

spherical
09-26-2014, 08:30 PM
Do you have any other hotkey utilities running?

No. First thing to think of when looking for a UI conflict.

[QUOTE=jeric_synergy;1401324]Please just post the script as you have it: perhaps a typo crept in somewhere along the road.

Not unless you and/or erikals put one in:


SetTitleMatchMode 2
#IfWinActive LightWave
; Zoom IN
; Default is "." "period" or CTRL+ALT+Mouse button (either left, right, or middle)
; in orthographic and perspective viewports

WheelUp:: ;When user scrolls mousewheel up,
Send {.} ;Send '.'
return


; Zoom OUT
; Default is "," "comma" or CTRL+ALT+mouse button (either left, right, or middle)
; in orthographic and perspective viewports

WheelDown:: ;when user scrolls mousewheel down,
Send {,} ;send ','
return

; remaps the "s" key so the Surface Editor doesn't save a preset: courtesy erikals.
; "q" now saves Surface preset

#IfWinActive Surface Editor
s::Alt
q::s

As I said, his first script to replace "s" with "q" also does nothing.

BTW, all of the posts that Search turns up from erikals show that www.autohotkey.com is the version he's been using. It's older and depreciated, according to what the devs on ahkscript.org say.

EDIT: New wrinkle that says that the script is running. Was searching for more hits on this in the forums and upon loading one, my wheel stopped scrolling the web page. In the current script I had changed the #IfWinActive line from LightWave to Modeler. The Firefox tab (HTML page title) was "Modeler rounder problem". The script trapped it and set the wheel to outputting "."s and ","s instead of scrolling the page in its normal way.

EDIT II: Found it. In Win 8.1, you have to set all of AHK's executables to: Properties > Compatibility > Run As Administrator.
Before, opening AHK's window showed the script only executing lines 001, 003.



001: SetTitleMatchMode,2
003: Return (3.63)


Now, it shows:



001: SetTitleMatchMode,2
003: Return (3.42)
008: Send,{,} (0.05)
008: Return (0.09)
008: Send,{,} (0.01)
008: Return (0.42)
003: Send,{.} (0.02)
003: Return (0.06)
003: Send,{.} (0.02)
003: Return (0.06)
003: Send,{.} (0.02)
003: Return (0.06)
003: Send,{.} (0.02)
003: Return (5.98)

erikals
09-26-2014, 09:45 PM
the code i tried was a bit shorter...


#IfWinActive Modeler
; Zoom IN
; Default is "." "period" or CTRL+ALT+Mouse button (either left, right, or middle)
; in orthographic and perspective viewports

WheelUp:: ;When user scrolls mousewheel up,
Send {.} ;Send '.'
return


; Zoom OUT
; Default is "," "comma" or CTRL+ALT+mouse button (either left, right, or middle)
; in orthographic and perspective viewports

WheelDown:: ;when user scrolls mousewheel down,
Send {,} ;send ','
return

just removing SetTitleMatchMode 2 and the bottom part of the script

spherical
09-26-2014, 10:07 PM
Mine's even shorter than that. Works great.



SetTitleMatchMode, 2
#IfWinActive NewTek LightWave
WheelUp:: Send, {.}
WheelDown:: Send, {,}


"Return" is superfluous. From the docs: This parameter should be omitted except when return is used inside a function.

erikals
09-27-2014, 10:23 AM
"Return" is superfluous. From the docs: This parameter should be omitted except when return is used inside a function.

ah, good to know... http://erikalstad.com/backup/misc.php_files/smile.gif

Ryan Roye
09-27-2014, 10:26 AM
This parameter should be omitted except when return is used inside a function.

In other words, always end a hotkey with "return", that's basically all people need to know as it stops AHK from reading any more lines in the script. Without the returns, the script will keep reading lines below where the hotkey was supposed to end.

jeric_synergy
09-27-2014, 11:03 AM
There're zero RETURNS in Spherical's script. :question:

If one is use a MASTER SCRIPT with a bunch of includes, does the Return terminate JUST the include script, and the master script moves on to the next? (I'm guessing "yes".)

If one were worried about performance, profiling the keys/functions used and putting the most often used near the front of the script with RETURNS would improve executing performance. OTOH, since 99% the entire script needs to be evaluated, this most likely doesn't matter, never mind, nothing to see here..... 8~

Ryan Roye
09-27-2014, 11:10 AM
There're zero RETURNS in Spherical's script. :question:

If one were worried about performance, profiling the keys/functions used and putting the most often used near the front of the script with RETURNS would improve executing performance. OTOH, since 99% the entire script needs to be evaluated, this most likely doesn't matter, never mind, nothing to see here..... 8~

1) Ah, Spherical's script sample is a one-line hotkey. This assumes a return... know that for multi-line hotkey functions return is absolutely necessary.

2) Executing performance is a moot point in all but the most extreme cases with AHK. This only becomes an issue if the script continuously operates. IE: You're constantly having the script record your screen at intervals, or you're scanning an area of the screen to look for something, or performing any operation that involves logic operations on large text files.

spherical
09-27-2014, 01:47 PM
To check the processing of commands, choose Open from the tray icon menu. You'll see where AHK is supplying its own "returns" as commands are executed. If you need to limit processing, and the command stream is showing you that it isn't stopping where it should (because you've created a function between {}s), add a "return" line where necessary, so that the function exits. It's just good programming practice. Tighten things up where necessary, but keep the code as lean as you can while doing so.

jboudreau
11-25-2014, 01:16 PM
Hi Guys

I was just playing around with AHK (Thanks guy for this, I had no idea it existed)


Here is a modified version of spherical code. It allows you not only to zoom in and out but it also allows you to pan around your viewports as well as rotate your model in perspective viewport


SetTitleMatchMode, 2
#IfWinActive NewTek LightWave
MButton::!MButton
WheelUp:: Send, {.}
WheelDown:: Send, {,}


This code below will allow the perspective viewport to pan instead of rotate so now all viewports can pan using the middle mouse button

SetTitleMatchMode, 2
#IfWinActive NewTek LightWave
MButton::+!MButton
WheelUp:: Send, {.}
WheelDown:: Send, {,}

Thanks
Jason

erikals
11-25-2014, 02:09 PM
think this is in LightWave 2015 now?...

jboudreau
11-25-2014, 02:16 PM
think this is in LightWave 2015 now?...

Nope unfortunately. They have wheel zoom but I guess they never though of panning.

The wheel zoom in 2015 is better than the AHK work around because it zooms in to where the pointer is as for panning you can't pan with the mouse buttons you still have to hold the alt key down to do so

Thanks,
Jason

jeric_synergy
11-25-2014, 05:30 PM
jboudreau, thanks for posting that! Hopefully we get one giant AHK script for all LW functions we're missing.

Now, is your new addition for "mouse lean"??

jboudreau
11-25-2014, 05:31 PM
think this is in LightWave 2015 now?...

Hi Erikals

Did you find out if the panning is in lightwave 2015. I'm using the demo at the moment and I can't find it or get it to work

Thanks,
Jason

jboudreau
11-25-2014, 05:34 PM
jboudreau, thanks for posting that! Hopefully we get one giant AHK script for all LW functions we're missing.

Now, is your new addition for "mouse lean"??

Hi Jeric

Your welcome after working on getting the middle mouse double click to expand open the views, I'll keep you posted

Sorry I'm not sure what you mean by mouse lean?

Thanks
Jason

jeric_synergy
11-25-2014, 05:56 PM
Sorry I'm not sure what you mean by mouse lean?
My Logitech mouse wheel can be TILTED l/r to scroll horizontally in horizontally scrolling programs. At least, in my browser and word processor.

It would be beyond cool to be able to tilt the mousewheel and pan the orthogonals or spin the perspective.

jboudreau
11-25-2014, 06:09 PM
My Logitech mouse wheel can be TILTED l/r to scroll horizontally in horizontally scrolling programs. At least, in my browser and word processor.

It would be beyond cool to be able to tilt the mousewheel and pan the orthogonals or spin the perspective.

Hi

oh okay I don't have that type of mouse.

Wouldn't this restrict you to only panning left or right and not up or down though.

Here is the code to use the left and right tilt of your mouse in AHK

WheelRight
WheelLeft


Since I don't have the mouse to test I'm going to use a key instead to make the viewport pan left and right. (Shift + the arrow keys will pan the viewport)

Update:

Try this code below

WheelRight::+Right
WheelLeft::+Left


This code will control and pan the viewport up and down with the scroll wheel so if the WheelRight controls the tilt like it's suppose to it should work

WheelUp::+Up
WheelDown::+Down


Hope this helps
Jason