; Screenshot Helper
; script best view with Notepad++ and SyntaxHighlighting=Autoit
;
; AHK 1.1.09.00 L
ScriptVersionString = 1.0.0.1
ScriptVersionDateString = 15.11.2012
; By fump2000
;
;============================================================================
; Setzen der Globalen Variablen:
;============================================================================
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
CoordMode, Mouse, Screen
;============================================================================
; Includes
;============================================================================
#Include, Gdip.ahk
;============================================================================
; Start & Hotkeys
;============================================================================
^NumpadDot::
Settimer, InfoBox, 50
Hotkey, Numpad0, ScreenArea
Hotkey, Numpad1, WindowOnly
Hotkey, Numpad2, ScreenOne
Hotkey, Numpad3, ScreenComplete
Hotkey, ESC, ToolEnd
Hotkey, Numpad0, ScreenArea, on
Hotkey, Numpad1, WindowOnly, on
Hotkey, Numpad2, ScreenOne, on
Hotkey, Numpad3, ScreenComplete, on
Hotkey, ESC, ToolEnd, on
Return
;============================================================================
WindowOnly: ; Nur Fenster Cpature
GoSub InfoBoxOff
WinGetPos,x,y,w,h,A
MakeCapture(x,y,w,h)
GoSub HotkeyOff
Gosub ZeigePic
Return
ScreenComplete: ; Kompletter Screen
GoSub InfoBoxOff
file:= A_ScriptDir "\" "screenshot" "-" A_Now ".jpg"
pToken:=Gdip_Startup()
pBitmap:=Gdip_BitmapFromScreen(Screen=0)
Gdip_SaveBitmapToFile(pBitmap, file, 99)
Gdip_GetImageDimensions(pBitmap, sw, sh)
Gdip_Shutdown(pToken)
GoSub HotkeyOff
Gosub ZeigePic
Return
ScreenOne: ; Nur Monitor 1
GoSub InfoBoxOff
SysGet, Mon1, Monitor, 1
x:= Mon1Left
y:= Mon1Top
w:= Mon1Right
h:= Mon1Bottom
MakeCapture(x,y,w,h)
GoSub HotkeyOff
Gosub ZeigePic
Return
ScreenArea: ; Bereich mit zwei Klicks bestimmen
GoSub InfoBoxOff
SysGet, Bildschirmanzahl, MonitorCount
Loop, %Bildschirmanzahl%
{
SysGet, Size%A_Index%, Monitor, %A_Index%
}
; GUI's vorbereiten
Loop, %Bildschirmanzahl%
{
Gui, Screen%A_Index%:New, +ToolWindow +LastFound +AlwaysOnTop, Screen%A_Index%
Gui, Screen%A_Index%:Color, 0x3366CC
WinSet, Transparent, 100,
Gui, Screen%A_Index%:-caption
}
ShowGUI()
Koords = A
SetTimer, ToolTipAnzeigen, 50
KeyWait, LButton, D
if(GetKeyState("esc","P"))
{
GoSub HotkeyOff
HideGUI()
SetTimer, ToolTipAnzeigen, Off
ToolTip
Return
}
MouseGetPos,MouseX ,MouseY
ToolTip
sleep, 200
SetTimer, ToolTipAnzeigen, Off
Koords = B
SetTimer, ToolTipAnzeigen, 50
KeyWait, LButton, D
if(GetKeyState("esc","P"))
{
GoSub HotkeyOff
HideGUI()
SetTimer, ToolTipAnzeigen, Off
ToolTip
Return
}
MouseGetPos,MouseW ,MouseH
sleep, 200
SetTimer, ToolTipAnzeigen, Off
ToolTip
HideGUI()
x:= MouseX
y:= MouseY
w:= MouseW-MouseX
h:= MouseH-MouseY
MakeCapture(x,y,w,h)
GoSub HotkeyOff
Gosub ZeigePic
Return
;============================================================================
; Erstellter Screenshot wird angezeigt
;============================================================================
ZeigePic:
; Berechnungen am Bild zur verkleinerten Darstellung
Loop,
{
if (sh > 399)
{
sh:=sh/100*95
sw:=sw/100*95
}
else
{
if (sw > 399)
{
sh:=sh/100*95
sw:=sw/100*95
}
else
{
sh:=Round(sh)
sw:=Round(sw)
break
}
}
}
; Minimierte GUI zum anzeigen des erstellten Bildes
Gui, Pic:New, +LastFound, Pic
Gui, Pic:Color, 8dadef
Gui, Pic:-Caption
Gui, Pic:Add, GroupBox, x12 y0 w130 h30 ,
Gui, Pic:Add, GroupBox, x142 y0 w130 h30 ,
Gui, Pic:Add, GroupBox, x272 y0 w130 h30 ,
Gui, Pic:Add, Text, x52 y11 w50 h17 gSpeicherPic, Speichern
Gui, Pic:Add, Text, x162 y11 w90 h17 gPicToClip, In Zwischenablage
Gui, Pic:Add, Text, x289 y11 w100 h17 gDelete, Löschen + schließen
sx1:=sw//2
sy1:=sh//2
sx:=205-sx1
sy:=235-sy1
Gui, Pic:Add, Picture, x%sx% y%sy% w%sw% h%sh%, %file%
SysGet, PicMon, MonitorWorkArea, 1
PicX:=PicMonRight-420
PicY:=PicMonBottom-450
PicW:=410
PicH:=440
Gui, Pic:Show, % "Minimize" "x" PicX "y" PicY "w" PicW "h" PicH
Loop 6
{
Gui Flash
Sleep, 500
}
Return
SpeicherPic: ; Bild Speichern (der UPfad kommt später über eine INI)
SplitPath, file, Name, Verz, Erw, NameOhneErw, Laufwerk
UPfad:="E:\"
UserPfad:=UPfad "\" Name
FileSelectFile, Pfad, S16, %UserPfad%, Wähle einen Pfad (*.*)
SplitPath, Pfad, Name, Verz, Erw, NameOhneErw, Laufwerk
Filecopy, %file%, %Pfad%
Return
PicToClip: ; Bild in die Zwischenablage
filetemp:= A_ScriptDir "\" "tempfile" "-" A_Now ".bmp"
Source:=file
pToken:=Gdip_Startup()
pBitmap2 := Gdip_CreateBitmapFromFile(Source)
Gdip_SaveBitmapToFile(pBitmap2, filetemp, 100)
Gdip_Shutdown(pToken)
ImageToClipboard(filetemp)
Filedelete %filetemp%
t=1
Settimer, ToolTipClip, 50
Return
Delete: ; Bild löschen und GUI killen
Filedelete %file%
Gui, Pic:Destroy
Return
;============================================================================
; Tooltip Timer
;============================================================================
InfoBox:
Tooltip Funktionen:`nNumPad 0 = Bildbereich ausschneiden`nNumPad 1 = Nur aktives Fenster`nNumPad 2 = Nur erster Monitor`nNumPad 3 = Kompletter Sichtbereich`n`nStrg+Escape = Abbruch
Return
InfoBoxOff:
Settimer, InfoBox, Off
Tooltip
Return
ToolTipAnzeigen:
MouseGetPos, AusgabeX, AusgabeY
Tooltip, Koordinaten %Koords% anklicken!`n`nPosition: X = %AusgabeX% | Y = %AusgabeY%`nESC drücken + klicken =Abbruch!
Return
ToolTipClip:
t++
Tooltip Das Bild ist über die Zwischenablage verfügbar!
if t > 50
{
ToolTip
Settimer, ToolTipClip, Off
}
Return
;============================================================================
; Funktionen
;============================================================================
; GUIs anzeigen
ShowGUI()
{
global
Loop, %Bildschirmanzahl%
{
local width:=Size%A_Index%Right-Size%A_Index%Left
local height:=Size%A_Index%Bottom-Size%A_Index%Top
Gui, Screen%A_Index%:Show, % "x" Size%A_Index%Left "y" Size%A_Index%Top "w" width "h" height,
}
}
Return
; GUIs ausblenden
HideGUI()
{
global
Loop, %Bildschirmanzahl%
{
Gui, Screen%A_Index%:Hide
}
}
Return
MakeCapture(x,y,w,h)
{
global file
global sw
global sh
file:= A_ScriptDir "\" "screenshot" "-" A_Now ".jpg"
nl:= x
nt:= y
nw:= w
nh:= h
pToken:=Gdip_Startup()
pBitmap:=Gdip_BitmapFromScreen(nl "|" nt "|" nw "|" nh)
Gdip_SaveBitmapToFile(pBitmap, file, 99)
Gdip_GetImageDimensions(pBitmap, sw, sh)
Gdip_Shutdown(pToken)
}
ImageToClipboard(Filename)
{
hbm := DllCall("LoadImage","uint",0,"str",Filename,"uint",0,"int",0,"int",0,"uint",0x10)
if !hbm
return
DllCall("OpenClipboard","uint",0)
DllCall("EmptyClipboard")
; Place the data on the clipboard. CF_BITMAP=0x2
if ! DllCall("SetClipboardData","uint",0x2,"uint",hbm)
DllCall("DeleteObject","uint",hbm)
DllCall("CloseClipboard")
}
;============================================================================
; Tool beenden & Hotkeys abschalten
;============================================================================
HotkeyOff:
Hotkey, Numpad0, ScreenArea, Off
Hotkey, Numpad1, WindowOnly, Off
Hotkey, Numpad2, ScreenOne, Off
Hotkey, Numpad3, ScreenComplete, Off
Hotkey, ESC, ToolEnd, Off
Return
ToolEnd:
GoSub HotkeyOff
GoSub InfoBoxOff
Return