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

Notification

Icon
Error

Options
Go to last post Go to first unread
Sofocl  
#1 Posted : Sunday, May 26, 2019 3:47:44 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

It is impossible to send any command to a child window Chrome, extension, save as..., save page as... etc.

Code:
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);

// Send the CTRL+V keystroke
sp.SendKeys("^v");

UserPostedImage
Sorry for my bad English.
Rob  
#2 Posted : Sunday, May 26, 2019 4:36:58 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
Options > Always Activate Window Where Gesture Began

Looks like XTranslate hides itself when the focus isn't on the popup. The option above activates the owner window of where the gesture started, which would be the main Chrome window, causing the XTranslate popup to think you clicked somewhere else and it hides itself.
Sofocl  
#3 Posted : Monday, May 27, 2019 12:39:37 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

After disabling "Always Activate Window Where Gesture Began" option, it worked. Thanks.

Just for clarity of understanding, if this is not a bug: this behavior is for ALL Chrome child windows and not just XTranslate, At the same time, "Always ActivateWindow Where Gesture begin" option is enabled by default.
Which will probably cause problems for others in the future..
Sorry for my bad English.
Rob  
#4 Posted : Monday, May 27, 2019 6:50:20 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
Yeah, it's a trade off...in the original StrokesPlus I did not have it activate the window below where the gesture started, because I didn't want to make decisions for the users.

But, time and time again(!), people would come to the forum asking why it doesn't do that, so I made it on by default in StrokesPlus.net. They also said it should be the default...I can't win :)

So far, it's only you mentioning this as an issue for StrokesPlus.net...so statistically, you and I are not in the majority!

Edited by user Monday, May 27, 2019 6:52:16 PM(UTC)  | Reason: Not specified

Sofocl  
#5 Posted : Tuesday, May 28, 2019 1:13:57 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

Partially you can solve the problem by separating the option "Always Activate Window Where Gesture Began" (If possible) for the first and the second buttons?!
(For me it would be perfect)

If you want I'll create a post in the Feature Requests?
Sorry for my bad English.
Rob  
#6 Posted : Tuesday, May 28, 2019 1:49:38 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
Just use the before action script, that's what it's there for.

Global Actions > Settings > Before Action : Use Script

Code:
//If not Chrome, activate window
if(action.Window.Title.indexOf("- Google Chrome") == -1) {
    action.Window.Activate();
}


Note that application definitions can also have Before/After scripts, but those are only executed for actions which belong to the application, not an action that bubbles up to global actions...hopefully that's not too confusing.
Rob  
#7 Posted : Tuesday, May 28, 2019 1:52:07 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
Oh, you can also test against the stroke button as well, if you need to:

Code:
if(action.Window.Title.indexOf("- Google Chrome") == -1 && action.StrokeButton == MouseButtons.Right) {
    action.Window.Activate();
}
Sofocl  
#8 Posted : Tuesday, May 28, 2019 4:25:45 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

Code:
//If not Chrome, activate window
if(action.Window.Title.indexOf("- Google Chrome") == -1) {
    action.Window.Activate();
}

Unfortunately this does not work for extensions (or did I fail?), for window only: "Save as..."etc. with them also there are optional problems the window flashes and it is impossible to send a command more than 1 time.

So I'm still leaning towards my previous proposal.
Code:
if(action.Window.Title.indexOf("- Google Chrome") == -1 && action.StrokeButton == MouseButtons.Right) {
    action.Window.Activate();
}

With this I have unfortunately nothing happened.
Sorry for my bad English.
Rob  
#9 Posted : Tuesday, May 28, 2019 7:46:52 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
Unfortunately, I don't think separating the option into different segments based on a specific scenario for a small user base is a good approach...or at least one that I want to take. Invariably, it will lead to someone wanting it to be slightly different than you would like it, which just becomes a mess and is why I have these various ways to get specific if needed.

It simply makes things more difficult to manage and adds further complexity for the average person.

However, everything necessary to accomplish this is present, it just will take some additional script logic to handle the various cases. Save dialog windows are a little different than regular windows and sometimes create challenging situations.

But I did change the script here to be a little better, as I hadn't tested the other one with an extension, just that it recognized the main Chrome window versus a different app.

Code:
if(action.Window.Process.MainWindowTitle.indexOf("- Google Chrome") !== -1) {
    if(action.Window.Title.indexOf("Save As") == 0) {
        action.Control.BringToFront();
    }
} else {
    action.Window.BringToFront();
}
Sofocl  
#10 Posted : Wednesday, May 29, 2019 5:03:00 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

Ok, I'll wait for better times)
Code:
if(action.Window.Process.MainWindowTitle.indexOf("- Google Chrome") !== -1) {
    if(action.Window.Title.indexOf("Save As") == 0) {
        action.Control.BringToFront();
    }
} else {
    action.Window.BringToFront();
}

Your last script also didn't work for me at all.
Sorry for my bad English.
Rob  
#11 Posted : Thursday, May 30, 2019 10:15:43 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
You're probably going to have to do some debugging/testing to find out the reasons, that works fine on my system, so I can't help too much.
Rob  
#12 Posted : Friday, May 31, 2019 6:56:30 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 536
United States

Thanks: 5 times
Was thanked: 115 time(s) in 102 post(s)
I added a post on how to enable and use debugging, though it definitely requires some familiarity with coding/debugging.

https://forum.strokesplus.net/posts/t5028-Debugging-Scripts
Sofocl  
#13 Posted : Saturday, June 1, 2019 3:15:25 AM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

Could you give me the exact script including the string "debugger;"?
Sorry for my bad English.
Rob  
#14 Posted : Saturday, June 1, 2019 9:13: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: 115 time(s) in 102 post(s)
Any script you have, you can put "debugger;" as a line of code, probably at the top of the action script, so you can debug the whole thing.

Think of debugger; as a command, since it is, no different than sp.Something, it gets executed and that triggers the debugger to break the code.

Code:
debugger;
var exeName = action.Window.Process.MainModule.ModuleName;
var x = action.Start;


Note that you should click OK to make sure the Settings window isn't open, then go to chrome://inspect/#devices and click inpect, since clicking OK can reload the script engine and disconnect Chrome.

Then draw your gesture and Chrome Dev Tools will break the script at the debugger line for you to debug.

In the debugger, you can then see the values and step into each line of code, one by one.

Chrome Dev Tools

Edited by user Saturday, June 1, 2019 9:19:28 AM(UTC)  | Reason: Not specified

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.