Yes, the reason is you have actually named the file Gdip.ahk.ahk. And you most likley think it's not named that because in File Explorer, you have the default setting enabled where it hides file extensions for known file types, so it displays .ahk files without the .ahk extension. So to make it look like it has one in File Explorer, you added .ahk to the file name that already had a .ahk extension. You should disable the terrible "Hide extensions for known file types" option in the "View" tab of the "Folder Options" window so you can see what files are actually named.feeko wrote: ↑ Yeah, I have that included at the top of my script. Any reason why my file extension has 2 .ahk? I don't think it worked if I didn't have it.
Code: Select all
#include C:\Users\Owner\Documents\Other\AutoHotkey Scripts\Gdip.ahk.ahk
Create Screenshot specific area Topic is solved
Re: Create Screenshot specific area
Re: Create Screenshot specific area
Why doesn't this work:
Code: Select all
^+PrintScreen::
WinGetPos, X, Y, W, H, A
Clipboard := "(X" | "Y"| "W" | "H)"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen%Clipboard%
Gdip_SaveBitmapToFile(snap, OutFile, 100)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
Re: Create Screenshot specific area
@LAPIII -- The syntax is wrong on this line:
You put quotes around what would be the variable names, making them text, and you didn't put quotes around the pipe characters, making them bitwise OR operators instead of pipe characters. See Expressions to learn more. Should be:
Also this is not correct for an expression or a function call (missing the parentheses and shouldn't have % signs):
Should be:
Also, why use the clipboard as your variable? There seems to be no reason to use that rather than a regular variable.
Code: Select all
Clipboard := "(X" | "Y"| "W" | "H)"
Code: Select all
Clipboard := "(" X "|" Y "|" W "|" H ")"
Also this is not correct for an expression or a function call (missing the parentheses and shouldn't have % signs):
Code: Select all
snap := Gdip_BitmapFromScreen%Clipboard%
Code: Select all
snap := Gdip_BitmapFromScreen(Clipboard)
Also, why use the clipboard as your variable? There seems to be no reason to use that rather than a regular variable.
Re: Create Screenshot specific area
Perfect:
Code: Select all
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
^+PrintScreen::
WinGetPos, X, Y, W, H, A
Clipboard := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Clipboard)
Gdip_SaveBitmapToFile(snap, OutFile, 100)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
Re: Create Screenshot specific area
More perfect:
Again, there is no reason for using the Clipboard as a variable here.
Code: Select all
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
^+PrintScreen::
WinGetPos, X, Y, W, H, A
Area := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Area)
Gdip_SaveBitmapToFile(snap, OutFile, 100)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
Again, there is no reason for using the Clipboard as a variable here.
Re: Create Screenshot specific area
By the way, the 100 in this line doesn't do anything since your file is a png file:
Defining the quality of the image only applies to jpg files. Lossless files like png and bmp are always 100% quality.
Code: Select all
Gdip_SaveBitmapToFile(snap, OutFile, 100)
Re: Create Screenshot specific area
If I attach this to the script:
Using Area doesn't work and with Clipboard, sometimes I've got to press the hotkey twice, I get:
Code: Select all
ToolTipFont("s14", "Comic Sans MS")
ToolTipColor("green", "white")
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, -500
return
RemoveToolTip:
ToolTip
return
; ToolTipOpt v1.004
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
Using Area doesn't work and with Clipboard, sometimes I've got to press the hotkey twice, I get:
Re: Create Screenshot specific area
What do you mean by attaching that to the script? You mean you just pasted one script on the end of the other with no attention to the auto-execute sections of each?
Re: Create Screenshot specific area
Yeah, could you help:
Code: Select all
#SingleInstance, Force
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
^+PrintScreen::
WinGetPos, X, Y, W, H, A
Clipboard := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Clipboard)
Gdip_SaveBitmapToFile(snap, OutFile)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
ToolTipFont("s14", "Comic Sans MS")
ToolTipColor("green", "white")
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, -500
return
RemoveToolTip:
ToolTip
return
; ToolTipOpt v1.004
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
Re: Create Screenshot specific area
Next time I'd rather have you learn and apply the concept that I tell you is the issue.
Code: Select all
#SingleInstance, Force
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
ToolTipFont("s14", "Comic Sans MS")
ToolTipColor("green", "white")
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, -500
return
^+PrintScreen::
WinGetPos, X, Y, W, H, A
Clipboard := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Clipboard)
Gdip_SaveBitmapToFile(snap, OutFile)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
RemoveToolTip:
ToolTip
return
; ToolTipOpt v1.004
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
Re: Create Screenshot specific area
Same error and the tooltip only shows when the script is ran.
Re: Create Screenshot specific area
The error was because you were messing with the clipboard. You need to use another variable, like Area, and it needs to either be passed as a parameter to the function or declared as global like I did. I moved the ToolTip into the hotkey subroutine because I assume that's what you wanted when you said it appeared only once. You can't just put two scripts together and it expect it to know you what you had in mind for when it should appear.
Code: Select all
#SingleInstance, Force
#Include <GDIP_All> ; C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
ToolTipFont("s14", "Comic Sans MS")
ToolTipColor("green", "white")
return
^+PrintScreen::
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, -500
WinGetPos, X, Y, W, H, A
Clipboard := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Clipboard)
Gdip_SaveBitmapToFile(snap, OutFile)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
RemoveToolTip:
ToolTip
return
; ToolTipOpt v1.004
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
Re: Create Screenshot specific area
Nothing happens when I press the hotkey:
Code: Select all
#SingleInstance, Force
#Include <GDIP_All> ; C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
ToolTipFont("s14", "Comic Sans MS")
ToolTipColor("green", "white")
return
^+PrintScreen::
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, -500
WinGetPos, X, Y, W, H, A
Area := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
Screenshot(OutFile)
{
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Area)
Gdip_SaveBitmapToFile(snap, OutFile)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
RemoveToolTip:
ToolTip
return
; ToolTipOpt v1.004
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
Re: Create Screenshot specific area
When I press it it shows the tooltip (in the location you specified, relative to the active window) and saves a screenshot of the active window in the script directory. Are you sure you saved the updated script file and closed any other version of it?
Re: Create Screenshot specific area
You probably need to change this line:
…back to this:
I don’t think it would run without errors if you didn’t already change it, though.
Code: Select all
#Include <GDIP_All> ; C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
Code: Select all
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
I don’t think it would run without errors if you didn’t already change it, though.
Re: Create Screenshot specific area
It does work, whether <GDIP_All> or the path, but I still get the error.
Re: Create Screenshot specific area
And you’re using the version above, that does not use the clipboard as a variable as you posted in the other thread?
Re: Create Screenshot specific area
Gotta share the script with your fix Boiler:
Code: Select all
#SingleInstance, Force
#Include C:\Users\LPIII\Documents\AutoHotkey\Lib\GDIP_All.ahk
SetWorkingDir, C:\Users\LPIII\Pictures\Captures
ToolTipFont("s14", "Comic Sans MS")
ToolTipColor("green", "white")
return
^+PrintScreen::
ToolTip, Active Window Screenshot, 1525, 0
SetTimer, RemoveToolTip, -500
WinGetPos, X, Y, W, H, A
Area := "(" X "|" Y "|" W "|" H ")"
FormatTime, DateTime,, d-M-yy h-mm-ss tt
WinGetActiveTitle, Title
Screenshot(Title "_" DateTime ".png")
return
Screenshot(OutFile)
{
global Area
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen(Area)
Gdip_SaveBitmapToFile(snap, OutFile)
Gdip_DisposeImage(snap) ;Dispose of the bitmap to free memory.
Gdip_Shutdown( pToken ) ;Turn off gdip
return
}
RemoveToolTip:
ToolTip
return
; ToolTipOpt v1.004
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
Re: Create Screenshot specific area
Is it possible to add a clipboard snippet to the saved file in this code so that when the script saves the screenshot it includes whatever text I copied in the saved file?
ie. "(clipboard content) - Test"
I tried adding % clipboard to the script, but it literally just showed "% clipboard - Test" as the saved file.
ie. "(clipboard content) - Test"
I tried adding % clipboard to the script, but it literally just showed "% clipboard - Test" as the saved file.
Code: Select all
#include C:\Users\Owner\Documents\Other\AutoHotkey Scripts\Gdip_All.ahk
^Numpad5::
; Test
pToken := Gdip_Startup()
snap := Gdip_BitmapFromScreen("1400|148|1142|1163")
Gdip_SaveBitmapToFile(snap, "C:\Users\Owner\Desktop\ - Test.png")
fPath := "C:\Users\Owner\Desktop"
Gdip_SaveBitmapToFile(snap,fPath "\ - Test.png")
Gdip_SaveBitmapToFile(snap,A_Desktop "\ - Test.png")
fName := "my.txt"
fPath := A_Desktop
Return
Re: Create Screenshot specific area
I don't see in your posted code where you tried doing that, but it doesn't matter. The answer is no, you can't just add text to it and have it somehow show up along with the image in the saved file. You would have to modify the image to add text to it.