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

Notification

Icon
Error

Options
Go to last post Go to first unread
sery111  
#1 Posted : Wednesday, April 26, 2023 9:12:00 AM(UTC)
sery111

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/29/2021(UTC)
Posts: 9

when closing a document,There will be two situations:one situation is A pop-up window asking if it has been saved; another situation is to close the window directly. When writing a script to close a document how to distinguish between the two situations ?

Rob  
#2 Posted : Wednesday, April 26, 2023 1:17:58 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
This would vary by application, since they could all use different methods to prompt for saving which do not appear the same in the window hierarchy.

For example, Notepad's save prompt is very different from Microsoft Word's save dialog.

sery111  
#3 Posted : Thursday, April 27, 2023 3:10:22 AM(UTC)
sery111

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/29/2021(UTC)
Posts: 9

Can the mouse script achieve such a function when closing Notepad:move the mouse to the pop-up window if Notepad is not saved, otherwise close it directly?
Rob  
#4 Posted : Thursday, April 27, 2023 3:43:51 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
It's technically possible, but it's very tedious to get just right. You'd have to either walk the window hierarchy, test the save window's title based on relative location to the parent Notepad window, or use image comparison.

I don't have a script handy already to do that, and it would likely take time to work on it that I don't have at the moment. :-/
sery111  
#5 Posted : Saturday, April 29, 2023 8:16:49 AM(UTC)
sery111

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/29/2021(UTC)
Posts: 9

Found a script (global action) to achieve this:

sp.SendModifiedVKeys([vk.LMENU], [vk.F4]);
sp.Sleep(100);
sp.ForegroundWindow().Activate();
var w_Bottom = sp.ForegroundWindow().Rectangle.Bottom;
var w_exe = sp.ForegroundWindow().Process.ProcessName;
var w_class = sp.ForegroundWindow().ClassName;
if(w_exe == "notepad"){
if(w_class == "#32770"){
sp.SendVKey(vk.TAB);
var w_Move = sp.ForegroundWindow().Rectangle.Bottom - 20;
sp.MouseRestrictToRectangle(new Rectangle(1000, w_Move, 0, 0));
sp.StoreBool("mouseRestrict", true);
sp.Sleep(500);
sp.MouseRestrictClear();
sp.StoreBool("mouseRestrict", false);
}
}
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.