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
 General Discussion
 General Discussion
 combining 3 scripts with one gesture
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

control_freak

51 Posts

Posted - 04/21/2016 :  18:17:05  Show Profile
is it possible to combine these scripts like for short drag one command will execute, for long drag another, and for dragging to the corner of screen or certain part will execute another command?

short_len=200 --better be specified in global script
if gex-gsx<short_len then
acMessageBox("do something1",'message',nil)
else
acMessageBox("do something2",'message',nil)
end

and this one

local hScreen = acGetMonitorFromPoint(gsx, gsy)
if acGetMonitorRight(hScreen, 10) - gex < 50 then --allow for up to 150 pixels from the edge
acSendKeys("{MEDIANEXTTRACK}")
else
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
--Activate the owning window where the gesture started
acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
end
acSendKeys("{BROWSERFORWARD}")
end

Rob

USA
2615 Posts

Posted - 04/21/2016 :  18:22:35  Show Profile  Visit Rob's Homepage
The world is your oyster, control_freak! You can certainly do that, you just gotta work out the logic :)

I've been drinking and am on my phone, but seeing a whole bunch of posts and am being a bit snarky ;)
Go to Top of Page

control_freak

51 Posts

Posted - 04/21/2016 :  20:02:03  Show Profile
haha true but am not a programmer or coder so i dont no many things.but you've been very helpful. ive just figured this out

local hScreen = acGetMonitorFromPoint(gsx, gsy)
if 1800 - acGetMonitorLeft(hScreen, 1) < gsx then
acSendKeys("{MEDIAPREV}")

still cant figure out how to put all these three together though. :(
Go to Top of Page

control_freak

51 Posts

Posted - 05/22/2016 :  02:46:53  Show Profile
still couldnt figure this one out. help me rob :|
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/23/2016 :  10:19:30  Show Profile  Visit Rob's Homepage
Can you give me a more detailed explanation?
Go to Top of Page

control_freak

51 Posts

Posted - 05/24/2016 :  01:03:26  Show Profile
short_len=200 --better be specified in global script
if gex-gsx<short_len then
acMessageBox("do something1",'message',nil)
else
acMessageBox("do something2",'message',nil)
end

this one means i can add two scripts with one gesture.

local hScreen = acGetMonitorFromPoint(gsx, gsy)
if acGetMonitorRight(hScreen, 10) - gex < 50 then --allow for up to 150 pixels from the edge
acSendKeys("{MEDIANEXTTRACK}")
else
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)

this one allows me to run script when i draw the gesture if its drawn near the edge of the screen right?

i want to combine those three like if i draw the gesture short it'll do one thing if i draw a bigger one it'll trigger another and if i draw the same gesture near the edge it'll do another thing. hope my explanation is clear :|
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  07:15:04  Show Profile  Visit Rob's Homepage
It looks like you have the pieces there, so I'm not sure what it is that's missing.

One thing I do need to clear up first. I've seen you use function declarations in very odd ways, in this post and other places. I'm guessing that you have very little programming/scripting experience?

For example:
local hScreen = acGetMonitorFromPoint(gsx, gsy) 
if acGetMonitorRight(hScreen, 1) - gex < 50 then --allow for up to 150 pixels from the edge
	acSendKeys("{MEDIANEXTTRACK}")
else
	function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
The line in red is a very nonsensical statement. The function keyword indicates that you're defining a function which can be called by other code. I can't speak specifically for Lua (if that is even valid syntax, as in it would cause the function to be defined), but excluding some extremely rare and advanced programming in a language which would allow it, that statement would never be used.

It's clear that you're very excited to craft all kinds of scripts, and that's great! I think it would be a useful investment of your time to find a simple web course (free) for scripting. Any language is really fine, as in the end, all (for the pedants: most) programming languages translate to the same basic stuff: variables, functions, conditions, and loops.

Moving on to your script now! The first question regarding the length is: Which direction is the gesture? Also, is it in a straight line? These are both extremely important questions when it comes to determining the length of a line. Because are you measuring the distance between the start and end points from left to right? Top to bottom? If it's a diagonal line, that requires different math altogether. If it's not a line, that gets even more complicated. I would recommend you only do this for straight lines, to keep it simple. The code below is based on your original, and pretty much is intended to work with a straight line, going from left to right.

Because I'm not sure of which actions you're trying to execute (I only see next track and browser forward), the script below can execute 4 different actions (the code shows a red number where it corresponds to the following condition):

1. Gesture ends within 50 pixels from the right edge of the monitor where the gesture began, and it's shorter than 200 pixels, left to right
2. Gesture ends within 50 pixels from the right edge of the monitor where the gesture began, and it's longer than 200 pixels, left to right
3. Gesture did not end within 50 pixels from the right edge of the monitor where the gesture began, and it's shorter than 200 pixels, left to right
4. Gesture did not end within 50 pixels from the right edge of the monitor where the gesture began, and it's longer than 200 pixels, left to right
local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy) 

if acGetMonitorRight(hScreen, 1) - gex < 50 then 
	-- ^^ this would be true only if the gesture ends within 50 pixels 
 	--    of the right-most coordinate of the monitor where the gesture
	--    drawing began 
	if gex-gsx < short_len then 
		-- ^^ only true if the distance of the x plane (left to right)
		--    of the drawing is less than 200 pixels. If you had a 
		--    more vertical gesture, this may never be true
		--(1)
		acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
		acSendKeys("{BROWSERFORWARD}")
	else 
		--(2)
		acSendKeys("{MEDIANEXTTRACK}")
	end 
else --If the gesture didn't end within 50 pixels of the monitor's right edge
	if gex-gsx < short_len then 
		-- ^^ only true if the distance of the x plane (left to right)
		--    of the drawing is less than 200 pixels. If you had a 
		--    more vertical gesture, this may never be true
		--(3)
		acMessageBox("do something1",'message',nil)
	else 
		--(4)
		acMessageBox("do something2",'message',nil)
	end 
end
Go to Top of Page

control_freak

51 Posts

Posted - 05/24/2016 :  12:43:55  Show Profile
i have no programming experience. i found these from somewhere in this forum and thought this could work together. this script is even better than i expected. :p thank you. could you suggest a programming language for a noob like me?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  12:47:46  Show Profile  Visit Rob's Homepage
Honestly, JavaScript is probably one of the best simply because there is SO much on the Internet and tons of sites that let you code and run the scripts right in the same browser window.

Of course, most of the Internet (from the browser side) runs on JavaScript, so it's a very useful scripting language to learn. Of course, you can also download Lua and make your own Lua scripts to run.

Though I should mention, in the new version of S+ I'm writing, it will use JavaScript...so it's probably a good place to start =)
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  12:52:36  Show Profile  Visit Rob's Homepage
Scripting aside, which is what Lua and JavaScript are, I would recommend downloading Visual Studio 2015 and learn C#. That is, since you asked about programming languages, which are much more powerful than scripting languages. Although, the syntax of C# and JavaScript are fairly similar, so again, that's why I recommend JavaScript as it makes it easier to transition to a more complex programming language if you want to (C, C++, C# share a similar style with JavaScript, though I'm NOT claiming they're at all the same!).

Visual Studio 2015 Community Edition and C# is what I'm using to create the new version of S+, by the way!

However, if you're only looking to dabble in scripting, JavaScript is fine.
Go to Top of Page

control_freak

51 Posts

Posted - 05/24/2016 :  13:14:42  Show Profile
thank you so much bro for being so helpful. u rock
Go to Top of Page

control_freak

51 Posts

Posted - 05/24/2016 :  15:21:11  Show Profile
now i cant modify the gsx,gsy, gex and gey to make script for left up and down gestures :| too complicated for me. can u tell me what should i put for left up and down gestures? or maybe explain a lil bit so i can understand(if u have time)?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  15:24:29  Show Profile  Visit Rob's Homepage
I don't have the answer for that off the top of my head. For those, you'll need to figure out the math necessary to measure the distance of a diagonal line.

All that I would do is Google how to measure the distance from a mathematical perspective, then write it in code. Google "math to measure diagonal line from points", the rest is just math!
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  15:30:11  Show Profile  Visit Rob's Homepage
But as far as the coordinates:

gsx = Gesture Start X point
gsy = Gesture Start Y point

gex = Gesture End X point
gey = Gesture End Y point

Those would be what you'd use when looking at formulas to calculate the distance accordingly.
Go to Top of Page

control_freak

51 Posts

Posted - 05/24/2016 :  15:33:09  Show Profile
not that mathematical measurements. your script is only for right gestures. i have to change the gex and gsx to something else for left gestures neh? cant figure out what to put for left, up and down gestures
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  15:37:37  Show Profile  Visit Rob's Homepage
It's the same concept, though. You have some coordinates and you need to compare them! Some are easier than others, but still the same idea. I'm no longer at my computer and won't be for a while, so you're on your own for now.

It might help to check out the math sites and draw a grid and some lines. Then figure out how to calculate and work with the lines.
Go to Top of Page

control_freak

51 Posts

Posted - 05/24/2016 :  16:57:03  Show Profile
1st 4 gestures work fine. what am i doing wrong on the last else?

local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy)

if acGetMonitorRight(hScreen, 1) - gex < 50 then
-- ^^ this would be true only if the gesture ends within 50 pixels
-- of the right-most coordinate of the monitor where the gesture
-- drawing began
if gex-gsx < short_len then
-- ^^ only true if the distance of the x plane (left to right)
-- of the drawing is less than 200 pixels. If you had a
-- more vertical gesture, this may never be true
--(1)
acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
acSendKeys("@{RIGHT}")
else
--(2)
acDelay(100)

local a1 = acGetClipboardText()
acSendKeys("{DELAY=50}^c")
acDelay(50)
local a2 = acGetClipboardText()
if a2 ~= a1 then
a2 = 'http://www.imdb.com/find?ref_=nv_sr_fn&q='..a2 -- You can search in any web. Just need to see the address bar in the page you want to search, like youtube.
acShellExecute("open","rundll32.exe",
"url.dll,FileProtocolHandler "..a2, nil, 1)
else
wEb = 'www.imdb.com/'--change the web here!
acShellExecute("open","rundll32.exe",
"url.dll,FileProtocolHandler "..wEb, nil, 1)

end
end
else --If the gesture didn't end within 50 pixels of the monitor's right edge
if gex-gsx < short_len then
-- ^^ only true if the distance of the x plane (left to right)
-- of the drawing is less than 200 pixels. If you had a
-- more vertical gesture, this may never be true
--(3)
acSendKeys("@3")
else
--(4)
acSendKeys("@5")
end


end
else

if acGetMonitorRight(hScreen, 1) -1800 > gsx then
acSendKeys("{MEDIAPREV}")
end


when i try to include the last else it says error. i want this gesture to start from left screen toward right and end within 200 pixels of left screen. it works when i test the script alone but error shows <eof> expected near else :|

Edited by - control_freak on 05/24/2016 17:00:16
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/24/2016 :  20:20:05  Show Profile  Visit Rob's Homepage
https://www.lua.org/pil/4.3.1.html

An "if" can't have more than 1 "else"; that is more than one stand alone "else".

You can have:
	if

	elseif

	elseif

	else

	end
But not:
	if

	else

	else

	end
Without a condition, it doesn't make sense because you can either do something or not; the last else would never get executed under any circumstance.

Something like this should work:
local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy) 

if acGetMonitorRight(hScreen, 1) - gex < 50 then 
	-- ^^ this would be true only if the gesture ends within 50 pixels 
	-- of the right-most coordinate of the monitor where the gesture
	-- drawing began 
	if gex-gsx < short_len then 
		-- ^^ only true if the distance of the x plane (left to right)
		-- of the drawing is less than 200 pixels. If you had a 
		-- more vertical gesture, this may never be true
		--(1)
		acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
		acSendKeys("@{RIGHT}")
	else 
		--(2)
		acDelay(100)

		local a1 = acGetClipboardText()
		acSendKeys("{DELAY=50}^c")
		acDelay(50)
		local a2 = acGetClipboardText()
		if a2 ~= a1 then
			a2 = 'http://www.imdb.com/find?ref_=nv_sr_fn&q='..a2 
			acShellExecute("open","rundll32.exe", "url.dll,FileProtocolHandler "..a2, nil, 1)
		else
			wEb = 'www.imdb.com/'--change the web here!
			acShellExecute("open","rundll32.exe", "url.dll,FileProtocolHandler "..wEb, nil, 1)
		end
	end 
elseif acGetMonitorRight(hScreen, 1) -1800 > gsx then
	acSendKeys("{MEDIAPREV}")
else --If the gesture didn't end within 50 pixels of the monitor's right edge or the elseif above
	if gex-gsx < short_len then 
		-- ^^ only true if the distance of the x plane (left to right)
		-- of the drawing is less than 200 pixels. If you had a 
		-- more vertical gesture, this may never be true
		--(3)
		acSendKeys("@3")
	else 
		--(4)
		acSendKeys("@5")
	end 
end
Again, this is a very basic programming fundamental....so you should really do some studying/practicing
Go to Top of Page

control_freak

51 Posts

Posted - 05/25/2016 :  05:24:58  Show Profile
aha i was just tweaking it so asked it sorry am such a pain in the ass lol
Go to Top of Page

Rob

USA
2615 Posts

Posted - 05/25/2016 :  10:42:39  Show Profile  Visit Rob's Homepage
It's all good, but at some point I have to stop giving you fish; you'll have to learn how to fish for yourself and be happier for it!
Go to Top of Page

control_freak

51 Posts

Posted - 05/25/2016 :  18:13:43  Show Profile
here's what my script looks like now. couldn't have done it without you Rob. Thank you

LEFT




local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy) 

if 50 - acGetMonitorLeft(hScreen, 1) > gex then 
	-- ^^ this would be true only if the gesture ends within 50 pixels 
	-- of the left-most coordinate of the monitor where the gesture
	-- drawing began 
	if gsx-gex < short_len then 
		-- ^^ only true if the distance of the x plane (right to left)
		-- of the drawing is less than 200 pixels. If you had a 
		-- more vertical gesture, this may never be true
		--(1)
		acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
		acMessageBox("do something1",'message',nil)
	else 
		--(2)
		acMessageBox("do something1",'message',nil)
	end 
elseif 1800 - acGetMonitorLeft(hScreen, 1) < gsx then
               --(3)
               acMessageBox("do something1",'message',nil)

else --If the gesture didn't end within 50 pixels of the monitor's left edge or the elseif above
	if gsx-gex < short_len then 
		-- ^^ only true if the distance of the x plane (right to left)
		-- of the drawing is less than 200 pixels. If you had a 
		-- more vertical gesture, this may never be true
		--(4)
		acMessageBox("do something1",'message',nil)
	else 
		--(5)
		acMessageBox("do something1",'message',nil)
	end 
end


RIGHT




local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy) 

if acGetMonitorRight(hScreen, 1) - gex < 50 then 
	-- ^^ this would be true only if the gesture ends within 50 pixels 
	-- of the right-most coordinate of the monitor where the gesture
	-- drawing began 
	if gex-gsx < short_len then 
		-- ^^ only true if the distance of the x plane (left to right)
		-- of the drawing is less than 200 pixels. If you had a 
		-- more vertical gesture, this may never be true
		--(1)
		acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
		acMessageBox("do something1",'message',nil)
	else 
		--(2)
		acMessageBox("do something1",'message',nil)

elseif acGetMonitorRight(hScreen, 1) -1800 > gsx then
		--(3)	
		acMessageBox("do something1",'message',nil)

else --If the gesture didn't end within 50 pixels of the monitor's right edge or the elseif above
	if gex-gsx < short_len then 
		-- ^^ only true if the distance of the x plane (left to right)
		-- of the drawing is less than 200 pixels. If you had a 
		-- more vertical gesture, this may never be true
		--(4)
		acMessageBox("do something1",'message',nil)
	else 
		--(5)
		acMessageBox("do something1",'message',nil)
	end 
end


UP




local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy) 

if 50 - acGetMonitorTop(hScreen, 1) > gey then 
	
	if gsy-gey < short_len then 
		
		--(1)
		acMessageBox("do something1",'message',nil)
		--(2)
		acMessageBox("do something1",'message',nil)
elseif 1000 - acGetMonitorTop(hScreen, 1) < gsy then
		--(3)	
		acMessageBox("do something1",'message',nil)
else 
	if gsy-gey < short_len then 
		
		--(4)
		acMessageBox("do something1",'message',nil)
	else 
		--(5)
		acMessageBox("do something1",'message',nil)
	end 
end


DOWN




local short_len=200 --better be specified in global script
local hScreen = acGetMonitorFromPoint(gsx, gsy) 

if acGetMonitorBottom(hScreen, 1) - gey < 50 then 
	
	if gey-gsy < short_len then 
		
		--(1)
		acMessageBox("do something1",'message',nil)
	else 
		--(2)
		acMessageBox("do something1",'message',nil)
elseif acGetMonitorBottom(hScreen, 1) - 1000 > gsy then
		--(3)	
		acMessageBox("do something1",'message',nil)
else 
	if gey-gsy < short_len then 
		
		--(4)
		acMessageBox("do something1",'message',nil)
	else 
		--(5)
		acMessageBox("do something1",'message',nil)
	end 
end

Edited by - control_freak on 05/25/2016 18:34:58
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000