<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10269&amp;type=atom" />
	<updated>2019-08-19T17:01:18Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10269</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135774#p135774" />
			<content type="html"><![CDATA[<p>Все что нужно, это цикл, обходящий папку и команда из скрипта (пути исправить)<br /></p><div class="codebox"><pre><code>RunWait % &quot;Tesseract-OCR\tesseract.exe &quot; spt &quot; Tesseract-OCR\out -l &quot; lng</code></pre></div><p>здесь spt - переменная пути к изображению, а lng - языковой код. Данный скрипт для этого не предназначен.</p>]]></content>
			<author>
				<name><![CDATA[Krot66]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30687</uri>
			</author>
			<updated>2019-08-19T17:01:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135774#p135774</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135771#p135771" />
			<content type="html"><![CDATA[<p>Имелось в виду: распознать изображение, которое не открыто для скрипта на экране, а лежит где-то на диске. С другими хотекеями срабатывает, но в таком формате не пошло:</p><div class="codebox"><pre><code>2::St(&quot;s&quot;,&quot;D:\Screenshot_OCR\_Books_OCR\1_file.jpg&quot;,&quot;rus+eng&quot;,1)</code></pre></div><div class="codebox"><pre><code>2::St(&quot;s&quot;,&quot;_Books_OCR\1_file.jpg&quot;,&quot;rus+eng&quot;,1)</code></pre></div><p>Выводится желтая область, и после клика правой кнопкой создается пустой файл в папке &quot;Tesseract-OCR&quot;. Дано ли настроить скрипт на автоматизацию распознавания множества файлов изображений, в текстовые файлы с их названиями?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2019-08-19T16:41:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135771#p135771</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135766#p135766" />
			<content type="html"><![CDATA[<p>Нужно повесить на любую клавишу функцию вида <br />St(&quot;s&quot;,&quot;Папка\image.png&quot;,&quot;rus+eng&quot;,1)<br />где &quot;rus+eng&quot; - сочетание языков распознавания или один язык. Усложнить можно с помощью переменных (процесс, заголовок окна и пр.) из описания.<br />Еще нужна папка Tesseract-OCR из архивов на этой странице.</p>]]></content>
			<author>
				<name><![CDATA[Krot66]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30687</uri>
			</author>
			<updated>2019-08-19T15:54:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135766#p135766</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135761#p135761" />
			<content type="html"><![CDATA[<p>Как настроить последний скрипт на распознавание изображения по определенному пути, в текстовый файл с тем же именем?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2019-08-19T10:32:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135761#p135761</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89830#p89830" />
			<content type="html"><![CDATA[<p>Попробовал сделать встроенное распознавание текста на основе Tesseract-OCR, так, чтобы вместо превью картинки выводилось окно редактирования распознанного текста с последующим сохранением его по заданным правилам.<br />Результат оказался на удивление достойным: при работе с pdf и djvu среднего качества с простым текстом ошибки распознавания почти отсутствуют, и даже на старых серых, переснятых камерой книгах с волнистыми строками будет что приводить в порядок. Прилично работает с двуязычными текстами, читает компьютерные сообщения и интерфейсы, если шрифт ClearType и не слишком мелок. Можно даже сканировать вшитые субтитры в плеере и засовывать их в переводчик, если есть такая нужда.</p><p>Файл tesseract-ocr-3.02-win32-portable.zip и нужные языковые пакеты берем здесь (английский включен в дистрибутив): <a href="https://code.google.com/p/tesseract-ocr/downloads/list">https://code.google.com/p/tesseract-ocr/downloads/list</a><br />Папка Tesseract-OCR должна находиться в каталоге скрипта, языковые пакеты в папке tessdata без подкаталогов.<br />Собранный набор скрипт + Tesseract-OCR с русским и английским языковыми пакетами можно взять здесь: <a href="https://yadi.sk/d/ZEe594j4dgU5X">https://yadi.sk/d/ZEe594j4dgU5X</a></p><p>Функция сканирования теперь имеет вид:<br />St(type,f_path,lng=&quot;&quot;,save_img=&quot;&quot;)<br />Здесь<br />lng - код языка, фигурирующий в названиях архивов языковых пакетов и их файлах. Возможны сочетания вида &quot;rus+eng&quot;, но едва ли стоит использовать более двух языков за раз.<br />save_img - переменная, отвечающая за сохранение распознанных файлов.<br />Результирующий текстовый файл имеет тот же полный путь, что и изображение с заменой расширения на txt. Разница в том, что изображения автопереименовываются при совпадении имен, а распознанный текст дописывается в один файл.</p><p>Так что <br />	St(&quot;s&quot;,&quot;_Books_OCR\$file.png&quot;,&quot;rus+eng&quot;)<br />будет лепить книжные цитаты в текстовый файл, одноименный с первоисточником, не оставляя обработанных изображений.</p><p>При этом если нажатие кнопки Save или Ctrl+S в окне редактирования добавляет текст с заголовком из даты, времени и заголовка активного окна, то нажатие Add продолжает прежнюю запись. Это позволяет соединять цитаты на разрывах страниц, где распознавание регулярно глючит. Cancel отменяет сохранение текста и удаляет исходное изображение.</p><p>Исправлен баг со снятием скриншота активного окна <br /></p><div class="codebox"><pre><code>#NoEnv 
SendMode Input 
SetWorkingDir %A_ScriptDir%
#SingleInstance, force
Menu Tray, Icon, shell32.dll, 35
SetTitleMatchMode 2
SetTitleMatchMode Slow
CoordMode Mouse, Screen

; --------- Настройки ---------
color:=&quot;FFDC00&quot; ; цвет окна выделения
transp:=150 ; его прозрачность (0-255)
sel:=80 ; его начальный размер
nQuality:=90 ; качество JPEG
pr_time:=3 ; время показа превью изображений, сек
tab:=3 ; число цифр c ведущими нулями при автопереименовании
ed_path:=&quot;D:\Soft\Chasys Draw IES\Artist.exe&quot;  ; путь к графическому редактору 
ft:=22 ; размер шрифта окна редактирования распознанного текста
;------------------------------

&lt;+PrintScreen::St(&quot;f&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ; LShift+PrintScreen - скриншот всего экрана в папку процесса активного окна

#PrintScreen::St(&quot;w&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ; Win+PrintScreen - скриншот активного окна в папку процесса активного окна

&lt;^PrintScreen::St(&quot;s&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ;LCtrl+PrintScreen - скриншот выделенной области в папку процесса активного окна

$^!PrintScreen::St(&quot;s&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;,&quot;rus+eng&quot;,1) ;Ctrl+Alt+PrintScreen - распознанный текст выделенной области в папку процесса активного окна с сохранением изображения

&gt;^PrintScreen::St(&quot;s&quot;,&quot;_Books_OCR\$file.png&quot;,&quot;rus+eng&quot;) ; RCtrl+PrintScreen - распознанные цитаты электронных книг в файл, одноменный с названием источника 

&lt;^&lt;+PrintScreen::St(&quot;s&quot;,&quot;#Sites\$site\$file.png&quot;) ;LCtrl+LShift+PrintScreen - скриншот выделенной области в папку открытого сайта с именем из заголовка страницы

&gt;+PrintScreen::St(&quot;s&quot;,&quot;#Платежи\$site\$date\img.png&quot;) ;RShift+PrintScreen - скриншоты электронных платежей с сортировкой по сайтам и датам

&gt;^&gt;+PrintScreen::St(&quot;s&quot;,&quot;#Формы\[$site]-$file.png&quot;) ;RCtrl+RShift+PrintScreen - скриншоты регистрационных форм


; -----------------------------
$&lt;!PrintScreen:: ; LAlt+PrintScreen - открытие последнего скриншота или текстового файла
Run %s_path%
SplitPath s_path, s_file, , s_ext
If (s_ext=&quot;txt&quot;)
{
    WinWaitActive % s_file, , 3
    If ! Errorlevel
    {
        Sleep 500
        Send ^{End}
    }
}
return

$&gt;!PrintScreen::Run %s_folder% ; RAlt+PrintScreen - открытие папки последнего скриншота или текстового файла

;------------------------------
St(type,f_path,lng=&quot;&quot;,save_img=&quot;&quot;)
{
    global
    KeyWait Ctrl, T1
    KeyWait Shift, T1
    KeyWait Alt, T1
    KeyWait PrintScreen, T1
    type2:=type, f_path2:=f_path, lng2:=lng, save_img2:=save_img, z:=&quot;&quot;
    If (type=&quot;s&quot;) &amp;&amp; select
        goto End    
    FormatTime date, , yyyy.MM.dd
    FormatTime time, , HH.mm.ss
    WinGetActiveTitle t
    WinGet proc, ProcessName, % t
    SplitPath proc, , , , proc
    StringUpper proc, proc, T
    title:=ValidName(t)
    file:=ValidName(CleanTitle(t))
    cmd:=GetPath(t)
    SplitPath cmd, , , ,cmd
    If cmd
        cmt:=cmd
    else
    { 
        cmt:=file
        If f_path contains $cmd 
        {
                MsgBox, 262160, Ошибка, Имя открытого файла недоступно!, 1.5
                return
        }
    }
    If f_path contains $site
    {
        Clipboard:=&quot;&quot;
        Send ^{vk4C}
        Sleep 500
        Send ^{vk43}
        ClipWait 1
        RegExMatch(Clipboard,&quot;(?&lt;=//).+?(?=/)&quot;,site)
        If ! site
        {
            MsgBox, 262160, Ошибка, Адрес недоступен!, 1.5
            return
        }
    }
    If (type=&quot;s&quot;) &amp;&amp; (select=&quot;&quot;)
    {
        MouseGetPos mx, my
        Gui Destroy
        Gui Color, % color
        Gui +Lastfound +Resize AlwaysOnTop -Caption +ToolWindow -DPIScale
        WinSet Transparent, % transp
        Gui Show, x%mx% y%my% w%sel% h%sel%, selectwindow
        select:=1
        return
    }
    End:
    StringReplace tag, tag, $site, % stag
    StringReplace s_path, f_path, $date, % date
    StringReplace s_path, s_path, $time, % time
    StringReplace s_path, s_path, $proc, % proc
    StringReplace s_path, s_path, $site, % site
    StringReplace s_path, s_path, $title, % title
    StringReplace s_path, s_path, $file, % file
    StringReplace s_path, s_path, $cmd, % cmd
    StringReplace s_path, s_path, $cmt, % cmt
    StringReplace s_path, s_path, $z
    If ! Errorlevel
        z:=1
    start_path:=s_path
    s_path:=RenIfExist(s_path,tab)
    SplitPath s_path, , s_folder, s_ext, s_file
    FileCreateDir % s_folder
    SysGet, M, Monitor
    If (type=&quot;f&quot;)        
        sx:=0, sy:=0, sw:=MRight, sh:=MBottom    
    If (type=&quot;w&quot;)
        WinGetPos sx, sy, sw, sh, A
    aRect:= sx &quot;|&quot; sy &quot;|&quot; sw &quot;|&quot; sh
    pToken := Startup()
    pBitmap := BitmapFromScreen(aRect,0x40000000 | 0x00CC0020)
    SaveBitmapToFile(pBitmap, s_path, nQuality)
    DllCall(&quot;gdiplus\GdipDisposeImage&quot;, UInt, pBitmap)
    Shutdown(pToken)
    FileGetSize sz,% s_path, K
    If lng
    {
        spt=&quot;%s_path%&quot;
        RunWait % &quot;Tesseract-OCR\tesseract.exe &quot; spt &quot; Tesseract-OCR\out -l &quot; lng
        Sleep 200
        FileEncoding UTF-8-RAW
        FileRead text, Tesseract-OCR\out.txt        
        If ! save_img2
            FileDelete % s_path
        text:=RegExReplace(text,&quot;^\s+&quot;,&quot;&quot;)
        text:=RegExReplace(text,&quot;\s+$&quot;,&quot;&quot;)
        text:=RegExReplace(text,&quot;^\s+$&quot;,&quot;&quot;), r:=&quot;`r`n`r`n&quot;
        text:=RegExReplace(text,&quot;\R{2,}&quot;,r)
        SplitPath start_path, ,t_folder, , t_file
        t_path:=t_folder &quot;\&quot; t_file &quot;.txt&quot;
        s_path_del:=s_path, s_path:=t_path
        ed_w:=MRight*0.7, ed_h:=MBottom*0.7, b_w:=ed_w/4    
        Gui 2:Destroy
        Gui 2:-DPIScale
        Gui 2:Color, D7D7D7
        Gui 2:Margin , 24, 8
        Gui 2:font, s%ft%
        Gui 2:Add, Edit, vtext w%ed_w% h%ed_h%,% text
        Gui 2:font, s13
        Gui 2:Add, Button, w%b_w% y+8 h45, Canc&amp;el
        Gui 2:Add, Button, wp x+0 hp, &amp;Copy
        Gui 2:Add, Button, x+0 hp wp, &amp;Add
        Gui 2:Add, Button, wp x+0 hp, &amp;Save    
        Gui 2:Show, Center, % t_path
        Send ^{Home}
        return
    }
    If z
    {
        ToolTip Сохранено
        Sleep 600
        ToolTip
        return
    }
    SplashImage % s_path, B1 ZW800 ZH-1 ZX20 ZY20 Fm14 Fs12 CW808080 CTFFFFFF C00,{Enter} - редактирование`n{Ctrl} - сохранить как`n{Space} - переименование файла&quot;  ,% &quot;Папка:  &quot;  s_folder &quot;`nИмя:  &quot; s_file &quot;.&quot; s_ext &quot;`n&quot; sw &quot;x&quot; sh &quot;   &quot; sz &quot; KB&quot;, preview
    WinActivate preview
    Sleep % pr_time*1000
    SplashImage Off
    select:=&quot;&quot;
    return
}

#If WinActive(&quot;ahk_pid &quot; DllCall(&quot;GetCurrentProcessId&quot;))
^vk53::goto 2ButtonSave ; Ctrl+S
#If WinActive
2ButtonAdd:
caption:=&quot;&quot;
goto Add
2ButtonSave:
caption:=&quot;`n`n### &quot; A_DD &quot;.&quot; A_MM &quot;.&quot; A_YYYY &quot;  &quot; A_Hour &quot;:&quot; A_Min &quot; ###`n### &quot; title &quot; ###`n`n&quot;
Add:
Gui 2:Submit
If text
{    
    FileAppend % caption . text &quot;`n&quot;,% t_path, utf-8
    If Errorlevel
        MsgBox, 262160, , Ошибка сохранения!, 1
    else
        MsgBox 262208, ,% &quot;Сохранено!&quot;, 1
    select:=&quot;&quot;, text:=&quot;&quot;    
}
return

2ButtonCopy:
Gui 2:Submit, NoHide
Clipboard:=text
ToolTip Тект в буфере!
Sleep 600
ToolTip
return

2ButtonCancel:
2GuiEscape:
2GuiClose:
Gui 2:Destroy
FileDelete % s_path_del
select:=&quot;&quot;, text:=&quot;&quot;
return
    

#IfWinActive selectwindow ahk_class AutoHotkeyGUI
RButton::
KeyWait RButton, T1
WinGetPos sx, sy, sw, sh, selectwindow
MouseGetPos mx, my
If (mx&gt;sx &amp;&amp; mx&lt;sx+sw &amp;&amp; my&gt;sy &amp;&amp; my&lt;sy+sh)
{
    Gui Destroy
    St(type2,f_path2,lng2,save_img2)
    return
}
GuiEscape:
Gui Destroy
select:=&quot;&quot;
Sleep 200
return

#IfWinActive preview ahk_class AutoHotkey2      
Space::
SplashImage Off
Sleep 500
InputBox s_file, Переименование, Введите имя файла без расширения:, , 500, 130, , , , ,% s_file
s_file:=ValidName(s_file)
s_path_new:=RenIfExist(s_folder &quot;\&quot; s_file &quot;.&quot; s_ext,1)
FileMove % s_path, % s_path_new
s_path:=s_path_new
return

Enter::
NumpadEnter::
SplashImage Off
Run % ed_path &quot; &quot; s_path
return

Ctrl::
SplashImage Off
FileSelectFile s_path_new, S, % s_file &quot;.&quot; s_ext, Выберите место сохранения, Изображения (*.bmp; *.jpg; *.png)
FileMove % s_path, % s_path_new
s_path:=s_path_new
SplitPath s_path, , s_folder
return

Esc::SplashImage Off
#IfWinActive

;-----------------------------    
CleanTitle(t)
{
    RegExMatch(t,&quot;(?&lt;=\)\.+?(?=\.[a-zA-Z0-9]{2,4}(]| |$|\}))&quot;,title)
    If ! title
        RegExMatch(t,&quot;(?&lt;=\[).+\.[a-zA-Z0-9]{2,4}(?=])&quot;,title)
    If ! title
        RegExMatch(t,&quot;^.+\.[a-zA-Z0-9]{2,4}(?=( - | \| ))&quot;,title)
    If ! title
        RegExMatch(t,&quot;(?&lt;= - ).+\.[a-zA-Z0-9]{2,4}$&quot;,title)
    SplitPath title, , , ,title
    If ! title
        RegExMatch(t,&quot;^.+(?= - )&quot;,title)
    If ! title
        title:=t
    return title
}

GetPath(title)
{
    WinGet pr, ProcessName, % title 
    Process, Exist, % pr 
    pid := ErrorLevel
    for process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process&quot;)
    If (process.ProcessId = pid)
    cmdline := process.CommandLine
    If cmdline contains Explorer.exe
        cmdline:=&quot;&quot;
    fp:=RegExMatch(cmdline,&quot;[A-Z]:\\.*\.[a-zA-Z0-9]{2,4}&quot;,f_path,6)
    return f_path
}

RenIfExist(f_path,tab)
{
    If ! FileExist(f_path)
        return f_path
    SplitPath f_path, , dir, ext, file
    Loop % dir &quot;\&quot; file &quot;*.&quot; ext
    {
        n:=0
        RegExMatch(A_LoopFileName,&quot;(?&lt;=_)\d+?(?=\.[a-zA-Z0-9]{2,4}$)&quot;,n)
        If ! n
            n_max:=0
        If (n&gt;n_max)
            n_max:=n
    }
    SetFormat float, % &quot;0&quot; tab
    return dir &quot;\&quot; file &quot;_&quot; n_max+1.0 &quot;.&quot; ext
}

ValidName(n,r=&quot;&quot;)
{
    n:=RegExReplace(n,&quot;(:|;|,|\*|\?|\\|/|&lt;|&gt;|&quot;&quot;)&quot;,&quot; &quot;)
    n:=RegExReplace(n,&quot;\s+&quot;,&quot; &quot;)
    StringReplace n, n, |, -, All
    If r
        StringReplace n, n, % &quot; &quot;, % r, All
    return Trim(n)
}

;--------- GDI+ ----------
BitmapFromScreen(Screen=0, Raster=&quot;&quot;)
{
    if (Screen = 0)
    {
        Sysget, x, 76
        Sysget, y, 77    
        Sysget, w, 78
        Sysget, h, 79
    }
    else if (SubStr(Screen, 1, 5) = &quot;hwnd:&quot;)
    {
        Screen := SubStr(Screen, 6)
        if !WinExist( &quot;ahk_id &quot; Screen)
            return -2
        WinGetPos,,, w, h, ahk_id %Screen%
        x := y := 0
        hhdc := GetDCEx(Screen, 3)
    }
    else if (Screen&amp;1 != &quot;&quot;)
    {
        Sysget, M, Monitor, %Screen%
        x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
    }
    else
    {
        StringSplit, S, Screen, |
        x := S1, y := S2, w := S3, h := S4
    }

    if (x = &quot;&quot;) || (y = &quot;&quot;) || (w = &quot;&quot;) || (h = &quot;&quot;)
        return -1

    chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
    BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
    ReleaseDC(hhdc)
    
    pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
    SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
    return pBitmap
}

Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, Ptr, hBitmap, Ptr, Palette, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pBitmap)
    return pBitmap
}

SaveBitmapToFile(pBitmap, sOutput, Quality=75)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    SplitPath, sOutput,,, Extension
    if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
        return -1
    Extension := &quot;.&quot; Extension

    DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, &quot;uint*&quot;, nCount, &quot;uint*&quot;, nSize)
    VarSetCapacity(ci, nSize)
    DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, &quot;uint&quot;, nCount, &quot;uint&quot;, nSize, Ptr, &amp;ci)
    if !(nCount &amp;&amp; nSize)
        return -2
    
    If (A_IsUnicode){
        StrGet_Name := &quot;StrGet&quot;
        Loop, %nCount%
        {
            sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), &quot;UTF-16&quot;)
            if !InStr(sString, &quot;*&quot; Extension)
                continue
            
            pCodec := &amp;ci+idx
            break
        }
    } else {
        Loop, %nCount%
        {
            Location := NumGet(ci, 76*(A_Index-1)+44)
            nSize := DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, Location, &quot;int&quot;, -1, &quot;uint&quot;, 0, &quot;int&quot;,  0, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
            VarSetCapacity(sString, nSize)
            DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, Location, &quot;int&quot;, -1, &quot;str&quot;, sString, &quot;int&quot;, nSize, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
            if !InStr(sString, &quot;*&quot; Extension)
                continue
            
            pCodec := &amp;ci+76*(A_Index-1)
            break
        }
    }
    
    if !pCodec
        return -3

    if (Quality != 75)
    {
        Quality := (Quality &lt; 0) ? 0 : (Quality &gt; 100) ? 100 : Quality
        if Extension in .JPG,.JPEG,.JPE,.JFIF
        {
            DllCall(&quot;gdiplus\GdipGetEncoderParameterListSize&quot;, Ptr, pBitmap, Ptr, pCodec, &quot;uint*&quot;, nSize)
            VarSetCapacity(EncoderParameters, nSize, 0)
            DllCall(&quot;gdiplus\GdipGetEncoderParameterList&quot;, Ptr, pBitmap, Ptr, pCodec, &quot;uint&quot;, nSize, Ptr, &amp;EncoderParameters)
            Loop, % NumGet(EncoderParameters, &quot;UInt&quot;)      ;%
            {
                elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
                if (NumGet(EncoderParameters, elem+16, &quot;UInt&quot;) = 1) &amp;&amp; (NumGet(EncoderParameters, elem+20, &quot;UInt&quot;) = 6)
                {
                    p := elem+&amp;EncoderParameters-pad-4
                    NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, &quot;UInt&quot;)), &quot;UInt&quot;)
                    break
                }
            }      
        }
    }

    if (!A_IsUnicode)
    {
        nSize := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sOutput, &quot;int&quot;, -1, Ptr, 0, &quot;int&quot;, 0)
        VarSetCapacity(wOutput, nSize*2)
        DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sOutput, &quot;int&quot;, -1, Ptr, &amp;wOutput, &quot;int&quot;, nSize)
        VarSetCapacity(wOutput, -1)
        if !VarSetCapacity(wOutput)
            return -4
        E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, &amp;wOutput, Ptr, pCodec, &quot;uint&quot;, p ? p : 0)
    }
    else
        E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, &amp;sOutput, Ptr, pCodec, &quot;uint&quot;, p ? p : 0)
    return E ? -5 : 0
}

BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster=&quot;&quot;)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;gdi32\BitBlt&quot;
                    , Ptr, dDC
                    , &quot;int&quot;, dx
                    , &quot;int&quot;, dy
                    , &quot;int&quot;, dw
                    , &quot;int&quot;, dh
                    , Ptr, sDC
                    , &quot;int&quot;, sx
                    , &quot;int&quot;, sy
                    , &quot;uint&quot;, Raster ? Raster : 0x00CC0020)
}

CreateCompatibleDC(hdc=0)
{
   return DllCall(&quot;CreateCompatibleDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}

CreateDIBSection(w, h, hdc=&quot;&quot;, bpp=32, ByRef ppvBits=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    hdc2 := hdc ? hdc : GetDC()
    VarSetCapacity(bi, 40, 0)
    
    NumPut(w, bi, 4, &quot;uint&quot;)
    , NumPut(h, bi, 8, &quot;uint&quot;)
    , NumPut(40, bi, 0, &quot;uint&quot;)
    , NumPut(1, bi, 12, &quot;ushort&quot;)
    , NumPut(0, bi, 16, &quot;uInt&quot;)
    , NumPut(bpp, bi, 14, &quot;ushort&quot;)
    
    hbm := DllCall(&quot;CreateDIBSection&quot;
                    , Ptr, hdc2
                    , Ptr, &amp;bi
                    , &quot;uint&quot;, 0
                    , A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, ppvBits
                    , Ptr, 0
                    , &quot;uint&quot;, 0, Ptr)

    if !hdc
        ReleaseDC(hdc2)
    return hbm
}

DeleteDC(hdc)
{
   return DllCall(&quot;DeleteDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}

DeleteObject(hObject)
{
   return DllCall(&quot;DeleteObject&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hObject)
}

GetDC(hwnd=0)
{
    return DllCall(&quot;GetDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hwnd)
}

GetDCEx(hwnd, flags=0, hrgnClip=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;GetDCEx&quot;, Ptr, hwnd, Ptr, hrgnClip, &quot;int&quot;, flags)
}

ReleaseDC(hdc, hwnd=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;ReleaseDC&quot;, Ptr, hwnd, Ptr, hdc)
}

SelectObject(hdc, hgdiobj)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;SelectObject&quot;, Ptr, hdc, Ptr, hgdiobj)
}

Startup()
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    if !DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, Ptr)
        DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;gdiplus&quot;)
    VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
    DllCall(&quot;gdiplus\GdiplusStartup&quot;, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pToken, Ptr, &amp;si, Ptr, 0)
    return pToken
}

Shutdown(pToken)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, pToken)
    if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, Ptr)
        DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
    return 0
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Krot66]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30687</uri>
			</author>
			<updated>2014-12-29T07:21:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89830#p89830</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89744#p89744" />
			<content type="html"><![CDATA[<p>Совсем доработанная версия на основе Gdip_All.ahk с поддержкой 64-битных систем<br /></p><div class="codebox"><pre><code>#NoEnv 
SendMode Input 
SetWorkingDir %A_ScriptDir%
#SingleInstance, force
Menu Tray, Icon, shell32.dll, 35
SetTitleMatchMode 2
SetTitleMatchMode Slow
CoordMode Mouse, Screen

; --------- Настройки ---------
color:=&quot;FFDC00&quot; ; цвет окна выделения
transp:=150 ; его прозрачность (0-255)
sel:=80 ; его начальный размер
nQuality:=90 ; качество JPEG
pr_time:=3 ; время показа превью, сек
tab:=3 ; число цифр c ведущими нулями при автопереименовании
ed_path:=&quot;D:\Soft\Chasys Draw IES\Artist.exe&quot;  ; путь к редактору
;------------------------------

&lt;+PrintScreen::St(&quot;f&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ; LShift+PrintScreen - скриншот всего экрана в папку процесса активного окна

#PrintScreen::St(&quot;w&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ; Win+PrintScreen - скриншот активного окна в папку процесса активного окна

&lt;^PrintScreen::St(&quot;s&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ;LCtrl+PrintScreen - скриншот выделенной области в папку процесса активного окна

&gt;^PrintScreen::St(&quot;s&quot;,&quot;#Files\$file\img.png&quot;) ;RCtrl+PrintScreen - скриншот выделенной области в папку открытого файла (для цитат электронных книг и пр.)

&lt;^&lt;+PrintScreen::St(&quot;s&quot;,&quot;#Sites\$site\$file.png&quot;) ;LCtrl+LShift+PrintScreen - скриншот выделенной области в папку открытого сайта с именем из заголовка страницы

&gt;+PrintScreen::St(&quot;s&quot;,&quot;#Платежи\$site\$date\img.png&quot;) ;RShift+PrintScreen - скриншоты электронных платежей с сортировкой по сайтам и датам

&gt;^&gt;+PrintScreen::St(&quot;s&quot;,&quot;#Формы\[$site]-$file.png&quot;) ;RCtrl+RShift+PrintScreen - скриншоты регистрационных форм

; -----------------------------
&lt;!PrintScreen::Run %s_path% ; LAlt+PrintScreen - открытие последнего скриншота

&gt;!PrintScreen::Run %s_folder% ; RAlt+PrintScreen - открытие папки последнего скриншота

;------------------------------
St(type,f_path)
{
    global
    KeyWait Ctrl, T1
    KeyWait Shift, T1
    KeyWait Alt, T1
    KeyWait PrintScreen, T1
    tp:=type, fp:=f_path, z:=&quot;&quot;
    If (type=&quot;s&quot;) &amp;&amp; select
        goto End    
    FormatTime date, , yyyy.MM.dd
    FormatTime time, , HH.mm.ss
    WinGetActiveTitle t
    WinGet proc, ProcessName, % t
    SplitPath proc, , , , proc
    StringUpper proc, proc, T
    title:=ValidName(t)
    file:=ValidName(CleanTitle(t))
    cmd:=GetPath(t)
    SplitPath cmd, , , ,cmd
    If cmd
        cmt:=cmd
    else
    { 
        cmt:=file
        If f_path contains $cmd 
        {
                MsgBox, 262160, Ошибка, Имя открытого файла недоступно!, 1.5
                return
        }
    }
    If f_path contains $site
    {
        Clipboard:=&quot;&quot;
        Send ^{vk4C}
        Sleep 500
        Send ^{vk43}
        ClipWait 1
        RegExMatch(Clipboard,&quot;(?&lt;=//).+?(?=/)&quot;,site)
        If ! site
        {
            MsgBox, 262160, Ошибка, Адрес недоступен!, 1.5
            return
        }
    }
    If (type=&quot;s&quot;) &amp;&amp; (select=&quot;&quot;)
    {
        MouseGetPos mx, my
        Gui Destroy
        Gui Color, % color
        Gui +Lastfound +Resize AlwaysOnTop -Caption +ToolWindow -DPIScale
        WinSet Transparent, % transp
        Gui Show, x%mx% y%my% w%sel% h%sel%, selectwindow
        select:=1
        return
    }
    End:
    StringReplace tag, tag, $site, % stag
    StringReplace s_path, f_path, $date, % date
    StringReplace s_path, s_path, $time, % time
    StringReplace s_path, s_path, $proc, % proc
    StringReplace s_path, s_path, $site, % site
    StringReplace s_path, s_path, $title, % title
    StringReplace s_path, s_path, $file, % file
    StringReplace s_path, s_path, $cmd, % cmd
    StringReplace s_path, s_path, $cmt, % cmt
    StringReplace s_path, s_path, $z
    If ! Errorlevel
        z:=1        
    s_path:=RenIfExist(s_path,tab)
    SplitPath s_path, , s_folder, s_ext, s_file
    FileCreateDir % s_folder
    SysGet, M, Monitor
    If (type=&quot;f&quot;)        
        sx:=0, sy:=0, sw:=MRight, sh:=MBottom    
    If (type=&quot;w&quot;)
        WinGetPos, , , sw, sh,% t
    aRect:= sx &quot;|&quot; sy &quot;|&quot; sw &quot;|&quot; sh
    pToken := Startup()
    pBitmap := BitmapFromScreen(aRect,0x40000000 | 0x00CC0020)
    SaveBitmapToFile(pBitmap, s_path, nQuality)
    DllCall(&quot;gdiplus\GdipDisposeImage&quot;, UInt, pBitmap)
    Shutdown(pToken)
    FileGetSize sz,% s_path, K
    If z
    {
        ToolTip Сохранено
        Sleep 600
        ToolTip
        return
    }
    SplashImage % s_path, B1 ZW800 ZH-1 ZX20 ZY20 Fm14 Fs12 CW808080 CTFFFFFF C00,{Enter} - редактирование`n{Ctrl} - сохранить как`n{Space} - переименование файла&quot;  ,% &quot;Папка:  &quot;  s_folder &quot;`nИмя:  &quot; s_file &quot;.&quot; s_ext &quot;`n&quot; sw &quot;x&quot; sh &quot;   &quot; sz &quot; KB&quot;, preview
    WinActivate preview
    Sleep % pr_time*1000
    SplashImage Off
    select:=&quot;&quot;
    return
}

#IfWinActive selectwindow ahk_class AutoHotkeyGUI
RButton::
KeyWait RButton, T1
WinGetPos sx, sy, sw, sh, selectwindow
MouseGetPos mx, my
If (mx&gt;sx &amp;&amp; mx&lt;sx+sw &amp;&amp; my&gt;sy &amp;&amp; my&lt;sy+sh)
{
    Gui Destroy
    St(tp,fp)
    return
}
GuiEscape:
Gui Destroy
select:=&quot;&quot;
Sleep 200
return

#IfWinActive preview ahk_class AutoHotkey2      
Space::
SplashImage Off
Sleep 500
InputBox s_file, Переименование, Введите имя файла без расширения:, , 500, 130, , , , ,% s_file
s_file:=ValidName(s_file)
s_path_new:=RenIfExist(s_folder &quot;\&quot; s_file &quot;.&quot; s_ext,1)
FileMove % s_path, % s_path_new
s_path:=s_path_new
return
Enter::
NumpadEnter::
SplashImage Off
Run % ed_path &quot; &quot; s_path
return
Ctrl::
SplashImage Off
FileSelectFile s_path_new, S, % s_file &quot;.&quot; s_ext, Выберите место сохранения, Изображения (*.bmp; *.jpg; *.png)
FileMove % s_path, % s_path_new
s_path:=s_path_new
SplitPath s_path, , s_folder
return
Esc::SplashImage Off
#IfWinActive

;-----------------------------    
CleanTitle(t)
{
    RegExMatch(t,&quot;(?&lt;=\)\.+?(?=\.[a-zA-Z0-9]{2,4}(]| |$|\}))&quot;,title)
    If ! title
        RegExMatch(t,&quot;(?&lt;=\[).+\.[a-zA-Z0-9]{2,4}(?=])&quot;,title)
    If ! title
        RegExMatch(t,&quot;^.+\.[a-zA-Z0-9]{2,4}(?=( - | \| ))&quot;,title)
    If ! title
        RegExMatch(t,&quot;(?&lt;= - ).+\.[a-zA-Z0-9]{2,4}$&quot;,title)
    SplitPath title, , , ,title
    If ! title
        RegExMatch(t,&quot;^.+(?= - )&quot;,title)
    If ! title
        title:=t
    return title
}

GetPath(title)
{
    WinGet pr, ProcessName, % title 
    Process, Exist, % pr 
    pid := ErrorLevel
    for process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process&quot;)
    If (process.ProcessId = pid)
    cmdline := process.CommandLine
    If cmdline contains Explorer.exe
        cmdline:=&quot;&quot;
    fp:=RegExMatch(cmdline,&quot;[A-Z]:\\.*\.[a-zA-Z0-9]{2,4}&quot;,f_path,6)
    return f_path
}

RenIfExist(f_path,tab)
{
    If ! FileExist(f_path)
        return f_path
    SplitPath f_path, , dir, ext, file
    Loop % dir &quot;\&quot; file &quot;*.&quot; ext
    {
        n:=0
        RegExMatch(A_LoopFileName,&quot;(?&lt;=_)\d+?(?=\.[a-zA-Z0-9]{2,4}$)&quot;,n)
        If ! n
            n_max:=0
        If (n&gt;n_max)
            n_max:=n
    }
    SetFormat float, % &quot;0&quot; tab
    return dir &quot;\&quot; file &quot;_&quot; n_max+1.0 &quot;.&quot; ext
}

ValidName(n,r=&quot;&quot;)
{
    n:=RegExReplace(n,&quot;(:|;|,|\*|\?|\\|/|&lt;|&gt;|&quot;&quot;)&quot;,&quot; &quot;)
    n:=RegExReplace(n,&quot;\s+&quot;,&quot; &quot;)
    StringReplace n, n, |, -, All
    If r
        StringReplace n, n, % &quot; &quot;, % r
    return Trim(n)
}

;--------- GDI+ ----------
BitmapFromScreen(Screen=0, Raster=&quot;&quot;)
{
    if (Screen = 0)
    {
        Sysget, x, 76
        Sysget, y, 77    
        Sysget, w, 78
        Sysget, h, 79
    }
    else if (SubStr(Screen, 1, 5) = &quot;hwnd:&quot;)
    {
        Screen := SubStr(Screen, 6)
        if !WinExist( &quot;ahk_id &quot; Screen)
            return -2
        WinGetPos,,, w, h, ahk_id %Screen%
        x := y := 0
        hhdc := GetDCEx(Screen, 3)
    }
    else if (Screen&amp;1 != &quot;&quot;)
    {
        Sysget, M, Monitor, %Screen%
        x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
    }
    else
    {
        StringSplit, S, Screen, |
        x := S1, y := S2, w := S3, h := S4
    }

    if (x = &quot;&quot;) || (y = &quot;&quot;) || (w = &quot;&quot;) || (h = &quot;&quot;)
        return -1

    chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
    BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
    ReleaseDC(hhdc)
    
    pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
    SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
    return pBitmap
}

Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, Ptr, hBitmap, Ptr, Palette, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pBitmap)
    return pBitmap
}

SaveBitmapToFile(pBitmap, sOutput, Quality=75)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    SplitPath, sOutput,,, Extension
    if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
        return -1
    Extension := &quot;.&quot; Extension

    DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, &quot;uint*&quot;, nCount, &quot;uint*&quot;, nSize)
    VarSetCapacity(ci, nSize)
    DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, &quot;uint&quot;, nCount, &quot;uint&quot;, nSize, Ptr, &amp;ci)
    if !(nCount &amp;&amp; nSize)
        return -2
    
    If (A_IsUnicode){
        StrGet_Name := &quot;StrGet&quot;
        Loop, %nCount%
        {
            sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), &quot;UTF-16&quot;)
            if !InStr(sString, &quot;*&quot; Extension)
                continue
            
            pCodec := &amp;ci+idx
            break
        }
    } else {
        Loop, %nCount%
        {
            Location := NumGet(ci, 76*(A_Index-1)+44)
            nSize := DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, Location, &quot;int&quot;, -1, &quot;uint&quot;, 0, &quot;int&quot;,  0, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
            VarSetCapacity(sString, nSize)
            DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, Location, &quot;int&quot;, -1, &quot;str&quot;, sString, &quot;int&quot;, nSize, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
            if !InStr(sString, &quot;*&quot; Extension)
                continue
            
            pCodec := &amp;ci+76*(A_Index-1)
            break
        }
    }
    
    if !pCodec
        return -3

    if (Quality != 75)
    {
        Quality := (Quality &lt; 0) ? 0 : (Quality &gt; 100) ? 100 : Quality
        if Extension in .JPG,.JPEG,.JPE,.JFIF
        {
            DllCall(&quot;gdiplus\GdipGetEncoderParameterListSize&quot;, Ptr, pBitmap, Ptr, pCodec, &quot;uint*&quot;, nSize)
            VarSetCapacity(EncoderParameters, nSize, 0)
            DllCall(&quot;gdiplus\GdipGetEncoderParameterList&quot;, Ptr, pBitmap, Ptr, pCodec, &quot;uint&quot;, nSize, Ptr, &amp;EncoderParameters)
            Loop, % NumGet(EncoderParameters, &quot;UInt&quot;)      ;%
            {
                elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
                if (NumGet(EncoderParameters, elem+16, &quot;UInt&quot;) = 1) &amp;&amp; (NumGet(EncoderParameters, elem+20, &quot;UInt&quot;) = 6)
                {
                    p := elem+&amp;EncoderParameters-pad-4
                    NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, &quot;UInt&quot;)), &quot;UInt&quot;)
                    break
                }
            }      
        }
    }

    if (!A_IsUnicode)
    {
        nSize := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sOutput, &quot;int&quot;, -1, Ptr, 0, &quot;int&quot;, 0)
        VarSetCapacity(wOutput, nSize*2)
        DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sOutput, &quot;int&quot;, -1, Ptr, &amp;wOutput, &quot;int&quot;, nSize)
        VarSetCapacity(wOutput, -1)
        if !VarSetCapacity(wOutput)
            return -4
        E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, &amp;wOutput, Ptr, pCodec, &quot;uint&quot;, p ? p : 0)
    }
    else
        E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, &amp;sOutput, Ptr, pCodec, &quot;uint&quot;, p ? p : 0)
    return E ? -5 : 0
}

BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster=&quot;&quot;)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;gdi32\BitBlt&quot;
                    , Ptr, dDC
                    , &quot;int&quot;, dx
                    , &quot;int&quot;, dy
                    , &quot;int&quot;, dw
                    , &quot;int&quot;, dh
                    , Ptr, sDC
                    , &quot;int&quot;, sx
                    , &quot;int&quot;, sy
                    , &quot;uint&quot;, Raster ? Raster : 0x00CC0020)
}

CreateCompatibleDC(hdc=0)
{
   return DllCall(&quot;CreateCompatibleDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}

CreateDIBSection(w, h, hdc=&quot;&quot;, bpp=32, ByRef ppvBits=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    hdc2 := hdc ? hdc : GetDC()
    VarSetCapacity(bi, 40, 0)
    
    NumPut(w, bi, 4, &quot;uint&quot;)
    , NumPut(h, bi, 8, &quot;uint&quot;)
    , NumPut(40, bi, 0, &quot;uint&quot;)
    , NumPut(1, bi, 12, &quot;ushort&quot;)
    , NumPut(0, bi, 16, &quot;uInt&quot;)
    , NumPut(bpp, bi, 14, &quot;ushort&quot;)
    
    hbm := DllCall(&quot;CreateDIBSection&quot;
                    , Ptr, hdc2
                    , Ptr, &amp;bi
                    , &quot;uint&quot;, 0
                    , A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, ppvBits
                    , Ptr, 0
                    , &quot;uint&quot;, 0, Ptr)

    if !hdc
        ReleaseDC(hdc2)
    return hbm
}

DeleteDC(hdc)
{
   return DllCall(&quot;DeleteDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}

DeleteObject(hObject)
{
   return DllCall(&quot;DeleteObject&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hObject)
}

GetDC(hwnd=0)
{
    return DllCall(&quot;GetDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hwnd)
}

GetDCEx(hwnd, flags=0, hrgnClip=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;GetDCEx&quot;, Ptr, hwnd, Ptr, hrgnClip, &quot;int&quot;, flags)
}

ReleaseDC(hdc, hwnd=0)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;ReleaseDC&quot;, Ptr, hwnd, Ptr, hdc)
}

SelectObject(hdc, hgdiobj)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    return DllCall(&quot;SelectObject&quot;, Ptr, hdc, Ptr, hgdiobj)
}

Startup()
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    if !DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, Ptr)
        DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;gdiplus&quot;)
    VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
    DllCall(&quot;gdiplus\GdiplusStartup&quot;, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pToken, Ptr, &amp;si, Ptr, 0)
    return pToken
}

Shutdown(pToken)
{
    Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
    
    DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, pToken)
    if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, Ptr)
        DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
    return 0
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Krot66]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30687</uri>
			</author>
			<updated>2014-12-24T13:03:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89744#p89744</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89739#p89739" />
			<content type="html"><![CDATA[<p>Да, конечно. Только в скрипте названия функций изменены (чаще всего знак подчёркивания убран), чтобы не пересекались с теми, что есть в файле Gdip.ahk. Мой скрипт написан в 2010, и хоть там и сказано, что работает под AHK_L, на самом деле сработает только под 32-bit.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-24T11:29:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89739#p89739</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89738#p89738" />
			<content type="html"><![CDATA[<p>Функции взяты из вашего ScreenCatcher,a. Следует взять из Gdip_all?<br />Они позволяют такую замену?</p>]]></content>
			<author>
				<name><![CDATA[Krot66]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30687</uri>
			</author>
			<updated>2014-12-24T11:15:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89738#p89738</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89736#p89736" />
			<content type="html"><![CDATA[<p>Пользуетесь устаревшей библиотекой Gdip.ahk, написанной для AHK-basic.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-24T11:00:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89736#p89736</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89735#p89735" />
			<content type="html"><![CDATA[<p>Вариант на основе GDI+, не требующий наличия nircmd.exe<br />Поддерживаемые форматы теперь bmp, gif, jpg, png и tif<br />Появилась настройка качества jpg</p><div class="codebox"><pre><code>#NoEnv 
SendMode Input 
SetWorkingDir %A_ScriptDir%
#SingleInstance, force
Menu Tray, Icon, shell32.dll, 35
SetTitleMatchMode 2
SetTitleMatchMode Slow
CoordMode Mouse, Screen

; --------- Настройки ---------
color:=&quot;FFDC00&quot; ; цвет окна выделения
transp:=150 ; его прозрачность (0-255)
sel:=80 ; его начальный размер
nQuality:=90 ; качество JPEG
pr_time:=3 ; время показа превью, сек
tab:=3 ; число цифр c ведущими нулями при автопереименовании
ed_path:=&quot;D:\Soft\Chasys Draw IES\Artist.exe&quot;  ; путь к редактору
;------------------------------

&lt;+PrintScreen::St(&quot;f&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ; LShift+PrintScreen - скриншот всего экрана в папку процесса активного окна

#PrintScreen::St(&quot;w&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ; Win+PrintScreen - скриншот активного окна в папку процесса активного окна

&lt;^PrintScreen::St(&quot;s&quot;,&quot;#Screenshots\$proc\$date-$time_$title.png&quot;) ;LCtrl+PrintScreen - скриншот выделенной области в папку процесса активного окна

&gt;^PrintScreen::St(&quot;s&quot;,&quot;#Files\$file\img.png&quot;) ;RCtrl+PrintScreen - скриншот выделенной области в папку открытого файла (для цитат электронных книг и пр.)

&lt;^&lt;+PrintScreen::St(&quot;s&quot;,&quot;#Sites\$site\$file.png&quot;) ;LCtrl+LShift+PrintScreen - скриншот выделенной области в папку открытого сайта с именем из заголовка страницы

&gt;+PrintScreen::St(&quot;s&quot;,&quot;#Платежи\$site\$date\img.png&quot;) ;RShift+PrintScreen - скриншоты электронных платежей с сортировкой по сайтам и датам

&gt;^&gt;+PrintScreen::St(&quot;s&quot;,&quot;#Формы\[$site]-$file.png&quot;) ;RCtrl+RShift+PrintScreen - скриншоты регистрационных форм

; -----------------------------
&lt;!PrintScreen::Run %s_path% ; LAlt+PrintScreen - открытие последнего скриншота

&gt;!PrintScreen::Run %s_folder% ; RAlt+PrintScreen - открытие папки последнего скриншота

;------------------------------
St(type,f_path)
{
    global
    KeyWait Ctrl, T1
    KeyWait Shift, T1
    KeyWait Alt, T1
    KeyWait PrintScreen, T1
    tp:=type, fp:=f_path, z:=&quot;&quot;
    If (type=&quot;s&quot;) &amp;&amp; select
        goto End    
    FormatTime date, , yyyy.MM.dd
    FormatTime time, , HH.mm.ss
    WinGetActiveTitle t
    WinGet proc, ProcessName, % t
    SplitPath proc, , , , proc
    StringUpper proc, proc, T
    title:=ValidName(t)
    file:=ValidName(CleanTitle(t))
    cmd:=GetPath(t)
    SplitPath cmd, , , ,cmd
    If cmd
        cmt:=cmd
    else
    { 
        cmt:=file
        If f_path contains $cmd 
        {
                MsgBox, 262160, Ошибка, Имя открытого файла недоступно!, 1.5
                return
        }
    }
    If f_path contains $site
    {
        Clipboard:=&quot;&quot;
        Send ^{vk4C}
        Sleep 500
        Send ^{vk43}
        ClipWait 1
        RegExMatch(Clipboard,&quot;(?&lt;=//).+?(?=/)&quot;,site)
        If ! site
        {
            MsgBox, 262160, Ошибка, Адрес недоступен!, 1.5
            return
        }
    }
    If (type=&quot;s&quot;) &amp;&amp; (select=&quot;&quot;)
    {
        MouseGetPos mx, my
        Gui Destroy
        Gui Color, % color
        Gui +Lastfound +Resize AlwaysOnTop -Caption +ToolWindow -DPIScale
        WinSet Transparent, % transp
        Gui Show, x%mx% y%my% w%sel% h%sel%, selectwindow
        select:=1
        return
    }
    End:
    StringReplace tag, tag, $site, % stag
    StringReplace s_path, f_path, $date, % date
    StringReplace s_path, s_path, $time, % time
    StringReplace s_path, s_path, $proc, % proc
    StringReplace s_path, s_path, $site, % site
    StringReplace s_path, s_path, $title, % title
    StringReplace s_path, s_path, $file, % file
    StringReplace s_path, s_path, $cmd, % cmd
    StringReplace s_path, s_path, $cmt, % cmt
    StringReplace s_path, s_path, $z
    If ! Errorlevel
        z:=1        
    s_path:=RenIfExist(s_path,tab)
    SplitPath s_path, , s_folder, s_ext, s_file
    FileCreateDir % s_folder
    SysGet, M, Monitor
    If (type=&quot;f&quot;)        
        sx:=0, sy:=0, sw:=MRight, sh:=MBottom    
    If (type=&quot;w&quot;)
        WinGetPos, , , sw, sh,% t
    aRect:= sx &quot;|&quot; sy &quot;|&quot; sw &quot;|&quot; sh
    pToken := GdipStart()
    pBitmap := BitmapFromScreen(aRect, 0, 0x40000000 | 0x00CC0020)
    SaveBitmapToFile(pBitmap, s_path, nQuality)
    DllCall(&quot;gdiplus\GdipDisposeImage&quot;, UInt, pBitmap)
    GdipShutdown(pToken)
    FileGetSize sz,% s_path, K
    If z
    {
        ToolTip Сохранено
        Sleep 600
        ToolTip
        return
    }
    SplashImage % s_path, B1 ZW800 ZH-1 ZX20 ZY20 Fm14 Fs12 CW808080 CTFFFFFF C00,{Enter} - редактирование`n{Ctrl} - сохранить как`n{Space} - переименование файла&quot;  ,% &quot;Папка:  &quot;  s_folder &quot;`nИмя:  &quot; s_file &quot;.&quot; s_ext &quot;`n&quot; sw &quot;x&quot; sh &quot;   &quot; sz &quot; KB&quot;, preview
    WinActivate preview
    Sleep % pr_time*1000
    SplashImage Off
    select:=&quot;&quot;
    return
}

#IfWinActive selectwindow ahk_class AutoHotkeyGUI
RButton::
KeyWait RButton, T1
WinGetPos sx, sy, sw, sh, selectwindow
MouseGetPos mx, my
If (mx&gt;sx &amp;&amp; mx&lt;sx+sw &amp;&amp; my&gt;sy &amp;&amp; my&lt;sy+sh)
{
    Gui Destroy
    St(tp,fp)
    return
}
GuiEscape:
Gui Destroy
select:=&quot;&quot;
Sleep 200
return

#IfWinActive preview ahk_class AutoHotkey2      
Space::
SplashImage Off
Sleep 500
InputBox s_file, Переименование, Введите имя файла без расширения:, , 500, 130, , , , ,% s_file
s_file:=ValidName(s_file)
s_path_new:=RenIfExist(s_folder &quot;\&quot; s_file &quot;.&quot; s_ext,1)
FileMove % s_path, % s_path_new
s_path:=s_path_new
return
Enter::
NumpadEnter::
SplashImage Off
Run % ed_path &quot; &quot; s_path
return
Ctrl::
SplashImage Off
FileSelectFile s_path_new, S, % s_file &quot;.&quot; s_ext, Выберите место сохранения, Изображения (*.bmp; *.jpg; *.png)
FileMove % s_path, % s_path_new
s_path:=s_path_new
SplitPath s_path, , s_folder
return
Esc::SplashImage Off
#IfWinActive

;-----------------------------    
CleanTitle(t)
{
    RegExMatch(t,&quot;(?&lt;=\)\.+?(?=\.[a-zA-Z0-9]{2,4}(]| |$|\}))&quot;,title)
    If ! title
        RegExMatch(t,&quot;(?&lt;=\[).+\.[a-zA-Z0-9]{2,4}(?=])&quot;,title)
    If ! title
        RegExMatch(t,&quot;^.+\.[a-zA-Z0-9]{2,4}(?=( - | \| ))&quot;,title)
    If ! title
        RegExMatch(t,&quot;(?&lt;= - ).+\.[a-zA-Z0-9]{2,4}$&quot;,title)
    SplitPath title, , , ,title
    If ! title
        RegExMatch(t,&quot;^.+(?= - )&quot;,title)
    If ! title
        title:=t
    return title
}

GetPath(title)
{
    WinGet pr, ProcessName, % title 
    Process, Exist, % pr 
    pid := ErrorLevel
    for process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process&quot;)
    If (process.ProcessId = pid)
    cmdline := process.CommandLine
    If cmdline contains Explorer.exe
        cmdline:=&quot;&quot;
    fp:=RegExMatch(cmdline,&quot;[A-Z]:\\.*\.[a-zA-Z0-9]{2,4}&quot;,f_path,6)
    return f_path
}

RenIfExist(f_path,tab)
{
    If ! FileExist(f_path)
        return f_path
    SplitPath f_path, , dir, ext, file
    Loop % dir &quot;\&quot; file &quot;*.&quot; ext
    {
        n:=0
        RegExMatch(A_LoopFileName,&quot;(?&lt;=_)\d+?(?=\.[a-zA-Z0-9]{2,4}$)&quot;,n)
        If ! n
            n_max:=0
        If (n&gt;n_max)
            n_max:=n
    }
    SetFormat float, % &quot;0&quot; tab
    return dir &quot;\&quot; file &quot;_&quot; n_max+1.0 &quot;.&quot; ext
}

ValidName(n,r=&quot;&quot;)
{
    n:=RegExReplace(n,&quot;(:|;|,|\*|\?|\\|/|&lt;|&gt;|&quot;&quot;)&quot;,&quot; &quot;)
    n:=RegExReplace(n,&quot;\s+&quot;,&quot; &quot;)
    StringReplace n, n, |, -, All
    If r
        StringReplace n, n, % &quot; &quot;, % r
    return Trim(n)
}

;--------- GDI+ ----------
BitmapFromScreen(Screen, Cursor, Raster=&quot;&quot;)
{
    if (Screen = 0)
    {
        Sysget, x, 76
        Sysget, y, 77
        Sysget, w, 78
        Sysget, h, 79
    }
    else
    {
        StringSplit, S, Screen, |
        x := S1, y := S2, w := S3, h := S4
    }
    chdc := DllCall(&quot;CreateCompatibleDC&quot;, UInt, 0)
    VarSetCapacity(bi, 40, 0)
    NumPut(w, bi, 4), NumPut(h, bi, 8), NumPut(40, bi, 0), NumPut(1, bi, 12, &quot;ushort&quot;)
    NumPut(0, bi, 16), NumPut(32, bi, 14, &quot;ushort&quot;)
    hbm := DllCall(&quot;CreateDIBSection&quot;
        , UInt , chdc, UInt , &amp;bi, UInt , 0, &quot;uint*&quot;, 0, UInt , 0, UInt , 0)
    obm := DllCall(&quot;SelectObject&quot;, UInt, chdc, UInt, hbm)
    hhdc := DllCall(&quot;GetDC&quot;, UInt, 0)
    DllCall(&quot;gdi32\BitBlt&quot;, UInt, chdc, Int, 0, Int, 0, Int, w, Int, h
        , UInt, hhdc, Int, x, Int, y, UInt, Raster)
    DllCall(&quot;ReleaseDC&quot;, UInt, 0, UInt, hhdc)
    ;~ if Cursor
        ;~ CaptureCursor(chdc, x, y)
    DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, UInt, hbm, UInt, 0, &quot;uint*&quot;, pBitmap)
    DllCall(&quot;SelectObject&quot;, UInt, chdc, UInt, obm)
    DllCall(&quot;DeleteObject&quot;, UInt, hbm)
    DllCall(&quot;DeleteDC&quot;, UInt, hhdc)
    DllCall(&quot;DeleteDC&quot;, UInt, chdc)
    return pBitmap
}

SaveBitmapToFile(pBitmap, sOutput, Quality=75)
{
    SplitPath, sOutput,,, Extension
    if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
        return -1
    Extension := &quot;.&quot; Extension

    DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, &quot;uint*&quot;, nCount, &quot;uint*&quot;, nSize)
    VarSetCapacity(ci, nSize)
    DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, UInt, nCount, UInt, nSize, UInt, &amp;ci)
    if !(nCount &amp;&amp; nSize)
        return -2

    Loop, %nCount%
    {
        Location := NumGet(ci, 76*(A_Index-1)+44)
        if !A_IsUnicode
        {
            nSize := DllCall(&quot;WideCharToMultiByte&quot;, UInt, 0, UInt, 0
                , UInt, Location, Int, -1, UInt, 0, Int,  0, UInt, 0, UInt, 0)
            VarSetCapacity(sString, nSize)
            DllCall(&quot;WideCharToMultiByte&quot;, UInt, 0, UInt, 0, UInt, Location
                , Int, -1, Str, sString, Int, nSize, UInt, 0, UInt, 0)
            if !InStr(sString, &quot;*&quot; Extension)
                continue
        }
        else
        {
            nSize := DllCall(&quot;WideCharToMultiByte&quot;, UInt, 0, UInt, 0
                , UInt, Location, Int, -1, UInt, 0, Int,  0, UInt, 0, UInt, 0)
            sString := &quot;&quot;
            Loop, %nSize%
                sString .= Chr(NumGet(Location+0, 2*(A_Index-1), &quot;char&quot;))
            if !InStr(sString, &quot;*&quot; Extension)
                continue
        }
        pCodec := &amp;ci+76*(A_Index-1)
        break
    }
    if !pCodec
        return -3

    if (Quality != 75)
    {
        Quality := (Quality &lt; 0) ? 0 : (Quality &gt; 100) ? 100 : Quality
        if Extension in .JPG,.JPEG,.JPE,.JFIF
        {
            DllCall(&quot;gdiplus\GdipGetEncoderParameterListSize&quot;
                , UInt, pBitmap, UInt, pCodec, &quot;uint*&quot;, nSize)
            VarSetCapacity(EncoderParameters, nSize, 0)
            DllCall(&quot;gdiplus\GdipGetEncoderParameterList&quot;, UInt, pBitmap
                , UInt, pCodec, UInt, nSize, UInt, &amp;EncoderParameters)
            Loop, % NumGet(EncoderParameters)      ;%
            {
                if (NumGet(EncoderParameters, (28*(A_Index-1))+20) = 1)
                    &amp;&amp; (NumGet(EncoderParameters, (28*(A_Index-1))+24) = 6)
                {
                   p := (28*(A_Index-1))+&amp;EncoderParameters
                   NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20)))
                   break
                }
            }
       }
    }

    if !A_IsUnicode
    {
        nSize := DllCall(&quot;MultiByteToWideChar&quot;
            , UInt, 0, UInt, 0, UInt, &amp;sOutput, Int, -1, UInt, 0, Int, 0)
        VarSetCapacity(wOutput, nSize*2)
        DllCall(&quot;MultiByteToWideChar&quot;
            , UInt, 0, UInt, 0, UInt, &amp;sOutput, Int, -1, UInt, &amp;wOutput, Int, nSize)
        VarSetCapacity(wOutput, -1)
        if !VarSetCapacity(wOutput)
            return -4
        E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;
            , UInt, pBitmap, UInt, &amp;wOutput, UInt, pCodec, UInt, p ? p : 0)
    }
    else
        E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;
            , UInt, pBitmap, UInt, &amp;sOutput, UInt, pCodec, UInt, p ? p : 0)
    return E ? -5 : 0
}

GdipStart()
{
    if !DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;)
        DllCall(&quot;LoadLibrary&quot;, Str, &quot;gdiplus&quot;)
    VarSetCapacity(si, 16, 0), si := Chr(1)
    DllCall(&quot;gdiplus\GdiplusStartup&quot;, &quot;uint*&quot;, pToken, UInt, &amp;si, UInt, 0)
    return pToken
}

GdipShutdown(pToken)
{
    DllCall(&quot;gdiplus\GdiplusShutdown&quot;, UInt, pToken)
    if hModule := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;)
        DllCall(&quot;FreeLibrary&quot;, UInt, hModule)
    return 0
}



</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Krot66]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30687</uri>
			</author>
			<updated>2014-12-24T10:56:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89735#p89735</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89731#p89731" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>В принципе можно сделать так: узнаем, какой Id у картинки под мышкой, вычисляем его местоположение на странице и сохраняем. Только зачем такие сложности, когда можно сделать save as.</p></blockquote></div><p>Такой вариант подходит для стандартного сохранения картинки, но если в плане рабочем и когда стоят ограничения на загрузку картинки такие как: размер до 1000х1000 и не более чем 300kb. То нужен другой подход вырезания картинки.</p>]]></content>
			<author>
				<name><![CDATA[niceice]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32565</uri>
			</author>
			<updated>2014-12-23T20:36:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89731#p89731</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89727#p89727" />
			<content type="html"><![CDATA[<p>В принципе можно сделать так: узнаем, какой Id у картинки под мышкой, вычисляем его местоположение на странице и сохраняем. Только зачем такие сложности, когда можно сделать save as.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-12-23T18:01:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89727#p89727</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89724#p89724" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Ну, алгоритм могу подсказать: с помощью PixelGetColor по каждой из координат определить, где заканчивается и где снова начинается последовательность пикселей указанного цвета.</p></blockquote></div><p>Можно сделать отдельную тему и там обсуждать и действия и что скрипт должен выполнять. Как предложение можно сделать собственную программу (с использованием других программ) для вырезания картинок, а если точнее то программу исполнитель для программы которая вырезает.</p>]]></content>
			<author>
				<name><![CDATA[niceice]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32565</uri>
			</author>
			<updated>2014-12-23T15:40:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89724#p89724</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89723#p89723" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Krot66 пишет:</cite><blockquote><p>Потом некоторые люди вообще сторонятся истинных и правильных вещей, которых не разумеют.</p></blockquote></div><div class="quotebox"><cite>Krot66 пишет:</cite><blockquote><p>Хорошо, попробуем</p></blockquote></div><p>Попробуйте.</p><p>И можно ещё Вас попросить, ссылку на энциклопедию истинных и правильных вещей? А то мы тут без разумения истины, в основном ерундой занимаемся.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-12-23T15:38:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89723#p89723</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скрипт для снятия скриншотов с автосортировкой]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89722#p89722" />
			<content type="html"><![CDATA[<p>А когда вы скриншот делаете, картинки в оригинальном качестве извлекаются? <span style="color: green">И пожалуйста, <a href="http://forum.script-coding.com/viewtopic.php?id=6148">найдите</a> отсутствующие точки в конце предложений.</span></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-12-23T15:13:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89722#p89722</id>
		</entry>
</feed>
