Author |
Topic |
|
cyberalex4life
53 Posts |
Posted - 06/29/2012 : 14:11:24
|
Many mouses's scroll do the folowing thing: when you roll the scroll up and down, for every click you here (if you here any), the page goes down or up a certain amount set in windows Mouse menu (3 rows, or one page) I'm asking for 2 VK's that emulate the folowing: {SCROLL_UP}/{SCROLL_DOWN} exactly emulates one of that click (ONE UNIT OF SCROLL), such that one could be able to use that unit in combination with OTHER_KEY + SCROLL_ACTION in windows. I mean Ctrl + Scroll Up = Zoom In should be implemented like "^{SCROLL_UP}" = one unit zoom in, or "+{SCROLL_UP}" = one unit scroll left |
|
Rob
USA
2615 Posts |
Posted - 06/29/2012 : 15:00:52
|
This can be done via windows messages. The samples below send the message to the control below the mouse cursor where the gesture started, feel free to change if needed.
I don't want to bloat S+ by continually adding more and more action functions to handle every single scenario. In fact, unless there's a compelling reason to do so, there won't be additional actions added, rather the scripts required will be provided in the forum. Some day, I'd like to make a web page that puts all the scripts together in a way that is easy to find/search/browse, but not there yet.
local WM_MOUSEWHEEL = 0x20A
local WHEEL_POS = 0x00780000 --standard 120 tick of a mouse wheel scroll up, pre-left-shifted for simplifying usage below
local WHEEL_NEG = 0xff880000 --standard -120 tick of a mouse wheel scroll down, pre-left-shifted for simplifying usage below
local MK_CONTROL = 0x08
local MK_LBUTTON = 0x01
local MK_MBUTTON = 0x10
local MK_RBUTTON = 0x02
local MK_SHIFT = 0x04
local MK_XBUTTON1 = 0x20
local MK_XBUTTON2 = 0x40
local WM_HSCROLL = 0x114
local WM_VSCROLL = 0x115
local SB_PAGEDOWN = 0x03
local SB_PAGEUP = 0x02
local SB_PAGELEFT = 0x02
local SB_PAGERIGHT = 0x03
local SB_LINEDOWN = 0x01
local SB_LINEUP = 0x00
local SB_LINELEFT = 0x00
local SB_LINERIGHT = 0x01
--Control + Scroll Up
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_MOUSEWHEEL, WHEEL_POS+MK_CONTROL, bit32.lshift(gsy,16)+gsx)
--Control + Scroll Down
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_MOUSEWHEEL, WHEEL_NEG+MK_CONTROL, bit32.lshift(gsy,16)+gsx)
--Shift + Scroll Up
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_MOUSEWHEEL, WHEEL_POS+MK_SHIFT, bit32.lshift(gsy,16)+gsx)
--Shift + Scroll Down
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_MOUSEWHEEL, WHEEL_NEG+MK_SHIFT, bit32.lshift(gsy,16)+gsx)
--Vertically scrolls one page up (if the control accepts the WM_VSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_VSCROLL, SB_PAGEUP, nil)
--Vertically scrolls one page down (if the control accepts the WM_VSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_VSCROLL, SB_PAGEDOWN, nil)
--Vertically scrolls one line up (if the control accepts the WM_VSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_VSCROLL, SB_LINEUP, nil)
--Vertically scrolls one line down (if the control accepts the WM_VSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_VSCROLL, SB_LINEDOWN, nil)
--Horizontally scrolls one page right (if the control accepts the WM_HSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_HSCROLL, SB_PAGERIGHT, nil)
--Horizontally scrolls one page left (if the control accepts the WM_HSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_HSCROLL, SB_PAGELEFT, nil)
--Horizontally scrolls one line right (if the control accepts the WM_HSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_HSCROLL, SB_LINERIGHT, nil)
--Horizontally scrolls one line left (if the control accepts the WM_HSCROLL message and has a scroll bar)
acPostMessage(acGetWindowByPoint(gsx, gsy), WM_HSCROLL, SB_LINELEFT, nil)
|
|
|
Rob
USA
2615 Posts |
Posted - 06/29/2012 : 15:35:26
|
Actually, I think my bit32.band call isn't serving a purpose, but it seems to work anyway..maybe imafishimafish will chime in on that
Basically, the lParam for WM_MOUSEWHEEL should be the mouse coordinates, low-order for X, high-order for Y. Of course, I see it looks like I may have swapped those as well. I don't believe the coordinates are terribly crucial to that message, but would be nice to have it the proper value. |
|
|
Rob
USA
2615 Posts |
Posted - 06/29/2012 : 18:15:02
|
Never mind, imafishimafish, I figured it out using message boxes and Calc.
Got it now and fixed the code above.
Also corrected the WHEEL_NEG to 0xff880000 (from 0xff780000). |
|
|
imafishimafish
USA
19 Posts |
Posted - 07/02/2012 : 00:08:44
|
quote: Originally posted by Rob
Never mind, imafishimafish, I figured it out using message boxes and Calc.
Got it now and fixed the code above.
Also corrected the WHEEL_NEG to 0xff880000 (from 0xff780000).
Glad it's working, you beat me to it. So much for "won't be checking the forum as often..." |
|
|
Bennomoehlman
5 Posts |
Posted - 07/16/2012 : 18:09:40
|
Thanks for this. Horizontal scrolling is a pain with a mouse!
Is there any way to increase the the number of clicks that I can scroll when I'm scrolling horizontally?
Thanks. |
|
|
Rob
USA
2615 Posts |
Posted - 07/16/2012 : 18:34:16
|
Technically yes, but it may be more complicated than what you're looking for =)
As per Microsoft (http://msdn.microsoft.com/en-us/library/windows/desktop/bb787575.aspx), the WM_HSCROLL message accepts SB_THUMBPOSITION as a wParam, but you'd have to get/know exactly what position you'd like to advance the scrollbar to.
To be honest, just fire the acPostMessage call more than once in your script, using the line right/left until it's the amount you'd like. Or, if you set it up with a gesture pair using the Fire Recognition on Mouse Wheel Scroll option, each mouse wheel tick would scroll either by SB_LINERIGHT or SB_PAGERIGHT (for scrolling right) within the same action(s). |
|
|
Rob
USA
2615 Posts |
Posted - 07/16/2012 : 18:40:06
|
You could also utilize the mouse wheel (if you Fire Recognition on Mouse Wheel Scroll disabled) and do a loop based on the gwd variable passed into your action.
Meaning, you have a gesture setup using scroll up (for example) as a modifier and no gesture selected. Then you hold down the right button and scroll the mouse up 3 ticks and let go of the stroke button.
Then in your script, the gwd value would equal 360 (120 per tick) and you could use a loop to fire the acPostMessage once for every 120 of gwd. |
|
|
Bennomoehlman
5 Posts |
Posted - 08/13/2012 : 11:14:02
|
Sending the same command twice? What a complicated solution! Thanks, Rob!
I do utilize the mouse wheel to do horizontal scroll. It just wasn't scrolling fast enough for me. But it does now. Not the smoothest thing in the world, but it works.
Horizontal scrolling doesn't work in work in Word 2010. That's the only place it doesn't work. Is there any help you can offer me?
Thanks! |
|
|
Rob
USA
2615 Posts |
Posted - 08/13/2012 : 13:05:18
|
Not sure on that one as I don't have Office 2010 on my system. I'll see if I can find anything out, though. |
|
|
Bennomoehlman
5 Posts |
Posted - 08/13/2012 : 14:37:41
|
Thanks, Rob. |
|
|
Rob
USA
2615 Posts |
Posted - 08/13/2012 : 23:06:02
|
Hmm, doesn't work for Word 2007 either. A Google search shows there are other apps which send horizontal scrolling messages to Word that also have the issue. Well, to be clear, it's more of a Word issue in not recognizing the scroll messages.
For example: http://www.excelbanter.com/showthread.php?t=166697 (the doesn't directly apply to this situation, but the complaint does)
It seems like maybe Word (or perhaps Office) doesn't like these messages or expects them to be sent to a specific handler.
Still stumped... |
|
|
Bennomoehlman
5 Posts |
Posted - 08/14/2012 : 10:26:20
|
Hmmmm.... well, I'm glad it's not my stupidity! :-)
Your scrolling solution also doesn't work in Excel, however, I worked that out by using keyboard shortcuts. But I can't find any keyboard shortcuts for use in Word...
Thanks! Appreciate the help. |
|
|
breakcore
Russia
74 Posts |
Posted - 09/12/2012 : 16:20:00
|
Hey, Rob. I have two questions I wanted to ask without starting a new topic as they are related to this one.
1) is there a code for "alt" key? local MK_CONTROL = 0x08 local MK_SHIFT = 0x04 local MK_ALT = ???
2) is it possible to send a key_down/key_up event? I need this to achieve that kind of things: {z_down} {mouse_click} {z_up} or {space_down} {mouse_move} {space_up}
p.s. I must admit S+ is a really addictive thing sometimes :) |
|
|
Rob
USA
2615 Posts |
Posted - 09/12/2012 : 17:44:52
|
For this script in particular (mouse wheel messages), it doesn't appear so:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645617.aspx
For individual key down/up events, you could invoke Alien to call the Windows keybd_event or SendInput API directly. I don't have the time (at the moment) to build a script, but will try to get you something soon.
|
|
|
breakcore
Russia
74 Posts |
Posted - 09/12/2012 : 19:47:34
|
quote: Originally posted by Rob
For this script in particular (mouse wheel messages), it doesn't appear so:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645617.aspx
For individual key down/up events, you could invoke Alien to call the Windows keybd_event or SendInput API directly. I don't have the time (at the moment) to build a script, but will try to get you something soon.
regarding first question this way works well: acSendAltDown() acPostMessage(acGetWindowByPoint(gsx, gsy), WM_MOUSEWHEEL, WHEEL_POS/WHEEL_NEG, bit32.lshift(gsy,16)+gsx) acSendAltUp()
about key_up/down - it's not brutally important feature for me, if you feel script won't meet much use may be it doesn't worth spending time on. Anyway thanks!
|
|
|
Rob
USA
2615 Posts |
Posted - 09/12/2012 : 19:55:35
|
I think what I'm going to do is simply modify the sendkeys code to accept some extra parameters and create a new action which calls the same code as acSendKeys, but allows for only sending a down or up..so it won't be too complicated. |
|
|
Rob
USA
2615 Posts |
Posted - 09/12/2012 : 21:46:57
|
Added acSendKeyDown(VKey) and acSendKeyUp(VKey) in 2.3.0.
Note that you must supply the virtual keycode, not the letter itself. this allows for greater control (like sending non-alphanumeric keycodes) and makes it much easier to implement =) |
|
|
breakcore
Russia
74 Posts |
Posted - 09/13/2012 : 04:57:01
|
quote: Originally posted by Rob
Added acSendKeyDown(VKey) and acSendKeyUp(VKey) in 2.3.0.
Note that you must supply the virtual keycode, not the letter itself. this allows for greater control (like sending non-alphanumeric keycodes) and makes it much easier to implement =)
Wow, Thanks Rob! |
|
|
control_freak
51 Posts |
Posted - 05/16/2016 : 13:32:17
|
i was trying the shift+scroll up and down script and it showed this error - attenpt to perform arithmetic on global 'WHEEL_neg'(a nil value) do i have to add something to global lua?
|
|
|
Rob
USA
2615 Posts |
Posted - 05/20/2016 : 17:20:42
|
At the top of the script on this page, there are a bunch of defined variables, so you'd have to have the ones you're using referenced in your script:
local WM_MOUSEWHEEL = 0x20A local WHEEL_POS = 0x00780000 --standard 120 tick of a mouse wheel scroll up, pre-left-shifted for simplifying usage below local WHEEL_NEG = 0xff880000 --standard -120 tick of a mouse wheel scroll down, pre-left-shifted for simplifying usage below
|
|
|
control_freak
51 Posts |
Posted - 05/22/2016 : 03:06:20
|
works yay :d |
|
|
rustyx
7 Posts |
|
Hard.Wired
84 Posts |
Posted - 12/13/2017 : 17:43:41
|
Was there any progress on communicating with Windows 10 apps? |
|
|
|
Topic |
|
|
|