Below is my version. I had more plans for it that I never implemented once I got it to the point that I started using it. For one I wanted to be able to minimize and restore clips but never got around to doing.
I use this quite a bit.
The ability to just create a clip to 'memorize' something on the screen is handy.
Clipping and pasting images then in other programs like Outlook and Word.
Code: Select all
; Screen Clipper
; Fanatic Guru
; 2017 02 25
; Version 1.00
;
; Use Mouse Drag to Clip Selection of Screen
;
;{-----------------------------------------------
;
; Credits:
;
; Learning one :=Screen Clipping
; https://autohotkey.com/boards/viewtopic.php?f=6&t=12088
; Joe Glines := added Clip, IMGUR, Email parameters to ScreenClip2Win()
; maestrith := IMGUR upload
; https://autohotkey.com/board/topic/95521-ahk-11-upload-a-screen-capture-to-imgur/
; tervon := closing of clip window
;
;}
; INITIALIZATION - ENVIROMENT
;{-----------------------------------------------
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force ; Ensures that only the last executed instance of script is running
;}
; INITIALIZATION - VARIABLES
;{-----------------------------------------------
;
;Obtain IMGUR API token value here: https://imgur.com/account/settings
Settings_Imgur_Client := "xxxxxxxxxxxxxxx"
Settings_SavePath := ".\Images - Screen Clipper\"
RelativePath(Settings_SavePath)
Settings_SavePathPDF := ".\PDF - Screen Clipper\"
RelativePath(Settings_SavePathPDF)
Settings_Ini := A_ScriptFullPath ": Screen Clipper.ini" ; Ini File in Script's Alternate Data Stream (requires NTFS)
Settings_Ini := A_ScriptDir "\Screen Clipper.ini" ; Normal Ini File
; Read Settings from Ini File
if FileExist(Settings_Ini)
{
IniRead, Settings_Imgur_Client, %Settings_Ini%, Settings, Settings_Imgur_Client, %Settings_Imgur_Client%
IniRead, Settings_SavePath, %Settings_Ini%, Settings, Settings_SavePath, %Settings_SavePath%
}
; Read Hotkeys from Script File
FileRead, Script, %A_ScriptFullPath%
Script := RegExReplace(Script, "ms`a)^\s*/\*.*?^\s*\*/\s*|^\s*\(.*?^\s*\)\s*")
Hotkeys := {}
Loop, Parse, Script, `n, `r
if RegExMatch(A_LoopField,"^\s*(.*):`:.*`;\s*(.*)",Match)
{
if !RegExMatch(Match1,"(Shift|Alt|Ctrl|Win)")
{
StringReplace, Match1, Match1, +, Shift+
StringReplace, Match1, Match1, <^>!, AltGr+
StringReplace, Match1, Match1, <, Left, All
StringReplace, Match1, Match1, >, Right, All
StringReplace, Match1, Match1, !, Alt+
StringReplace, Match1, Match1, ^, Ctrl+
StringReplace, Match1, Match1, #, Win+
}
Hotkeys.Push({"Hotkey":Match1, "Comment":Match2})
}
;}
; INITIALIZATION - GUI
;{-----------------------------------------------
;
Menu, tray, icon, %A_WinDir%\system32\mmcndmgr.dll,106
;******************Tray Menu items***********
Menu, Tray, NoStandard ;removes default options
Menu, Tray, Add , Help, Help ;can doubleclick main
Menu, Tray, Default, Help ;sets to default
Menu, Tray, Add, Settings
Menu, Tray, Add,
Menu, Tray, Add, Suspend
Menu, Tray, Add, Reload
Menu, Tray, Add, Edit
Menu, Tray, Add, Exit
Gui, +AlwaysOnTop +resize
Gui, Help:Default
Gui, Color, aqua
for Index, Element in Hotkeys
{
Gui, Font, Bold
Loop, Parse, % Element.Hotkey, +
{
If (A_LoopField = "Win")
{
Gui, Font, cBlue
xx := 40
}
else if (A_LoopField = "Alt")
{
Gui, Font, cRed
xx := 75
}
else if (A_LoopField = "Ctrl")
{
Gui, Font, cGreen
xx := 110
}
else if (A_LoopField = "Shift")
{
Gui, Font, cYellow
xx := 5
}
else
{
Gui, Font, Bold cBlack
xx := 145
}
if (A_Index = 1)
Gui, Add, Text, x%xx% , % Format("{:Ts}", A_LoopField)
else
Gui, Add, Text, x%xx% yp , % Format("{:Ts}", A_LoopField)
}
Gui, Font
Gui, Add, Text, yp x200, % Element.Comment
}
Gui, Settings:Default
Gui, Font, s10 bold
Gui, Add, Text, , Enter Path to Save Clips:
Gui, Font
Gui, Add, Edit, w500 vSettings_SavePath, %Settings_SavePath%
Gui, Add, Button, gSettings_ButtonPath yp x510 w22 h22 hwndIcon
GuiButtonIcon(Icon, "shell32.dll", 46, "s20")
Gui, Add, Text, x8, Starting ".\" indicates to start Relative Path in current folder.
Gui, Add, Text, yp+15, Each additional "." indicates to start Relative Path up one folder
Gui, Add, Text, yp+15, Example: .\Images (will store images in a subfolder of the working folder named "Images" )
Gui, Font, bold
Gui, Add, Text, yp+40, Enter Imgur Client ID:
Gui, Font
Gui, Add, Edit, yp-4 x140 w125 vSettings_Imgur_Client, %Settings_Imgur_Client%
Gui, Add, Button, yp+50 x100 w120 gSettings_ButtonSave, SAVE Settings
Gui, Add, Button, yp x300 w120 gSettings_ButtonUse Default, USE Settings
Menu, Context_Clip, add, COPY: &Clipboard, Context_Clip_Handler
Menu, Context_Clip, add, COPY: Clipboard (with Border), Context_Clip_Handler
Menu, Context_Clip, add
Menu, Context_Clip, add, COPY: &PDF, Context_Clip_Handler
Menu, Context_Clip, add, COPY: PDF (with Border), Context_Clip_Handler
Menu, Context_Clip, add, COPY: P&DF - Saved, Context_Clip_Handler
Menu, Context_Clip, add, COPY: PDF - Saved (with Border), Context_Clip_Handler
Menu, Context_Clip, add
Menu, Context_Clip, add, COPY: &File, Context_Clip_Handler
Menu, Context_Clip, add, COPY: File (with Border), Context_Clip_Handler
Menu, Context_Clip, add, COPY: File && Email, Context_Clip_Handler
Menu, Context_Clip, add, COPY: File && Imgur, Context_Clip_Handler
Menu, Context_Clip, add, COPY: File`, Imgur && Email, Context_Clip_Handler
Menu, Context_Clip, add
Menu, Context_Clip, add
Menu, Context_Clip, add, CLOSE: Clip Image, Context_Clip_Handler
;}
; BEGINNING OF AUTO-EXECUTE
;{-----------------------------------------------
;
;
;}-----------------------------------------------
; END OF AUTO-EXECUTE
; HOTKEYS
;{-----------------------------------------------
;
#Lbutton:: ; <-- Clip Image Only
SCW_ScreenClip2Win(SetClipboard:=false)
return
#^Lbutton:: ; <-- Clip Image and Copy to Clipboard
SCW_ScreenClip2Win(SetClipboard:=true)
return
#+Lbutton:: ; <-- Clip Image, Copy to Clipboard, Create PDF
SCW_ScreenClip2Win(SetClipboard:=true)
WaitReleaseAllModifiers()
Clipboard2Acrobat()
return
#!Lbutton:: ; <-- Clip Image and Save to File
Hwnd := SCW_ScreenClip2Win(SetClipboard:=false)
SCW_Win2File(Settings_SavePath,Hwnd)
return
#^!Lbutton:: ; <-- Clip Image, Copy to Clipboard, and Save to File
Hwnd := SCW_ScreenClip2Win(SetClipboard:=true)
SCW_Win2File(Settings_SavePath,Hwnd)
return
#^!+Lbutton:: ; <-- Clip Image, Copy to Clipboard, Save to File, and Create PDF
Hwnd := SCW_ScreenClip2Win(SetClipboard:=true)
SCW_Win2File(Settings_SavePath,Hwnd)
WaitReleaseAllModifiers()
Clipboard2Acrobat()
return
#IfWinActive, ScreenClipperWindow ahk_class AutoHotkeyGUI
^c:: ; <-- (Screen Clipper) : Copy Active Clip to Clipboard
SCW_Win2Clipboard()
return
+^c:: ; <-- (Screen Clipper) : Copy Active Clip to Clipboard with Border
SCW_Win2Clipboard(0)
return
^s:: ; <-- (Screen Clipper) : Save Active Clip to File
SCW_Win2File(Settings_SavePath)
return
+^s:: ; <-- (Screen Clipper) : Save Active Clip to File with Border
SCW_Win2File(Settings_SavePath,,0)
return
#e:: ; <-- (Screen Clipper) : Save Active Clip to File and Email
File := SCW_Win2File(Settings_SavePath)
Email_AttachFile(File)
return
#i:: ; <-- (Screen Clipper) : Save Active Clip to File and Post to IMGUR
File := SCW_Win2File(Settings_SavePath)
URL := Imgur_Post(File, Settings_Imgur_Client)
Clipboard := URL
return
#^i:: ; <-- (Screen Clipper) : Save Active Clip to File, Post to IMGUR and Email
File := SCW_Win2File(Settings_SavePath)
URL := Imgur_Post(File, Settings_Imgur_Client)
Email_AttachFile(File, URL)
return
RButton:: ; <-- (Screen Clipper) : Single for Menu, Double to Close Active Clip
KeyWait, RButton ; wait release
KeyWait, RButton, D T0.2 ; and pressed again within 0.2 seconds
if ErrorLevel ; timed-out (only a single press)
Menu, Context_Clip, Show
else
WinClose, A
return
Esc:: ; <-- (Screen Clipper) : Close Active Clip
WinClose, A
return
#IfWinActive
;}
; SUBROUTINES
;{-----------------------------------------------
;
;}
; SUBROUTINES - GUI
;{-----------------------------------------------
;
Settings_ButtonPath:
FileSelectFolder, Settings_SavePath, *%Settings_SavePath%, 3, Select Folder for Saved Image
GuiControl, Settings:, Settings_SavePath, %Settings_SavePath%\
return
Settings_ButtonUSE:
Gui, Settings:Submit
return
Settings_ButtonSAVE:
Gui, Settings:Submit
IniWrite, %Settings_Imgur_Client%, %Settings_Ini%, Settings, Settings_Imgur_Client
IniWrite, %Settings_SavePath%, %Settings_Ini%, Settings, Settings_SavePath
return
HelpGuiEscape:
HelpGuiClose:
Gui, Help:Hide
Return
;~ Context Menu for Clip Window
Context_Clip_Handler:
if (A_ThisMenuItemPos = 16) ; Close Clip Image
WinClose, A
Sleep 350 ; Context Menu selection fades out and needs time to disappear before Clipping
if (A_ThisMenuItemPos = 1) ; Clipboard
SCW_Win2Clipboard()
else if (A_ThisMenuItemPos = 2) ; Clipboard with Border
SCW_Win2Clipboard(0)
else if (A_ThisMenuItemPos = 4) ; Clipboard to PDF
{
SCW_Win2Clipboard()
Clipboard2Acrobat()
}
else if (A_ThisMenuItemPos = 5) ; Clipboard with Border to PDF
{
SCW_Win2Clipboard(0)
Clipboard2Acrobat()
}
else if (A_ThisMenuItemPos = 6) ; Clipboard to PDF and Save
{
SCW_Win2Clipboard()
Clipboard2Acrobat(Settings_SavePathPDF)
}
else if (A_ThisMenuItemPos = 7) ; Clipboard with Border to PDF and Save
{
SCW_Win2Clipboard(0)
Clipboard2Acrobat(Settings_SavePathPDF)
}
else if (A_ThisMenuItemPos = 9) ; File
SCW_Win2File(Settings_SavePath)
else if (A_ThisMenuItemPos = 10) ; File with Border
SCW_Win2File(Settings_SavePath,,0)
else if (A_ThisMenuItemPos = 11) ; File & Email
{
File := SCW_Win2File(Settings_SavePath)
Email_AttachFile(File)
}
else if (A_ThisMenuItemPos = 12) ; File & Imgur
{
File := SCW_Win2File(Settings_SavePath)
URL := Imgur_Post(File, Settings_Imgur_Client)
Clipboard := URL
}
else if (A_ThisMenuItemPos = 13) ; File, Imgur & Email
{
File := SCW_Win2File(Settings_SavePath)
URL := Imgur_Post(File, Settings_Imgur_Client)
Email_AttachFile(File, URL)
}
;~ MsgBox You selected %A_ThisMenuItemPos% - %A_ThisMenuItem% from the menu %A_ThisMenu%.
return
;~ Tray Menu
Help:
Gui,Help:Show, , Help
return
Settings:
Gui,Settings:Show, , Settings
return
Suspend:
Suspend
Return
Reload:
Reload
Return
Edit:
Edit
Return
Exit:
ExitApp
Return
;}
; FUNCTIONS
;{-----------------------------------------------
;
;{vvvvv SCW Functions vvvvv
/*
[module/script] ScreenClip2Win
Author: Learning one
Thanks: Tic, HotKeyIt
Creates always on top layered windows from screen clippings. Click in upper right corner to close win. Click and drag to move it.
Uses Gdip.ahk by Tic.
#Include ScreenClip2Win.ahk ; by Learning one
;=== Short documentation ===
SCW_ScreenClip2Win(SetClipboard:=0) ; creates always on top window from screen clipping. Click and drag to select area.
SCW_DestroyAllClipWins() ; destroys all screen clipping windows.
SCW_Win2Clipboard(DeleteBorders:=1) ; copies window to clipboard. By default, removes borders. To keep borders, specify "SCW_Win2Clipboard(0)"
SCW_SetUp(Options="") ; you can change some default options in Auto-execute part of script. Syntax: "<option>.<value>"
StartAfter - module will start to consume GUIs for screen clipping windows after specified GUI number. Default: 80
MaxGuis - maximum number of screen clipping windows. Default: 6
BorderAColor - Default: ff6666ff (ARGB format)
BorderBColor - Default: ffffffff (ARGB format)
DrawCloseButton - on/off draw "Close Button" on screen clipping windows. Default: 0 (off)
AutoMonitorWM_LBUTTONDOWN - on/off automatic monitoring of WM_LBUTTONDOWN message. Default: 1 (on)
SelColor - selection color. Default: Yellow
SelTrans - selection transparency. Default: 80
Example: SCW_SetUp("MaxGuis.30 StartAfter.50 BorderAColor.ff000000 BorderBColor.ffffff00")
;=== Avoid OnMessage(0x201, "WM_LBUTTONDOWN") collision example===
Gui, Show, w200 h200
SCW_SetUp("AutoMonitorWM_LBUTTONDOWN.0") ; turn off auto monitoring WM_LBUTTONDOWN
OnMessage(0x201, "WM_LBUTTONDOWN") ; manualy monitor WM_LBUTTONDOWN
Return
^Lbutton::SCW_ScreenClip2Win() ; click & drag
Esc::ExitApp
#Include Gdip.ahk ; by Tic
#Include ScreenClip2Win.ahk ; by Learning one
WM_LBUTTONDOWN() {
if SCW_LBUTTONDOWN() ; LBUTTONDOWN on module's screen clipping windows - isolate - it's module's buissines
return
else ; LBUTTONDOWN on other windows created by script
MsgBox,,, You clicked on script's window not created by this module,1
}
*/
SCW_Version()
{
return 1.02
}
SCW_DestroyAllClipWins()
{
MaxGuis := SCW_Reg("MaxGuis"), StartAfter := SCW_Reg("StartAfter")
Loop, %MaxGuis%
{
StartAfter++
Gui %StartAfter%: Destroy
}
}
SCW_SetUp(Options="")
{
if !(Options = "")
{
Loop, Parse, Options, %A_Space%
{
Field := A_LoopField
DotPos := InStr(Field, ".")
if (DotPos = 0)
Continue
var := SubStr(Field, 1, DotPos-1)
val := SubStr(Field, DotPos+1)
if var in StartAfter,MaxGuis,AutoMonitorWM_LBUTTONDOWN,DrawCloseButton,BorderAColor,BorderBColor,SelColor,SelTrans
%var% := val
}
}
SCW_Default(StartAfter,80), SCW_Default(MaxGuis,6)
SCW_Default(AutoMonitorWM_LBUTTONDOWN,1), SCW_Default(DrawCloseButton,0)
SCW_Default(BorderAColor,"ff6666ff"), SCW_Default(BorderBColor,"ffffffff")
SCW_Default(SelColor,"Yellow"), SCW_Default(SelTrans,80)
SCW_Reg("MaxGuis", MaxGuis), SCW_Reg("StartAfter", StartAfter), SCW_Reg("DrawCloseButton", DrawCloseButton)
SCW_Reg("BorderAColor", BorderAColor), SCW_Reg("BorderBColor", BorderBColor)
SCW_Reg("SelColor", SelColor), SCW_Reg("SelTrans",SelTrans)
SCW_Reg("WasSetUp", 1)
if AutoMonitorWM_LBUTTONDOWN
OnMessage(0x201, "SCW_LBUTTONDOWN")
}
SCW_ScreenClip2Win(SetClipboard:=0)
{
static c
if !(SCW_Reg("WasSetUp"))
SCW_SetUp()
StartAfter := SCW_Reg("StartAfter"), MaxGuis := SCW_Reg("MaxGuis"), SelColor := SCW_Reg("SelColor"), SelTrans := SCW_Reg("SelTrans")
c++
if (c > MaxGuis)
c := 1
GuiNum := StartAfter + c
Area := SCW_SelectAreaMod("g" GuiNum " c" SelColor " t" SelTrans)
StringSplit, v, Area, |
if (v3 < 10 and v4 < 10) ; too small area
return
pToken := Gdip_Startup()
if pToken =
{
MsgBox, 64, GDI+ error, GDI+ failed to start. Please ensure you have GDI+ on your system.
return
}
Sleep, 100
pBitmap := Gdip_BitmapFromScreen(Area)
if (SetClipboard=1)
Gdip_SetBitmapToClipboard(pBitmap)
hwnd := SCW_CreateLayeredWinMod(GuiNum,pBitmap,v1,v2, SCW_Reg("DrawCloseButton"))
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown("pToken")
return hwnd
}
SCW_SelectAreaMod(Options="")
{
CoordMode, Mouse, Screen
MouseGetPos, MX, MY
loop, parse, Options, %A_Space%
{
Field := A_LoopField
FirstChar := SubStr(Field,1,1)
if FirstChar contains c,t,g,m
{
StringTrimLeft, Field, Field, 1
%FirstChar% := Field
}
}
c := (c = "") ? "Blue" : c, t := (t = "") ? "50" : t, g := (g = "") ? "99" : g
Gui %g%: Destroy
Gui %g%: +AlwaysOnTop -caption +Border +ToolWindow +LastFound
WinSet, Transparent, %t%
Gui %g%: Color, %c%
Hotkey := RegExReplace(A_ThisHotkey,"^(\w* & |\W*)")
While, (GetKeyState(Hotkey, "p"))
{
Sleep, 10
MouseGetPos, MXend, MYend
w := abs(MX - MXend), h := abs(MY - MYend)
X := (MX < MXend) ? MX : MXend
Y := (MY < MYend) ? MY : MYend
Gui %g%: Show, x%X% y%Y% w%w% h%h% NA
}
Gui %g%: Destroy
MouseGetPos, MXend, MYend
If ( MX > MXend )
temp := MX, MX := MXend, MXend := temp
If ( MY > MYend )
temp := MY, MY := MYend, MYend := temp
Return MX "|" MY "|" w "|" h
}
SCW_CreateLayeredWinMod(GuiNum,pBitmap,x,y,DrawCloseButton=0)
{
static CloseButton := 16
BorderAColor := SCW_Reg("BorderAColor"), BorderBColor := SCW_Reg("BorderBColor")
Gui %GuiNum%: -Caption +E0x80000 +LastFound +ToolWindow +AlwaysOnTop +OwnDialogs
Gui %GuiNum%: Show, Na, ScreenClipperWindow
hwnd := WinExist()
Width := Gdip_GetImageWidth(pBitmap), Height := Gdip_GetImageHeight(pBitmap)
hbm := CreateDIBSection(Width+6, Height+6), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc), Gdip_SetSmoothingMode(G, 4), Gdip_SetInterpolationMode(G, 7)
Gdip_DrawImage(G, pBitmap, 3, 3, Width, Height)
Gdip_DisposeImage(pBitmap)
pPen1 := Gdip_CreatePen("0x" BorderAColor, 3), pPen2 := Gdip_CreatePen("0x" BorderBColor, 1)
if DrawCloseButton
{
Gdip_DrawRectangle(G, pPen1, 1+Width-CloseButton+3, 1, CloseButton, CloseButton)
Gdip_DrawRectangle(G, pPen2, 1+Width-CloseButton+3, 1, CloseButton, CloseButton)
}
Gdip_DrawRectangle(G, pPen1, 1, 1, Width+3, Height+3)
Gdip_DrawRectangle(G, pPen2, 1, 1, Width+3, Height+3)
Gdip_DeletePen(pPen1), Gdip_DeletePen(pPen2)
UpdateLayeredWindow(hwnd, hdc, x-3, y-3, Width+6, Height+6)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G)
SCW_Reg("G" GuiNum "#HWND", hwnd)
SCW_Reg("G" GuiNum "#XClose", Width+6-CloseButton)
SCW_Reg("G" GuiNum "#YClose", CloseButton)
Return hwnd
}
SCW_LBUTTONDOWN()
{
MouseGetPos,,, WinUMID
WinGetTitle, Title, ahk_id %WinUMID%
if Title = ScreenClipperWindow
{
PostMessage, 0xA1, 2,,, ahk_id %WinUMID%
KeyWait, Lbutton
CoordMode, mouse, Relative
MouseGetPos, x,y
XClose := SCW_Reg("G" A_Gui "#XClose"), YClose := SCW_Reg("G" A_Gui "#YClose")
if (x > XClose and y < YClose)
Gui %A_Gui%: Destroy
return 1 ; confirm that click was on module's screen clipping windows
}
}
SCW_Reg(variable, value="")
{
static
if (value = "")
return kxucfp%variable%pqzmdk
else
kxucfp%variable%pqzmdk = %value%
}
SCW_Default(ByRef Variable,DefaultValue)
{
if (Variable="")
Variable := DefaultValue
}
SCW_Win2Clipboard(DeleteBorders:=1, Hwnd := "")
{
/* ; does not work for layered windows
ActiveWinID := WinExist("A")
pBitmap := Gdip_BitmapFromHWND(ActiveWinID)
Gdip_SetBitmapToClipboard(pBitmap)
*/
if !Hwnd
WinGet, Hwnd, ID, A
WinGetPos, X, Y, W, H, ahk_id %Hwnd%
if DeleteBorders
X+=3, Y+=3, W-=6, H-=6
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen(X "|" Y "|" W "|" H)
Gdip_SetBitmapToClipboard(pBitmap)
Gdip_Shutdown("pToken")
}
SCW_Win2File(SavePath,Hwnd := "",DeleteBorders:=1)
{
IfNotExist, %SavePath%
FileCreateDir, %SavePath%
if !Hwnd
WinGet, Hwnd, ID, A
WinGetPos, X, Y, W, H, ahk_id %Hwnd%
if DeleteBorders
X+=3, Y+=3, W-=6, H-=6
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromScreen(X "|" Y "|" W "|" H)
FormatTime, TimeStamp ,, yyyy_MM_dd @ HH_mm_ss
FileName := TimeStamp " (" w "x" h ").PNG"
Gdip_SaveBitmapToFile(pBitmap, SavePath FileName)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown("pToken")
return SavePath FileName
}
;}^^^^^ SCW Functions ^^^^^
Email_AttachFile(File, URL:="")
{
try
IsObject(MailItem := ComObjActive("Outlook.Application").CreateItem(olMailItem:=0)) ; Get the Outlook application object if Outlook is open
catch
MailItem := ComObjCreate("Outlook.Application").CreateItem(olMailItem:=0) ; Create if Outlook is not open
MailItem.BodyFormat := (olFormatHTML:=2)
;~ MailItem.TO :="somejunkemail@yahoo.com"
;~ MailItem.CC :="somejunkemail@yahoo.com"
FormatTime, TimeStamp , % RegExReplace(File, "^.*\\|[_ @]|\(.*$"), dddd MMMM d, yyyy h:mm:ss tt
MailItem.Subject :="Screen shot taken : " (TimeStamp) ; Subject line of email
HTMLBody := "
<H2 style='BACKGROUND-COLOR: red'><br></H2>
<HTML>Please find attached the screenshot taken on " TimeStamp "<br><br>"
if URL
HTMLBody .= "
<span style='color:black'>The image can also be accessd here: <a href=""" (URL) """>" (URL) "</a> <br><br></span>"
HTMLBody .= "</HTML>"
MailItem.HTMLBody := HTMLBody
MailItem.Attachments.Add(File)
MailItem.Display
}
Imgur_Post(File, Client)
{
Http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Img := ComObjCreate("WIA.ImageFile")
Img.LoadFile(File)
/* ; Converts Image to JPG
IP := ComObjCreate("WIA.ImageProcess")
IP.Filters.Add(IP.FilterInfos("Crop").FilterID)
IP.Filters.Add(IP.FilterInfos("Convert").FilterID)
IP.Filters(2).Properties("FormatID").Value:="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
IP.Filters(2).Properties("Quality").Value:=85
Img := IP.Apply(Img)
*/
Data := Img.FileData.BinaryData
Http.Open("POST","https://api.imgur.com/3/upload")
Http.SetRequestHeader("Authorization","Client-ID " Client)
Http.SetRequestHeader("Content-Length",size)
Http.Send(Data)
Codes:=Http.ResponseText
split=":"
RegExMatch(Codes, "U)link" split "(.*)" Chr(34), Match)
URL:=RegExReplace(Match1, "\\")
Return URL
}
Clipboard2Acrobat(SavePathPDF:="") ; Adobe Acrobat must be installed
{
App := ComObjCreate("AcroExch.App")
App.Show()
App.MenuItemExecute("ImageConversion:Clipboard")
if SavePathPDF
{
IfNotExist, %SavePathPDF%
FileCreateDir, %SavePathPDF%
FormatTime, TimeStamp ,, yyyy_MM_dd @ HH_mm_ss
FileName := TimeStamp ".PDF"
AVDoc := App.GetActiveDoc()
PVDoc := AVDoc.GetPDDoc()
PDSaveIncremental := 0x0000 ;/* write changes only */
PDSaveFull := 0x0001 ;/* write entire file */
PDSaveCopy := 0x0002 ;/* write copy w/o affecting current state */
PDSaveLinearized := 0x0004 ;/* write the file linearized for */
PDSaveBinaryOK := 0x0010 ;/* OK to store binary in file */
PDSaveCollectGarbage := 0x0020 ;/* perform garbage collection on */
PVDoc.save(PDSaveFull|PDSaveLinearized, SavePathPDF FileName)
}
}
RelativePath(ByRef Path)
{
RegExMatch(Path,"^(\.*)\\",M), R := StrLen(M1)
if (R=1)
Path := A_ScriptDir SubStr(Path,R+1)
else if (R>1)
Path := SubStr(A_ScriptDir,1,InStr(A_ScriptDir,"\",,0,R-1)) SubStr(Path,R+2)
return Path
}
GuiDefaultFont() { ; by SKAN (modified by just me)
VarSetCapacity(LF, szLF := 28 + (A_IsUnicode ? 64 : 32), 0) ; LOGFONT structure
If DllCall("GetObject", "Ptr", DllCall("GetStockObject", "Int", 17, "Ptr"), "Int", szLF, "Ptr", &LF)
Return {Name: StrGet(&LF + 28, 32), Size: Round(Abs(NumGet(LF, 0, "Int")) * (72 / A_ScreenDPI), 1)
, Weight: NumGet(LF, 16, "Int"), Quality: NumGet(LF, 26, "UChar")}
Return False
}
WaitReleaseAllModifiers()
{
List := "LWin|RWin|LAlt|RAlt|LControl|RControl|LShift|RShift"
while !Done
{
Done := true
Loop Parse, list, |
if (GetKeyState(A_LoopField))
Done := false
Sleep 50
}
}