Snipper - Window Snipping Tool

Post your working scripts, libraries and tools.
neogna2
Posts: 617
Joined: 15 Sep 2016, 15:44

Re: Snipper - Window Snipping Tool

09 Jan 2024, 17:12

FanaticGuru wrote:
09 Jan 2024, 16:09
Kind of sad there is not a rock solid Gdip v2 out there. I have searched and every one I have found has numerous conversion bugs. It is one reason I created the class of select Gdip functions used in Snipper.
Maybe the most recently updated version of v2 gdip_all.ahk is this one (updated 5 months ago)
https://github.com/buliasz/AHKv2-Gdip
https://github.com/buliasz/AHKv2-Gdip/blob/master/CHANGE.log
https://github.com/buliasz/AHKv2-Gdip/commits/master/Gdip_All.ahk
Do you know of some bugs also in that version?
User avatar
FanaticGuru
Posts: 1945
Joined: 30 Sep 2013, 22:25

Re: Snipper - Window Snipping Tool

09 Jan 2024, 19:37

neogna2 wrote:
09 Jan 2024, 17:12
FanaticGuru wrote:
09 Jan 2024, 16:09
Kind of sad there is not a rock solid Gdip v2 out there. I have searched and every one I have found has numerous conversion bugs. It is one reason I created the class of select Gdip functions used in Snipper.
Maybe the most recently updated version of v2 gdip_all.ahk is this one (updated 5 months ago)
https://github.com/buliasz/AHKv2-Gdip
https://github.com/buliasz/AHKv2-Gdip/blob/master/CHANGE.log
https://github.com/buliasz/AHKv2-Gdip/commits/master/Gdip_All.ahk
Do you know of some bugs also in that version?

I looked at buliasz Gdip when I started Snipper, it had many errors but that was before the 2023 updates. When I looked at it there was only the 2021 update.
  • 2023-07-01 v1.57-60 - bug fixes
  • 2023-04-19 v1.56 - compatible with AHK v2.0.2, Gdip_DrawLines fixed, gdip_toolbox improved, separated changelog
  • 2021-12-19 v1.55 - compatibility with AHK v1 dropped, fixed compatibility with v2.0beta3 by buliasz

It looks better now and it is probably the most error free. But it still has errors and limitations though. An example of a limitation, Gdip_SaveBitmapToFile is missing the toBase64 parameter and code. It does have the Quality NumGet and NumPut arranged correctly but with different types than I came up with. I know my types work. Not sure about theirs, probably works either way. It has VarRef errors which is common in all the libraries because of changes from v2 beta to v2 release.

Marius Șucan has a good version too but again with errors. They have pulled code from many places and integrated it together, so tends to have the most capabilities. They do not appear to be updating.

My code is a mesh of code mostly from buliasz and Marius Șucan with some fixes and converted to a class. I did pull other sources on some functions like from ImagePut by iseahound. My code is also just the bare minimum functions need for Snipper and is nowhere near a complete library.

All and all, buliasz that you mentioned above is the best source for a Gdip v2 library if you had to pick just one source. It also has had the most recent activity.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
pgeugene
Posts: 50
Joined: 27 Jun 2019, 04:36

Re: Snipper - Window Snipping Tool

06 Feb 2024, 05:34

I just included OCR extention into my Snipper main script but get below error
Attachments
snipperocrext.png
snipperocrext.png (14.08 KiB) Viewed 2672 times
User avatar
FanaticGuru
Posts: 1945
Joined: 30 Sep 2013, 22:25

Re: Snipper - Window Snipping Tool

06 Feb 2024, 14:42

pgeugene wrote:
06 Feb 2024, 05:34
I just included OCR extention into my Snipper main script but get below error
Any of the extension need to be included in a very specific way as described in the post with the extensions.

Each of these files can be added to Snipper by including them in the same directory as the Snipper script and then the appropriate #include line needs to be added or uncommented in the #INCLUDE EXTENSION section of the Snipper script.
#Include Snipper - Extension - Acrobat.ahk
#Include Snipper - Extension - Word.ahk
#Include Snipper - Extension - Outlook.ahk
#include Snipper - Extension - OCR.ahk

You save the extension code in a separate file and then #include that extension file in a specific place in the main script.

You need to carefully read the initial post and the extension post to include extensions correctly.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
pgeugene
Posts: 50
Joined: 27 Jun 2019, 04:36

Re: Snipper - Window Snipping Tool

07 Feb 2024, 04:55

FG,
Thank you for your fast reply
It is working now
There were 2 mistakes causing my problem
1) I was using Snipper Lite version
2) I have included the extention-ocr script into Auto-Execute portion of Snipper Lite script
User avatar
MrDodel
Posts: 102
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: Snipper - Window Snipping Tool

28 Feb 2024, 16:13

I found this ages ago, sorry I can't remember where, add below the CLASSES & FUNCTIONS - GUI section, to enable dark mode.

Code: Select all

; Applying dark theme for Pop-up Menu & Tray Menu.
Class DarkMode
{
    Static __New(Mode := 1) => (
        DllCall(DllCall("GetProcAddress", "ptr", DllCall("GetModuleHandle", "str", "uxtheme", "ptr"), "ptr", 135, "ptr"), "int", mode),
        DllCall(DllCall("GetProcAddress", "ptr", DllCall("GetModuleHandle", "str", "uxtheme", "ptr"), "ptr", 136, "ptr"))
    )
}
Image

Caveat: OS Dependent.
So much universe, and so little time. GNU Sir Terry.
User avatar
Jacquesyip
Posts: 8
Joined: 18 May 2023, 22:16
Contact:

Re: Snipper - Window Snipping Tool

20 Jun 2024, 22:32

I found a problem, when I click Right Button and show the menu, it couldn't execute the menu item, the guiSnips just lose focus; but when I use arrow key on keyboard, then enter it works. The situation seems couldn't get the right guiSnips.hwnd when use mouse to click menu, because of the dynamic menu, I couldn't find the right way to fix it?
anhnha
Posts: 118
Joined: 08 Aug 2018, 02:46

Re: Snipper - Window Snipping Tool

26 Jul 2024, 04:26

In the previous version, v1, Juho implemented a feature where double-clicking on a clipped window would reduce its size to a very small region. Another double-click would then restore the window to its original size.

I'm wondering if there are any skilled users who could potentially add this functionality.

Here is the link to the feature (and the full code on his website): https://youtu.be/kCmaH9fX3ZA?t=334
Spydor
Posts: 7
Joined: 22 Jan 2024, 13:07

Re: Snipper - Window Snipping Tool

04 Aug 2024, 07:48

anhnha wrote:
26 Jul 2024, 04:26
In the previous version, v1, Juho implemented a feature where double-clicking on a clipped window would reduce its size to a very small region. Another double-click would then restore the window to its original size.
Not sure if I found this as an extension, or I moved it there. Either way, this is from the Juho Lee's clipper script.

You can either add this directly in the Snipper script

Code: Select all

OnMessage(0x0203, WM_LBUTTONDBLCLK) ;double click to downsize. Double click again to resize.
WM_LBUTTONDBLCLK(wParam, lParam, msg, hwnd)
{
    
   global

   WinGetPos(, , &Temp_Width, &Temp_Height, "A")
   
   If (Temp_Width = 50 && Temp_Height = 50) {
      WinMove(, , hwnd_Width, hwnd_Height, "A")
   } else {
   hwnd_Width := Temp_Width
   hwnd_Height := Temp_Height
   WinMove(, , 50, 50, "A")
   }      
}

Or add it via extension

Code: Select all

/*--------------------------------------------------------------------------------------------------------------------
[Plugin] Shrink  (by Juho-Lee [url]https://juho-lee.com[/url])
File Name : JL_Shrink.ahk
version: 1.0
topic: https://www.autohotkey.com/boards/viewtopic.php?p=506077#p506077
Help:
how to install this plugin ?
1° download FG ScreenClipper at https://www.autohotkey.com/boards/viewtopic.php?p=506077#p506077
2° put this plugin in the Lib folder of the main script
3° Note: this is a header plugin which means that it must be loaded before the plugins that contain shortcuts
   insert this line "#Include JL_Shrink.ahk" in the INCLUDE SECTION of the main RUN script just after 
   the line that contains "#Include Fg_Context_Clip_Menu.ahk" for it to work properly

   like this:
   #Include gdip_all.ahk               
   #Include FG_Header.ahk 
   #Include FG_ScreenClip.ahk 
   #Include FG_Context_Clip_Menu.ahk
   #Include JL_Shrink.ahk            <------- insert the line entry here
*/


; DEFAULT SHORTCUT ---------------------------------------------------
;double click to downsize. Double click again to resize.

#Requires AutoHotkey v2
/* AHK v2 */
OnMessage(0x0203, WM_LBUTTONDBLCLK) ;double click to downsize. Double click again to resize.
WM_LBUTTONDBLCLK(wParam, lParam, msg, hwnd) 
{
    
   global

   WinGetPos(, , &Temp_Width, &Temp_Height, "A")
   
   If (Temp_Width = 50 && Temp_Height = 50) {
      WinMove(, , hwnd_Width, hwnd_Height, "A")
   } else {
   hwnd_Width := Temp_Width
   hwnd_Height := Temp_Height
   WinMove(, , 50, 50, "A")
   }      
}
redrum
Posts: 118
Joined: 25 Jan 2015, 22:57

Re: Snipper - Window Snipping Tool

13 Aug 2024, 16:13

I guess most people run this library as a standalone script? I had Include <Snipper\Snipper> in a hotkey script and started experiencing issues with multiple hotkeys, which usually showed symptoms of hidden windows. Wasted some time chasing these down until I removed Snipper, and my code works again. So warning to newbs like me - don't blindly include this into hotkey scripts.
Spydor
Posts: 7
Joined: 22 Jan 2024, 13:07

Re: Snipper - Window Snipping Tool

13 Aug 2024, 18:59

For something like Snipper, I'd run standalone.
n00b
Posts: 39
Joined: 24 May 2016, 16:42

Re: Snipper - Window Snipping Tool

01 Oct 2024, 04:51

sometimes the border is missing, any ideas how to fix?
Image
User avatar
FanaticGuru
Posts: 1945
Joined: 30 Sep 2013, 22:25

Re: Snipper - Window Snipping Tool

01 Oct 2024, 13:08

n00b wrote:
01 Oct 2024, 04:51
sometimes the border is missing, any ideas how to fix?

I have experienced that also. I have to reload the script and it seems to fix it, but I am not sure what is causing it. I thought it might be something with my startup or setup, but I guess it is a universal problem.

At some point I need to see if I can figure out a solution, but it is hard to test as I cannot replicate it. I basically just need to try changing things here and there and see if it helps but it is hard to know if it helped.

Now that I think about it, it always starts that way. It doesn't seem to work and then the frame stops appearing. So maybe I can start the script over and over and see if I can cause it.

I just reloaded the script over and over and was able to get it to mess up. So it messes up on reloads sometimes also which should allow me to test it some.

I will tinker with it. If anyone else has any insight, that would also be appreciated.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
n00b
Posts: 39
Joined: 24 May 2016, 16:42

Re: Snipper - Window Snipping Tool

01 Oct 2024, 15:53

Thanks, I appreciate your effort. I noticed the same, I start the script via your startup script with Windows and sometimes the borders are missing, which is annoying. Running the script again solves the issue, at least for some time. I will do more testing to see if I can find a pattern.
RockssJoke
Posts: 1
Joined: 03 Oct 2024, 14:59

Re: Snipper - Window Snipping Tool

07 Oct 2024, 11:37

Hey @FanaticGuru, first of all I wanted to thank you for this amazing tool! Really upped my workflow.

One thing that was giving me trouble was my hotstrings not working as intended. When the last modifier key was pressed, it wouldn't register, the "space" key would not add a character and wouldn't activate the hotstrings. The hotkeys worked fine tho.

I managed to fix it by removing the "SI" from #hotstring O

Anyway, just thought of leaving this here in case someone has the same problemo

Thanks once again!
jsong55
Posts: 321
Joined: 30 Mar 2021, 22:02

Re: Snipper - Window Snipping Tool

07 Oct 2024, 20:16

Somehow the context menu for the snipped stuff is not working and I wonder if it's the AHK version?

I'm on 2.1-alpha.13

Since the issue was similar to what I posted before viewtopic.php?f=82&t=131230

I've solved it the same way by changing these lines

added within the snipArea functin

Code: Select all

		guiObj.OnMessage(0x201, WM_LBUTTONDOWN)
        WM_LBUTTONDOWN(wParam, lParam, msg, hwnd)
        {
            PostMessage(0xA1, 2, , guiObj.hwnd)
        }
and commented out the global OnMessage

Code: Select all

; OnMessage(0x201, WM_LBUTTONDOWN)
User avatar
FanaticGuru
Posts: 1945
Joined: 30 Sep 2013, 22:25

Re: Snipper - Window Snipping Tool

08 Oct 2024, 12:15

jsong55 wrote:
07 Oct 2024, 20:16
Somehow the context menu for the snipped stuff is not working and I wonder if it's the AHK version?

I'm on 2.1-alpha.13

Since the issue was similar to what I posted before viewtopic.php?f=82&t=131230

I've solved it the same way by changing these lines

added within the snipArea functin

Code: Select all

		guiObj.OnMessage(0x201, WM_LBUTTONDOWN)
        WM_LBUTTONDOWN(wParam, lParam, msg, hwnd)
        {
            PostMessage(0xA1, 2, , guiObj.hwnd)
        }
and commented out the global OnMessage

Code: Select all

; OnMessage(0x201, WM_LBUTTONDOWN)

Yes, it is the alpha version. The alpha version is tinkering with OnMessage.

This guiObj.OnMessage(0x201, WM_LBUTTONDOWN) is not supported in the current version.

When alpha goes to current, it is supposed to be backwards compatible and not break anything, but not necessarily while it is in development.

Can't really publish for alpha as it is very much subject to change.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
User avatar
FanaticGuru
Posts: 1945
Joined: 30 Sep 2013, 22:25

Re: Snipper - Window Snipping Tool

29 Oct 2024, 18:02

Updated in First Post

Change Log: 2024 10 29
  • Added Critical -1 to pause OnMessage during Gui creation
The shaded area during selection drag would not display on some startups.

This was due to OnMessage callbacks having to do with Gui occurring between the time the selection Gui was created and then shown for the first time. There was probably something like 10 ms between the creating the Gui and the first time it executed Show but an OnMessage was occurring an annoying amount of the time and then the Gui was messed up until the script was reloaded as the Gui was only created one initial time and if that got screwed up then it stayed screwed up.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: Bing [Bot], gdqb521 and 26 guests