StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Snip Screen Area and displayed on the screen
Rank: Member
Groups: Approved
Joined: 5/5/2019(UTC) Posts: 12  Thanks: 6 times
|
Is it possible to achieve what is shown below? If so, how can it be modified? Thank you very much and apologize for my poor English!Edited by user Monday, May 6, 2019 12:28:18 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
What is this screenshot from? Is this another program? What exactly is it doing, detecting text from the image?
|
|
|
|
Rank: Member
Groups: Approved
Joined: 5/5/2019(UTC) Posts: 12  Thanks: 6 times
|
This is another program,the name is mouseInc. https://shuax.com/project/mouseinc/Just like default script Snip Screen Area,Copies the area within the square gesture area to the clipboard. The program mouseInc display area within the square gesture area on the screen. How to modify the script(Snip Screen Area) to display the area on the screen? Thanks a lot! Edited by user Tuesday, May 7, 2019 1:41:49 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
I will have to take a look at that, but it's not simple with what S+.net has built in. To display something on the screen requires a window, and the only windows in S+.net are used for other purposes.
A plug-in could likely accomplish this, but would require some development.
|
|
|
|
Rank: Member
Groups: Approved
Joined: 5/5/2019(UTC) Posts: 12  Thanks: 6 times
|
Thank you. I look forward to it
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
Added a simple display image form in version 0.3.0.5. Add this to the bottom of the Snip Screen Area script: Code:sp.DisplayImage(clip.GetImage());
Note that I'm having it use the image from the clipboard as that is safer, since the snip script disposes the memoryImage object, which will lead to a crash (handled in code, but no image will appear since it no longer exists). Click and hold to drag the window around, double-click or press Escape to close the window. This does not have any OCR (optical character recognition) to read the text inside the image like mouseInc does. Maybe someday I will make an OCR plug-in....
|
 1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 5/5/2019(UTC) Posts: 12  Thanks: 6 times
|
I am very glad to receive the update. Thank you for your selfless dedication,Rob!
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
I've used this several times just today! It was something I didn't know that I needed :)
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74  Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Can S + change the size of the window where the picture is located. For example, you can adjust the size of the picture by dragging the bottom right of the picture with the left mouse button? It is expected that S + can adjust the size of the picture instead of the size of the pasted picture.
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
A temporary solution. It will stuck a script engine until you close it. Code:function ShowImage(img, pt) {
if (img == null) return;
var HD = sp.GetSystemMetricsByIndex(5) + sp.GetSystemMetricsByIndex(32);
HD *= 4; HD += sp.GetSystemMetricsByIndex(4);
var WD = sp.GetSystemMetricsByIndex(6) + sp.GetSystemMetricsByIndex(33);
WD *= 4;
var form = new forms.System.Windows.Forms.Form;
form.StartPosition = forms.System.Windows.Forms.FormStartPosition.Manual;
form.FormBorderStyle = forms.System.Windows.Forms.FormBorderStyle.SizableToolWindow;
form.TopMost = true;
form.ShowInTaskbar = false;
form.Location = pt;
form.Width = img.Width + WD;
form.Height = img.Height + HD;
var pic = new forms.System.Windows.Forms.PictureBox;
pic.SizeMode = forms.System.Windows.Forms.PictureBoxSizeMode.Zoom;
pic.Image = img;
pic.Width = img.Width;
pic.Height = img.Height;
var c1 = form.Resize.connect(function (sender, args) {
pic.Width = form.Width - WD;
pic.Height = form.Height - HD;
});
form.Controls.Add(pic);
form.ShowDialog();
c1.disconnect();
}
Example: Code:ShowImage(clip.GetImage(), action.End);
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Yes, it's great, but how do you save the resized picture after double-clicking with the left mouse button or pressing ESC to close the screenshot? Thank you very much,liuxilu
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
var c2 = pic.DoubleClick.connect(function (sender, args) { pic.Image.Save('z:\\test.jpg'); } ); c2.disconnect();
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Although this is not what I expected, thank you very much. The picture below is the effect I really want. I hope that S + will realize this function in the future, or maybe this function will never appear. 
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
var c1 = form.ResizeEnd.connect(function (sender, args) { var scale = (form.Width - WD) / pic.Width; pic.Height =parseInt(pic.Height * scale); pic.Width = parseInt(pic.Width * scale); form.Width = pic.Width + WD; form.Height = pic.Height + HD; });
|
 1 user thanked liuxilu for this useful post.
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
对了,你可以搜索一下 .Net 截图的 dll,作 S+ 插件用
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
我倒是想要找一个那样的插件,无奈小白一个,却总要用的贴图功能,非常感谢
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
好吧,那你可以双语,这样能更好表达,也能让人用英语搜索到
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79  Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 109  Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
好的,看来双击是实现不了了,还有就是左键点击贴图后拖拽移动容易实现么?
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
Originally Posted by: liuxilu#  按叉关闭就是了 大佬,有好用的OCR手势脚本么
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74  Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
I stumbled upon an OCR dll, here I leave it to anyone who needs it. But it needs to be used online, because it uses Baidu's character recognition. https://sendit.cloud/ih92veiv9w8q
|
|
|
|
Rank: Member
Groups: Approved
Joined: 11/22/2020(UTC) Posts: 7  Was thanked: 7 time(s) in 2 post(s)
|
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 1/5/2021(UTC) Posts: 2
Thanks: 1 times
|
哈哈哈哈哈哈,笑死了,一群中国人一起讲英文。不过在国外论坛也实属正常,这个论坛的英文字真的好小一个个看的眼睛疼。。。。
Hahahahahaha, laughed to death, a group of Chinese spoke English together. However, it is normal in foreign forums. The English words in this forum are really small, and the eyes hurt each and every one of them. . . .
----From google translation
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
Originally Posted by: Rob  Added a simple display image form in version 0.3.0.5. Add this to the bottom of the Snip Screen Area script: Code:sp.DisplayImage(clip.GetImage());
Hi, Rob, May I have a question about sp.DisplayImage? It is more amazing than using Winform to show words, pictures, as I post here, it will show more snip pictures on the screen instead of changing the number of the Max Script Pool Size. And last week, I use Winform to preview the selected picture on the desktop here, then I find the selected picture in the Explorer will lose focus, but sp.DisplayImage will not. I guess sp.DisplayImage is not using Winform to show. I need to resize the Max Width of the picture in the Showbox to 500 and set the location near the mouse and no border of the Showbox in Winform and so on instead of sp.DisplayImage, and also I probably need to define the Handle of the Showbox, so how can I use the customized function to show the picture and not lose the Explorer focus?
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
I find form.ShowDialog() that can't show the Showbox on top, and still lose focus to the Explorer. Maybe this API can achieve it, and I do some try, am I right? https://docs.microsoft.c...er/nf-winuser-showwindowSet this in Load/Unload Code:if(!NativeModules.User32)
{
var IntPtrT = host.typeOf(clr.System.IntPtr);
var Int32T = host.typeOf(clr.System.Int32);
var BooleanT = host.typeOf(clr.System.Boolean);
//--------------------------------------------------------------------
// Define the type which will contain the PInvokes
// Type can still be modified until .Create() is called
//--------------------------------------------------------------------
var user32TB = sp.NativeModule().DefineType("User32", "Class,Public,SequentialLayout,Serializable");
// Define PInvoke method for GetDpiForWindow (Windows 10 1607 or greater)
user32TB.DefinePInvokeMethod("ShowWindow",
"user32.dll",
[IntPtrT,Int32T],
BooleanT,
"PreserveSig");
//--------------------------------------------------------------------
// Creates the type (which cannot be changed after) and refreshes the
// NativeModules assembly in the script engine
//--------------------------------------------------------------------
user32TB.Create();
}
Then do an action Code:var SW_SHOWNOACTIVATE = 4;
var ShowNA = sp.GetSystemMetricsByIndex(SW_SHOWNOACTIVATE);
NativeModules.User32.ShowWindow(form.Handle, ShowNA);
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
These overrides are what the S+ gesture drawing and hint forms use in their classes (along with TopMost) to not activate - I'm guessing you want to do something like that. But I'm not exactly sure at the moment how to create those overrides in script. It would be easy to do in a plugin, though. Code:protected override bool ShowWithoutActivation
{
get { return true; }
}
protected override CreateParams CreateParams
{
get
{
var cp = base.CreateParams;
cp.Style |= unchecked((int)0x80000000); // WS_POPUP
cp.ExStyle |= ( 0x00000080 // WS_EX_TOOLWINDOW
| 0x08000000 // WS_EX_NOACTIVATE
| 0x00000020 // WS_EX_TRANSPARENT
);
return cp;
}
}
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
Yes, I found it in Stackoverflow as well, and it is a pity that can't be used directly in Script. It seems that ShowWindow, SetWindowPos, SetForegroundWindow don't work in S+. Code: ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
frm.Left, frm.Top, frm.Width, frm.Height,
SWP_NOACTIVATE);
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
I am trying to make this show function as a DLL plug-in.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
Make sure to select .Net Framework Class Library - .Net Framework version 4.8.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
Thank you, Rob. I find this can work instead of overriding the ShowWithoutActivation function to show the Winform also focus the Explorer.  Code:var HWND_TOPMOST = -1;
var SWP_NOACTIVATE = 0x0010;
var SW_SHOWNOACTIVATE = 4;
NativeModules.User32.ShowWindow(form.Handle, SW_SHOWNOACTIVATE);
NativeModules.User32.SetWindowPos(form.Handle, HWND_TOPMOST,form.Left, form.Top, form.Width, form.Height,SWP_NOACTIVATE);
form.TopMost = false;
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
Originally Posted by: Rob  Make sure to select .Net Framework Class Library - .Net Framework version 4.8. There is a problem about refresh the RAM of S+. No matter use 9#Liuxiu' post code or sp.DispplayImage to display the screen snap as well as preview the selected image. After I double click to close the shown image on the screen, the RAM will stay increased by some of the screen snap. Based on Liuxiu's code, I use this to refresh the memory, but there is no result about the RAM. The RAM will decrease only if I reload the S+. So, is there a better way to recover the RAM of S+ after closing the displayed image? Code:if(!NativeModules.Kernel32)
{
var kernel32TB = sp.NativeModule().DefineType("Kernel32", "Class,Public,SequentialLayout,Serializable");
var IntPtrT = host.typeOf(clr.System.IntPtr);
var Int32T = host.typeOf(clr.System.Int32);
var BooleanT = host.typeOf(clr.System.Boolean);
kernel32TB.DefinePInvokeMethod("SetProcessWorkingSetSize",
"kernel32.dll",
[IntPtrT,Int32T,Int32T],
BooleanT,
"PreserveSig");
kernel32TB.Create();
}
On double click function Code: FlushMemory();
function FlushMemory()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
if (System.Environment.OSVersion.Platform == System.PlatformID.Win32NT)
NativeModules.Kernel32.SetProcessWorkingSetSize(sp.WindowFromPoint(currentMouseLocation, true).HWnd, -1, -1);
}
I find this post on Stackoverflow, and I don't know whether it will help. Code: protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
// Release managed resources
Logger.Verbose("Disposing SettingForm");
mySetting.Dispose();
testFtp.Dispose();
}
base.Dispose(disposing);
}
Edited by user Monday, March 21, 2022 1:27:07 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
Quote:So, is there a better way to cover the RAM of S+ after closing the displayed image? Try adding this line above c1.disconnect(); in Liuxiu code: Code:img.Dispose();
c1.disconnect();
Let me know if you notice any difference. Also, SetProcessWorkingSetSize just forces Windows to page out as much process RAM as possible, but it doesn't change anything about the usage, just pushes it to virtual memory. Which then causes it to be pulled back from disk when something needs it - so it can make it look like it's using less, but is worse for actual performance.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
Originally Posted by: Rob  Let me know if you notice any difference. It seems RAM still keeps increasing. I add this after the image shows ether Preview the selected picture or Snip screen areaNow, I temporarily use the memreduct program instead to auto clear the whole computer RAM. And also, there is another strange thing, the pic_doubleClick event will not work if I set the Mouse Events - Left Click as Enable. Code:Forms.Application.Run(form);
img.Dispose();
Code:var pic_doubleClick =
pic.DoubleClick.connect(
function (sender, args) {
form.Close();
form.Dispose();
pic.Dispose();
});
Edited by user Tuesday, March 22, 2022 4:22:01 AM(UTC)
| Reason: Not specified
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Snip Screen Area and displayed on the screen
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