StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rob  
#1 Posted : Sunday, April 28, 2019 12:30:19 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 113 time(s) in 100 post(s)
Here are a pair of scripts to send Control + Mouse Wheel Scroll Up and Down, usually to zoom in and zoom out.

API documentation for the WM_MOUSEWHEEL message:
https://docs.microsoft.com/en-us/windows/desktop/inputdev/wm-mousewheel

Zoom In:
Code:
//Send Control down, as some apps don't fully accept the mouse message's control key part of the message
sp.SendControlDown();
sp.Sleep(10);
//Set the high-order word (mouse scroll delta) to 120 [scroll up],
//set low-order word to 0x0008 [MK_CONTROL] (Control key is down)
var wParam = (120 << 16) | 0x0008;
//Set high-order word to the mouse Y coordinate, 
//set the low-order word to the mouse X coordinate
var lParam = (action.Start.Y << 16) | action.Start.X;
//Post the WM_MOUSEWHEEL message [0x020A] to the control below the mouse
action.Control.PostMessage(host.cast(uint, 0x020A), new IntPtr(wParam), new IntPtr(lParam));
sp.SendControlUp();



Zoom Out:
Code:
//Send Control down, as some apps don't fully accept the mouse message's control key part of the message
sp.SendControlDown();
sp.Sleep(10);
//Set the high-order word (mouse scroll delta) to -120 [scroll down],
//set low-order word to 0x0008 [MK_CONTROL] (Control key is down)
var wParam = (-120 << 16) | 0x0008;
//Set high-order word to the mouse Y coordinate, 
//set the low-order word to the mouse X coordinate
var lParam = (action.Start.Y << 16) | action.Start.X;
//Post the WM_MOUSEWHEEL message [0x020A] to the control below the mouse
action.Control.PostMessage(host.cast(uint, 0x020A), new IntPtr(wParam), new IntPtr(lParam));
sp.SendControlUp();

Edited by user Sunday, April 28, 2019 1:52:23 PM(UTC)  | Reason: Updated to add sending the control key down as well

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.