This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Feature Updates
 New Features
 [ADDED] Allow Mouse Wheel Tick Script
 Forum Locked
 Printer Friendly
Author  Topic Next Topic  

Rob

USA
2615 Posts

Posted - 01/22/2014 :  15:24:04  Show Profile  Visit Rob's Homepage
This is an experimental feature and has a moderate chance of being unstable and/or reducing mouse wheel performance. This is for advanced users who understand what enabling this option means.

Added in 2.7.9.

Preference: Allow Mouse Wheel Tick Script*

(cannot be enabled with Enable Mouse Wheel Relay)

This option lets you instruct S+ to, on each mouse wheel tick (scroll event), fire the sp_wheel_tick function in Global Lua (which you must define). See the change log for a description of the parameters, but here's a simple example script which will scroll tabs in Chrome, if the mouse is in the top region of the Chrome window (top most 64 pixels), otherwise it will relay the mouse wheel message to the control where the wheel was originally scrolled:
function sp_wheel_tick(control, wParam, lParam, x, y, delta)
	local exe = acGetExecutableName(control, nil, nil) --get the name of the EXE
	local owner = acGetOwnerWindowByPoint(x, y) --get the owner window of the control
	if exe == "chrome.exe" or exe == "notepad++.exe" then
		if acGetForegroundWindow() ~= owner then --if the window isn't the active one...
			acActivateWindow(owner) --activate it
		end
		if y <= acGetWindowTop(owner) + 64 then --is the mouse in the top 64 pixel area of the window?
			if delta > 0 then
				--mouse wheel scrolled up
				acSendKeys("^{TAB}")
			else
				--mouse wheel scrolled down
				acSendKeys("^+{TAB}")
			end
			return
		end
		if x >= acGetWindowRight(owner) - 25 then --is the mouse along the right side of the window?
			if delta > 0 then
				--scroll up, send CTRL+Home to go to the top of the page
				acSendKeys("^{HOME}")
			else
				--scroll down, send CTRL+End to go to the end of the page
				acSendKeys("^{END}")
			end
			return
		end
	end
	--Default, pass mouse wheel message onto the original control
	acPostMessage(control, 0x020A, wParam, lParam)
end

control_freak

51 Posts

Posted - 05/16/2016 :  05:21:44  Show Profile
hey rob,
i used to love this option when i used coolnovo browser. but the browser is a deadware now. i dont understand how to do this with strokesplus. can u explain a little bit of where i should put this code, how to define the sp_wheel_tick function in global lua, how to allow mouse tick script and how to disable mouse wheel relay. TIA
Go to Top of Page

control_freak

51 Posts

Posted - 05/16/2016 :  13:06:48  Show Profile
ok i found out mouse tick and wheel relay and allow after relay but it stopped my normal scrolling and still dont no how to work this thing in global lua and tabs are not scrolling either please help me
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/20/2016 :  17:18:07  Show Profile  Visit Rob's Homepage
The function above is what needs to be in the Global Lua tab. Just make sure that you don't already have a function named sp_wheel_tick defined. In its most basic form, where it does nothing but relay the wheel tick without interfering is
function sp_wheel_tick(control, wParam, lParam, x, y, delta)
	--Default, pass mouse wheel message onto the original control
	acPostMessage(control, 0x020A, wParam, lParam)
end
If you have the right options set, this should fire everytime you roll the mouse wheel and the window should scroll just like if you didn't have S+ running.

Now, to have custom things happen when you scroll the wheel, you'd have to start adding logic, like the script example above.
Go to Top of Page

control_freak

51 Posts

Posted - 05/20/2016 :  19:43:14  Show Profile
i have these options on.
http://s32.postimg.org/gsynwwy2t/Capture.png

do i have to put these logics on configure actions tab cause ive put it there and tried with and without gesture configuration and coudnt make it work.

Edited by - control_freak on 05/20/2016 19:44:50
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/20/2016 :  19:46:03  Show Profile  Visit Rob's Homepage
The image link is not valid. The function goes in the Global Lua tab script. S+ calls that function on each wheel tick.
Go to Top of Page

control_freak

51 Posts

Posted - 05/21/2016 :  11:45:00  Show Profile
i've these options on preference
aggresively manage memory
reset cancel delay on movement
keep gesture draw window on top
dont hide gesture draw window
fire recognition on mouse wheel scroll
capture modifiers on stroke button down
allow mouse wheel tick script
allow after action script
allow after release script
this function in global lua
function sp_wheel_tick(control, wParam, lParam, x, y, delta)
--Default, pass mouse wheel message onto the original control
acPostMessage(control, 0x020A, wParam, lParam)
end

do i have to put this in global lua or lua script in configure actions tab? if i have to put it in lua script is it necessary to add a mouse key modifier?
function sp_wheel_tick(control, wParam, lParam, x, y, delta)
local exe = acGetExecutableName(control, nil, nil) --get the name of the EXE
local owner = acGetOwnerWindowByPoint(x, y) --get the owner window of the control
if exe == "chrome.exe" or exe == "notepad++.exe" then
if acGetForegroundWindow() ~= owner then --if the window isn't the active one...
acActivateWindow(owner) --activate it
end
if y <= acGetWindowTop(owner) + 64 then --is the mouse in the top 64 pixel area of the window?
if delta > 0 then
--mouse wheel scrolled up
acSendKeys("^{TAB}")
else
--mouse wheel scrolled down
acSendKeys("^+{TAB}")
end
return
end
if x >= acGetWindowRight(owner) - 25 then --is the mouse along the right side of the window?
if delta > 0 then
--scroll up, send CTRL+Home to go to the top of the page
acSendKeys("^{HOME}")
else
--scroll down, send CTRL+End to go to the end of the page
acSendKeys("^{END}")
end
return
end
end
--Default, pass mouse wheel message onto the original control
acPostMessage(control, 0x020A, wParam, lParam)
end

Edited by - control_freak on 05/21/2016 18:18:22
Go to Top of Page

control_freak

51 Posts

Posted - 05/21/2016 :  22:56:27  Show Profile
never mind got it thanks rob you're the best
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/21/2016 :  22:58:08  Show Profile  Visit Rob's Homepage
Glad to hear! It's kind of difficult to walk someone through all of the various things without being at their computer :)
Go to Top of Page

control_freak

51 Posts

Posted - 05/21/2016 :  23:56:04  Show Profile
haha true. i know u try your best. my action lua looks like this now

function sp_wheel_tick(control, wParam, lParam, x, y, delta)
local exe = acGetExecutableName(control, nil, nil) --get the name of the EXE
local owner = acGetOwnerWindowByPoint(x, y) --get the owner window of the control
if exe == "chrome.exe" or exe == "notepad++.exe" then
if acGetForegroundWindow() ~= owner then --if the window isn't the active one...
acActivateWindow(owner) --activate it
end
if y <= acGetWindowTop(owner) + 64 then --is the mouse in the top 64 pixel area of the window?
if delta > 0 then
--mouse wheel scrolled up
acSendKeys("^+{TAB}")
else
--mouse wheel scrolled down
acSendKeys("^{TAB}")
end
return
end
if x >= acGetWindowRight(owner) - 100 then --is the mouse along the right side of the window?
if delta > 0 then
--scroll up, send CTRL+Home to go to the top of the page
acSendKeys("^{HOME}")
else
--scroll down, send CTRL+End to go to the end of the page
acSendKeys("^{END}")
end
return
end
if y >= acGetWindowBottom(owner) - 20 then --is the mouse along the bottom side of the window?
if delta > 0 then
--scroll up, send VOLUP
acSendKeys("{MEDIAPREVTRACK}")
else
--scroll down, send VOLDOWN
acSendKeys("{MEDIANEXTTRACK}")
end
return
end
if x <= acGetWindowLeft(owner) + 20 then --is the mouse along the bottom side of the window?
if delta > 0 then
--scroll up, send VOLUP

acSendKeys("{VOLUP}")
else
--scroll down, send VOLDOWN
acSendKeys("{VOLDOWN}")
end
return
end
end
--Default, pass mouse wheel message onto the original control
acPostMessage(control, 0x020A, wParam, lParam)
end



what should I do to make it work everywhere not only just chrome or notepad?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/22/2016 :  00:09:13  Show Profile  Visit Rob's Homepage
Hopefully the code comments below help.
function sp_wheel_tick(control, wParam, lParam, x, y, delta)
	local exe = acGetExecutableName(control, nil, nil) --get the name of the EXE
	local owner = acGetOwnerWindowByPoint(x, y) --get the owner window of the control
	
	--The next line says to only execute the following code IF it's Chrome or Notepad++
	if exe == "chrome.exe" or exe == "notepad++.exe" then
		if acGetForegroundWindow() ~= owner then --if the window isn't the active one...
			acActivateWindow(owner) --activate it
		end
		if y <= acGetWindowTop(owner) + 64 then --is the mouse in the top 64 pixel area of the window?
			if delta > 0 then
				--mouse wheel scrolled up
				acSendKeys("^+{TAB}")
			else
				--mouse wheel scrolled down
				acSendKeys("^{TAB}")
			end
			return --EXIT the function, not executing anything below
		end
		if x >= acGetWindowRight(owner) - 100 then --is the mouse along the right side of the window?
			if delta > 0 then
				--scroll up, send CTRL+Home to go to the top of the page
				acSendKeys("^{HOME}")
			else
				--scroll down, send CTRL+End to go to the end of the page
				acSendKeys("^{END}")
			end
			return --EXIT the function, not executing anything below
		end
		if y >= acGetWindowBottom(owner) - 20 then --is the mouse along the bottom side of the window?
			if delta > 0 then
				--scroll up, send VOLUP 
				acSendKeys("{MEDIAPREVTRACK}")
			else
				--scroll down, send VOLDOWN
				acSendKeys("{MEDIANEXTTRACK}")
			end
			return --EXIT the function, not executing anything below
		end
		if x <= acGetWindowLeft(owner) + 20 then --is the mouse along the bottom side of the window?
			if delta > 0 then
				--scroll up, send VOLUP 
				acSendKeys("{VOLUP}")
			else
				--scroll down, send VOLDOWN
				acSendKeys("{VOLDOWN}")
			end
			return --EXIT the function, not executing anything below
		end
	end --This is the END of the "Is this Chrome or Notepad++" check
	
	--This code gets called only if nothing else above issued a "return" command
	--Default, pass mouse wheel message onto the original control
	acPostMessage(control, 0x020A, wParam, lParam)
end
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/22/2016 :  00:11:52  Show Profile  Visit Rob's Homepage
So you could comment out (--) or delete the lines:

if exe == "chrome.exe" or exe == "notepad++.exe" then

and the terminating "end", where I've noted it's the end of the Chrome/Notepad++ check.

Then it would execute for every program.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/22/2016 :  00:21:06  Show Profile  Visit Rob's Homepage
Just to expand a bit. The variables and functions in Global Lua are accessible to any action scripts.

Also, S+ (internally) has some code that checks to see if some option is enabled, and if it's enabled and the appropriate function exists (e.g. sp_wheel_tick) in the Global Lua script, S+ will execute the function.

So it's a bit confusing since Action scripts are executed as a result of a gesture/action you've explicitly created. Where the S+ specific functions in Global Lua are something that S+ checks for and executes based on the options.

In the new version I'm working on, these things will be grouped together explicitly. For example, you see the option to execute a script/action step sequence when the mouse wheel is scrolled, and right below that is only the area which relates directly to that action, instead of the Global Lua script area which is kind of a catch-all for a variety of miscellaneous functions, internal and external (defined by the user).

The new version will still allow for a generic place to create custom functions/variables, but the internal ones will be contained and placed right where they're appropriate.
Go to Top of Page

control_freak

51 Posts

Posted - 05/22/2016 :  00:48:40  Show Profile
works like a charm. thank you so much rob :x. can't wait for the new version with so many options
Go to Top of Page

control_freak

51 Posts

Posted - 05/25/2016 :  22:21:22  Show Profile
hey rob,
i have a new problem with this script.

if y >= acGetWindowBottom(owner) - 20 then --is the mouse along the bottom side of the window?
			if delta > 0 then
				--scroll up, send VOLUP 
				acSendKeys("{MEDIAPREVTRACK}")

if i am at the bottom of any window even if it is not maximized and i scroll mouse my track change command fires. it's even preventing me from scrolling down this comment section:| i tried changing it to acGetMonitorBottom-20 it doesn't work. can you think of a work around
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/25/2016 :  22:39:05  Show Profile  Visit Rob's Homepage
acGetWindowBottom(owner) is only going to get the bottom of the window, wherever that is, maximized or not.

acGetMonitorBottom is probably what you're looking for if you only want it to happen when your mouse is near the bottom of the screen.

What's the actual code you tried for acGetMonitorBottom?
Go to Top of Page

control_freak

51 Posts

Posted - 05/25/2016 :  22:47:40  Show Profile
if y >= acGetMonitorBottom(owner) - 50 then --is the mouse along the bottom side of the window?
if delta > 0 then
--scroll up, send VOLUP
acSendKeys("{MEDIAPREVTRACK}")
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/25/2016 :  23:02:38  Show Profile  Visit Rob's Homepage
You have to look up the functions..that's not the right way to call acGetMonitorBottom...

http://www.strokesplus.com/help/#acGetMonitorBottom

The first parameter requires the handle to the monitor, so you have to get that first, via acGetMonitorFromPoint:

http://www.strokesplus.com/help/#acGetMonitorFromPoint

The second parameter for acGetMonitorBottom is whether or not to include the working area (0 to indicate the entire screen, 1 to indicate only the working area). The working area would be the area of the screen without the taskbar, if it's not set to auto hide of course.

So, you'd probably want to try something like (nesting functions is acceptable):
if y >= acGetMonitorBottom(acGetMonitorFromPoint(gsx, gsy), 0) - 50 then --is the mouse along the bottom side of the screen?
	if delta > 0 then
		--scroll up, send VOLUP 
		acSendKeys("{MEDIAPREVTRACK}")

Here's the same result without nesting the functions:
local monitorhandle = acGetMonitorFromPoint(gsx, gsy)
if y >= acGetMonitorBottom(monitorhandle, 0) - 50 then --is the mouse along the bottom side of the screen?
	if delta > 0 then
		--scroll up, send VOLUP 
		acSendKeys("{MEDIAPREVTRACK}")



Go to Top of Page

control_freak

51 Posts

Posted - 05/27/2016 :  03:58:18  Show Profile
thank you :d
Go to Top of Page

Hard.Wired

84 Posts

Posted - 11/29/2017 :  21:46:05  Show Profile
I am having problems getting this to fire with Windows 10 apps (i.e. Store / Edge). Is there something I am missing?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 11/29/2017 :  22:05:36  Show Profile  Visit Rob's Homepage
Those apps reside in a different domain and are treated differently by Windows in terms of the types of messages they receive.
Go to Top of Page

Hard.Wired

84 Posts

Posted - 11/30/2017 :  17:42:27  Show Profile
Ah, makes sense. Related to the "Windows Shell Experience Host" etc. etc. ?

I think I have a work around though.
Go to Top of Page
   Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000