StrokesPlus.net Forum
»
General Discussion
»
General Discussion
»
How to distinguish between the two situations when closing a document?,
Rank: Newbie
Groups: Approved
Joined: 12/29/2021(UTC) Posts: 8
|
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 ?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,308  Location: Tampa, FL Thanks: 28 times Was thanked: 410 time(s) in 351 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.
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 12/29/2021(UTC) Posts: 8
|
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?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,308  Location: Tampa, FL Thanks: 28 times Was thanked: 410 time(s) in 351 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. :-/
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 12/29/2021(UTC) Posts: 8
|
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); } }
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
General Discussion
»
How to distinguish between the two situations when closing a document?,
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close