📜 ⬆️ ⬇️

Quick posting of screenshots

Post screenshots quite messed up if you do everything with your hands. But a lighter scenario is also possible:
1) press Alt + Ctrl + S
2) the editor appears with a ready-made screenshot
3) I cut the picture, close the editor
4) the picture itself is loaded; image link is in the clipboard

How to do it - for those who know what bat-files are and will be able to install a couple of Python-modules.

On the desktop, create a shortcut to the screenshot.bat file (below) and configure the launch in a collapsed form so that the console does not interfere in the screenshot. The label needs to be assigned a global keyboard shortcut like Ctrl + Alt + S.
')
Then in the “Program Files” (for example) you should create 5 files , most of which are useful in and of themselves (especially clipboard.bat).

The screenshot.bat file coordinates all the work:

 @rem takes a screenshot @rem allows a userr to editt it @rem upload image onto server @rem puts the server link into clipboard SET PNG=%TEMP%\screenshot.png SET EDITOR="C:\Program Files\XnView\XnView.exe" SET UPLOADER=fp.bat c:\python26\python.exe screenshot.py %PNG% %EDITOR% %PNG% %UPLOADER% %PNG% 


The screenshot.py file - takes a screenshot and saves it to the specified file:

 # Takes a screenshot and saves it to a file specified. # Requires Python Imging Library: http://www.pythonware.com/products/pil/ import sys import ImageGrab # PIL ImageGrab.grab().save(sys.argv[1]) 


The clipboard.bat file is a simple wrapper for the script below:

python clipboard.py

File clipboard.py - copies text from the input stream to the clipboard:

 # requires pywin32 module: http://sourceforge.net/projects/pywin32/files/ import sys import win32clipboard def setClipboard(text): win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardData(win32clipboard.CF_TEXT, text) win32clipboard.CloseClipboard() text = sys.stdin.read() print text setClipboard(text) 


File fp.bat - uploads images to the server - fastpic.ru in this case:

 @echo off @rem upload images to fastpic.ru @rem requires zenden image uploader: http://code.google.com/p/image-uploader/downloads/list @rem choose the CLI version like: zenden-image-uploader-CLI-XXX-win32.7z @rem zenden works from its own directory only @rem converting all filenames into the absolute form SET FILES= :loop_begin if "%~1"=="" GOTO loop_end SET FILES=%FILES% "%~f1" shift goto loop_begin :loop_end C: cd C:\Portable\zenden-image-uploader imgupload --server fastpic.ru %FILES% | clipboard 


Unfortunately, the features of the platform platform do not allow giving a link to a 100% ready archive - you will have to download and install two modules by hand:
- pywin32
- Python Imging Library
And such an uploader of files on the most different servers:
- zenden image uploader (CLI version)

If anyone knows how to deliver Python modules in the archive and not bother people by searching, downloading and installing modules, please let them know, because it’s all easy to develop, but to transfer it to people is a problem. You can copy the whole directory with Python, of course ...

In its current form, the solution works only under Windows. If you copy the text to the clipboard and find an analog to the image uploader, it will work in other OSs.

Source: https://habr.com/ru/post/125173/


All Articles