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

Notification

Icon
Error

Options
Go to last post Go to first unread
eugenes  
#1 Posted : Wednesday, December 4, 2019 3:22:38 AM(UTC)
eugenes

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 5

Hi

First of all thank you for the brilliant application, I just can't go without it.

One thing annoys me. If a text area is focused I first need to click outside it to make gestures work.

Can you share a script which switches focus from a text field to the main window?
Rob  
#2 Posted : Wednesday, December 4, 2019 5:34:36 AM(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)
Can you provide me with some specifics? Gestures shouldn't care if a text area has focus or not, unless the action is using keystrokes.

Are there certain applications where this happens, while not in others?

There are a lot of possible intricacies, which is why I'm asking for details; to ensure I understand the full picture.
eugenes  
#3 Posted : Wednesday, December 4, 2019 5:51:38 AM(UTC)
eugenes

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 5

I have gestures up and down assigned to scroll to top and to bottom (ctrl+home, ctrl+end). They don't work in these cases.

1. notepad++

Open find bar (search / incremental search), type a string to find. Now to make my gestures work I must switch focus to the document window. Also ctrl+tab doesn't work if the find bar is focused.

2. Firefox

If a text field is focused I must click outside it to make my gestures work.

Rob  
#4 Posted : Wednesday, December 4, 2019 8:10:08 AM(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)
So that's actually a little trickier than it seems it should be. Ultimately, the application controls focus, meaning that for a generic and consistently functional means of handling things, the mouse simply needs to be clicked somewhere that causes the application to change focus; or perform an equivalent keyboard command that takes focus away from a text field.

The problem is defining those events, especially across different applications. The first two scripts below simply click 1 pixel in and up from the lower left corner of the window and move the mouse back.

I tested this in Notepad++ and Firefox and it seemed to work fine. However, since Firefox doesn't have have a visible border/status bar area, it's possible that depending on the web page, this could result in clicking on something within the page.

The last script only works for Firefox, but it sends Ctrl+L to change focus to the address bar, then sends Tab twice, which on my computer (no extensions, default toolbar) returns focus to the web page area, then sends Ctrl+End.

It seems like this should be much simpler than it actually is, but at the end of the day, StrokesPlus.net can only interact with an application externally; any logic for controlling field focus is entirely dictated by each application - so you have to find some way to use the mouse/keyboard to get the application in a state where Ctrl+Home / Ctrl+End will function, then simulate it in the gesture.

Code:
//Ctrl+Home - Click the bottom left corner of the window
//then move the mouse back to the previous location and send Ctrl+Home
var currentMouseLocation = sp.GetCurrentMousePoint();
var leftEdgeOfWindow = action.Window.Rectangle.Left + 1;
var bottomOfLeftEdge = action.Window.Rectangle.Bottom - 1;
var clickPoint = new Point(leftEdgeOfWindow, bottomOfLeftEdge);
sp.MouseClick(clickPoint, MouseButtons.Left, true, true);
sp.MouseMove(currentMouseLocation); 
sp.SendKeys("^{Home}"); 


Code:
//Ctrl+End - Click the bottom left corner of the window
//then move the mouse back to the previous location and send Ctrl+End
var currentMouseLocation = sp.GetCurrentMousePoint();
var leftEdgeOfWindow = action.Window.Rectangle.Left + 1;
var bottomOfLeftEdge = action.Window.Rectangle.Bottom - 1;
var clickPoint = new Point(leftEdgeOfWindow, bottomOfLeftEdge);
sp.MouseClick(clickPoint, MouseButtons.Left, true, true);
sp.MouseMove(currentMouseLocation); 
sp.SendKeys("^{End}"); 


Code:
//Firefox only - Change focus to the address bar, 
//then send Tab twice to return focus to the web page
//and send Ctrl+End
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_L]);
sp.Sleep(20);
sp.SendVKey(vk.TAB);
sp.Sleep(20);
sp.SendVKey(vk.TAB);
sp.Sleep(20);
sp.SendKeys("^{End}"); 

Edited by user Wednesday, December 4, 2019 9:23:13 AM(UTC)  | Reason: Not specified

eugenes  
#5 Posted : Wednesday, December 4, 2019 11:01:13 PM(UTC)
eugenes

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 5

Hm, I thought it was easier. I found another solution:

Code:
var currpt = sp.GetCurrentMousePoint();
sp.MouseClick(new Point(currpt.X, currpt.Y), MouseButtons.Right, true, true);
sp.Sleep(60);
sp.SendVKey(vk.ESCAPE);
sp.SendKeys("^{HOME}");


it works well and fast but the context menu appears for a moment. Is there a way not to show it when the right mouse button is clicked?

Edited by user Wednesday, December 4, 2019 11:01:50 PM(UTC)  | Reason: Not specified

Rob  
#6 Posted : Thursday, December 5, 2019 7:37:24 AM(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)
Again, that's driven by the application, all S+ can do is cause some event to make it go away.

Of course to be thorough, there are numerous far more technically complicated methods which might be able to accomplish this seamlessly, but they would take a bit of time, are usually very application specific, and involve watching messages and trying to post just the right ones to the application. After nearly a decade of doing this, I've found those methods are simply not worth the time as 50% of the time the entire effort is wasted (unable to make it work), and the remainder usually only work some of the time or completely stop working the next time the application is updated in some way that breaks the previously working approach.

It's amazing how the most seemingly simple things can be very complicated. But as you can imagine, it would be terrible security if any application could simply look inside another application and make it do what it wanted; so we're limited to only interacting with the application externally, with whatever methods it allows. Usually this is just mouse and keyboard input, but some applications (like Winamp) actually allow you to post messages to the app which controls certain things - but again, those messages are only the ones exposed by the application itself.

So it's just a lot of trial and error, trying to find the right sequence of mouse/keyboard events that accomplishes the goal and scripting them into a gesture. When Flash was more prevalent on the web it really caused a lot of annoyances with making gestures work when Flash had taken over the mouse and keyboard input from the browser, leading to some very creative gestures to get them to work in a seamless way.
eugenes  
#7 Posted : Thursday, December 5, 2019 8:57:05 AM(UTC)
eugenes

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 5

Got it

Thank you
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.