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
 can i create a specific gesture for a website ?
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

giulia

4 Posts

Posted - 07/23/2018 :  01:28:53  Show Profile
Hi
i really love strokesplus
i create all my gesture for chrome and they works perfecly many of them using the forum
i'm almost a novice

i use in chrome the left & right gesture acSendKeys("{BROWSERBACK}") and acSendKeys("{BROWSERFORWARD}")

can i create a spefic gesture for a website (for example flickr) ?

can i use willcards like * ww.flir.com/photos/*

in flick , when you watching a gallery with many photos you can go back and forth with the left & right keyboard keys

can i create a spefic gesture for a website (for example flickr) ?

should i create a new app ?
can you help me please with the most easy solution and maybe a lua script?

thanks



Edited by - giulia on 07/23/2018 01:30:29

Rob

USA
2615 Posts

Posted - 07/23/2018 :  09:33:47  Show Profile  Visit Rob's Homepage
Try this:
if string.match(acGetWindowTitle(nil, gsx, gsy), ".*| Flickr.*Google Chrome$") ~= nil then
	acMessageBox("This is Flickr", "Match!")
	--Put your code here
end
I didn't spend a lot of time on it, but it seems to work for me.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 07/23/2018 :  09:39:44  Show Profile  Visit Rob's Homepage
If you only want to use the URL, you'd have to do something like
acSendKeys("^l") --press ctrl+L to set the focus to the address bar
acDelay(25)
acSendKeys("^c") --send ctrl+C to copy the url
local url = acGetClipboardText() --get the url from the clipboard
--Check the URL here, could use the Lua string.match or string.find to test

But check the forums here as well because some people have certainly done some complicated things based on different web sites.
Go to Top of Page

Gaia

2 Posts

Posted - 07/23/2018 :  10:00:57  Show Profile
quote:
Originally posted by Rob

Try this:
if string.match(acGetWindowTitle(nil, gsx, gsy), ".*| Flickr.*Google Chrome$") ~= nil then
	acMessageBox("This is Flickr", "Match!")
	--Put your code here
end
I didn't spend a lot of time on it, but it seems to work for me.


Hi Rob
the script works very well!
just wondering if i should add a new app ( a second chrome app) or find 2 new gestures that can fit
because left and right , are not available
i have searched in the forum without luck
thank you so much Rob , really appreciate
Go to Top of Page

Rob

USA
2615 Posts

Posted - 07/23/2018 :  10:09:56  Show Profile  Visit Rob's Homepage
Sure, create a new app.

Owner Title Pattern: ^.* Flickr.*Google Chrome$
File Name: chrome.exe

That should cover it.

Edit: You might need to create an exclusion in the regular Chrome app so it doesn't match that one first, possibly.

Or in your action for left or right, you can do two different things, based on the window title, and only have one chrome app.
Go to Top of Page

Gaia

2 Posts

Posted - 07/23/2018 :  10:22:26  Show Profile
quote:
Originally posted by Rob

If you only want to use the URL, you'd have to do something like
acSendKeys("^l") --press ctrl+L to set the focus to the address bar
acDelay(25)
acSendKeys("^c") --send ctrl+C to copy the url
local url = acGetClipboardText() --get the url from the clipboard
--Check the URL here, could use the Lua string.match or string.find to test

But check the forums here as well because some people have certainly done some complicated things based on different web sites.


hi amazing code
it should be like this?
acSendKeys("^l") --press ctrl+L to set the focus to the address bar
acDelay(25)
acSendKeys("^c") --send ctrl+C to copy the url
local url = acGetClipboardText() --get the url from the clipboard
--Check the URL here, could use the Lua string.match or string.find to test
if string.match(acGetWindowTitle(nil, gsx, gsy), "local url") ~= nil then
	acMessageBox("This is Flickr", "Match!")
	--Put your code here
end
Go to Top of Page

Rob

USA
2615 Posts

Posted - 07/23/2018 :  10:25:08  Show Profile  Visit Rob's Homepage
You don't want to test against the window title:

if string.match(url, "PATTERN HERE") ~= nil then
acMessageBox("This is Flickr", "Match!")
--Put your code here
end

Check the Lua string patterns page here: http://lua-users.org/wiki/PatternsTutorial
Go to Top of Page

AxJ

28 Posts

Posted - 02/12/2019 :  03:30:48  Show Profile
quote:
Originally posted by Rob
Sure, create a new app.Owner Title Pattern: ^.* Flickr.*Google Chrome$... Edit: You might need to create an exclusion in the regular Chrome app ...


Hi, I'm highly interested in this scenario too.

May I ask how to "exclude" some websites in the Chrome app by using "Owner Title Pattern"?

I tried to use the pattern you showed me last time but I can't get it right.

I've read the [Regex Cheat Sheet] "http://regexlib.com/CheatSheet.aspx" but I still don't know where I did wrong.

For example, I want to exclude "all files in Google sheets" from the Chrome app:

^.*((?!(Google sheets)).).*Google Chrome$
or
^.*((?!(Google sheets)).*Google Chrome$

Edited by - AxJ on 02/12/2019 03:38:36
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/12/2019 :  08:08:32  Show Profile  Visit Rob's Homepage
Give this a try:

^(?!.* - Google Sheets).* - Google Chrome$

I think your wildcards (.*) before and after the Google Sheets check would cause there to always be a match.

To expand, the (? is a lookahead assertion, meaning examine the characters ahead of the condition to see if they exist.

So ".* - Google Chrome$" matches any page, but the lookahead assertion says it must not include "{wildcard} - Google Sheets".
Go to Top of Page

giulia

4 Posts

Posted - 02/12/2019 :  09:12:11  Show Profile
hi
i have tried to etende to other site but it doesn't work
for example for 500px doesn't work

if string.match(acGetWindowTitle(nil, gsx, gsy), ".*| 500px.*Google Chrome$") ~= nil then
acMessageBox("This is 500px", "Match!")
--Put your code here
end
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/12/2019 :  12:14:30  Show Profile  Visit Rob's Homepage
This seems to work for me. I think the pipe | character might be causing a problem as that's a reserved character in regex.

if string.match(acGetWindowTitle(nil, gsx, gsy), ".*500px.*Google Chrome$") ~= nil then
acMessageBox("This is 500px", "Match!")
--Put your code here
end

If you intend to only match when there is a pipe then a space, try using:

".*\\| 500px.*Google Chrome$"

The backslash escapes the pipe, telling regex to treat it as a character instead of alternation operator.

EDIT: Updated to two backslashes, since the first one escapes the backslash from the Lua string, so it passes "\|"
Go to Top of Page

AxJ

28 Posts

Posted - 02/12/2019 :  20:30:23  Show Profile
quote:
Originally posted by Rob
Give this a try:
^(?!.* - Google Sheets).* - Google Chrome$

Thanks, the pattern works!!!
I just tried some other combinations:

--
The space before "-" could be omitted actually because of "*" (right?):
^(?!.*- Google Sheets).*- Google Chrome$
--
For also working in the "files list" :
^(?!.*Google Sheets).*- Google Chrome$
--
For excluding more than one website:
^(?!.*- (Google Sheets|Google Docs)).*- Google Chrome$
quote:
Originally posted by RobI think your wildcards (.*) before and after the Google Sheets check would cause there to always be a match.
To expand, ... says it must not include "{wildcard} - Google Sheets".

Thank you for the explanation! It's much clearer for me now since I'm very new about these.

Edited by - AxJ on 02/12/2019 20:32:10
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/12/2019 :  20:43:35  Show Profile  Visit Rob's Homepage
Glad to hear!
Right, the space is only there to more explicitly qualify the string.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/12/2019 :  21:05:32  Show Profile  Visit Rob's Homepage
quote:
The space before "-" could be omitted actually because of "*" (right?):


The "." is the wildcard, which means any character. The "*" means any amount of the preceding character, including none at all.

So ".*" means any character and any amount of any character, or none at all.

The expression "^G.ogle$" would match "Google, Gaogle, Ggogle" But would not match "Gooogle"

"^G.*ogle$" would match "Gogle, Google, "Gskdhskjhdfshkjdhkjsfdogle, Goooogle"

"^Go*gle$" would match "Ggle, Google, Goooooogle" but would not match "Goagle, Gaogle"

Go to Top of Page

AxJ

28 Posts

Posted - 02/13/2019 :  00:14:28  Show Profile
quote:
Originally posted by Rob
The "." is the wildcard, which means any character.
The "*" means any amount of the preceding character, including none at all.
...

AARRhhh~~ Right, right! I thought I've thought it through.
Thanks for pointing it out and clarifying.

Edited by - AxJ on 02/13/2019 00:17:13
Go to Top of Page

giulia

4 Posts

Posted - 02/13/2019 :  03:02:43  Show Profile
hi
if string.match(acGetWindowTitle(nil, gsx, gsy), ".*500px.*Google Chrome$") ~= nil then
acMessageBox("This is 500px", "Match!")
--Put your code here
end

it works ! i tried with a similar code without luck
may i ask you my last question ?
i don't know lua , but could i add several links ?
in this way if .......".*500px.*Google Chrome$") or
if ....... ".*| Flickr.*Google Chrome$") or
if.......".*| photos.*Google Chrome$") ~= nil then

?
may i know how is the code ?
and this script works only with chrome and not firefox
thank you so much
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/13/2019 :  07:48:13  Show Profile  Visit Rob's Homepage
So unfortunately Lua string matches don't use regular expressions, rather it uses pattern (http://lua-users.org/wiki/PatternsTutorial). So things that would be easy to make into a single regular expression are not as easily done in Lua string pattern matching.

The code below seems to work for me, but it's not doing a very explicit match, so you could run into unexpected situations. For example, the "photos" one would match is the title of the page has the word "photos" in it anywhere, which I imagine will happen pretty often.

For example, this page would show as a match: http://www.bbc.com/culture/story/20190212-don-mccullin-the-photos-we-cant-look-away-from
local windowTitle = acGetWindowTitle(nil, gsx, gsy) 
--First we'll see if the window title contains either "Google Chrome" or "Mozilla Firefox".
if string.find(windowTitle, " - Google Chrome") or string.find(windowTitle, " - Mozilla Firefox") then
	--Now we'll see if the window title contains "500px" or "Flickr" or "photos"
	if string.match(windowTitle, ".*500px.*") ~= nil
	   or string.match(windowTitle, ".*Flickr.*") ~= nil
	   or string.match(windowTitle, ".*photos.*") ~= nil then
		acMessageBox("This is 500px, Flickr, or contains 'photos'", "Match!")
	end
end

So you might have to change the above script some more to reduce the false positive matches as needed. But this should hopefully give you a place to start.
Go to Top of Page

giulia

4 Posts

Posted - 02/14/2019 :  08:49:49  Show Profile
hi Rob
thank you so much
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