Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

FSB - Fast Screenshot Bundle [BoBo]


  • Please log in to reply
5 replies to this topic

Poll: Download Barometer (6 member(s) have cast votes)

Download Barometer

  1. I love it! (3 votes [37.50%])

    Percentage of vote: 37.50%

  2. I love you! [Sorry! This is only selectable if your name is Angelina Jolie] (1 votes [12.50%])

    Percentage of vote: 12.50%

  3. I want to adopt that tic-person. Send me its address. (1 votes [12.50%])

    Percentage of vote: 12.50%

  4. UselessToolnameAlert (1 votes [12.50%])

    Percentage of vote: 12.50%

  5. Who I am? Where I am??? GOSH, I'd better leave this thread ... (2 votes [25.00%])

    Percentage of vote: 25.00%

Vote Guests cannot vote
Beastmaster
  • Members
  • 191 posts
  • Last active: Apr 23 2007 02:58 PM
  • Joined: 15 Apr 2004
BoBoVision proudly presents .. F .. S .. B .. !
/*
     
      AutoHotkey Version: 1.0.47.06
      Sprache:            English
      Plattform:          WIN_XP
      Author:             tic/(and ~2% BoBoCode)
      Credits:            The script is up to 100% based on what has been puplished within this thread: "GDI+ standard library 1.20 by tic" ...
                          which you might want to check out here: http://www.autohotkey.com/forum/topic32238.html

      Script Funktion:    Creation of two screenshoots ('The Bundle') in one go.
                          One image is created in its original size, the second is getting 'thumbnailed'.
                          Both screenshoots will be uploaded to autohotkey.net (configurable) using standard FTP .
                          Window- as well as Screen-shoots are supported.

                          Additionaly a BBCodeLink will be created at the clipboard (eg. to be used at a forum afterwards).
                          That BBCodeLink will offer the option to drop a 'clickable Thumbnail' at a forum, linked to the original image
                          eg. on autohotkey.net

                          Using thumbnails instead of original sized images should speed up the loading of forum posts, and prevents users from posting
                          'Wallpaper'-sized images which impacts the readability of threads.
          
      Handling:           Using the Hotkey (here SHIFT+PrintScreen), two screenshoots will be created at the scripts current directory.
                          The BBCodeLink is created at the clipboard to be used at a forum.

      Requirements:       the AHK Gdi+ library (linked below).
                          to edit the path which defines the BBCOde-Links destination target (as mentioned below)
                         
*/


#NoEnv
#SingleInstance, Force
#Include, Gdip.ahk                                            ; Download: https://ahknet.autohotkey.com/~tic/Gdip.ahk
SetBatchLines, -1

MyAHKNetUserName  := "MyUsername"
MyAHKNetPassword  := "MyPassword"
MyAHKNetUploadDir := "MyDirectory"
MyAHKNetFTPPath   := "autohotkey.net"
MyAHKNetPath      := "https://ahknet.autohotkey.com"

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system 
   ExitApp
  }
  OnExit, Exit

+PrintScreen:: ; press SHIFT+Printscreen
    MyAHKNetPath := MyAHKNetPath "/~" MyAHKNetUserName "/" MyAHKNetUploadDir
    FileName := SaveScreen(1.00,"png","Window")               ; create screenshot (original size).
    Sleep, 750
    FileNameThumb := SaveScreen(0.33,"png","Window")          ; shrink screenshot with a rate of 33/100 %, to create its thumbnail.
    ClipBoard := "[url=" MyAHKNetPath "/" FileName ".png][img]" MyAHKNetPath "/" FileNameThumb ".png[/img][/url]" ; create BBCodeLink
    Upload(FileName
         , FileNameThumb
         , MyAHKNetUserName
         , MyAHKNetPassword
         , MyAHKNetUploadDir
         , MyAHKNetFTPPath)
    Return
    Return

SaveScreen(Size,FileType,Type)
{
  WinGetPos, X, Y, W, H, A
  If (Type = "Window") {
    pBitmap := Gdip_BitmapFromScreen(X "|" Y "|" W "|" H)
    FileName := "Window_" A_Now
    } Else {
    pBitmap := Gdip_BitmapFromScreen()
    FileName := "Screen_" A_Now
    }
  Width := Gdip_GetImageWidth(pBitmap), Height := Gdip_GetImageHeight(pBitmap)
  PBitmapResized := Gdip_CreateBitmap(Round(Width*Size), Round(Height*Size)), G := Gdip_GraphicsFromImage(pBitmapResized)
  Gdip_SetInterpolationMode(G, 7)
  Gdip_DrawImage(G, pBitmap, 0, 0, Round(Width*Size), Round(Height*Size), 0, 0, Width, Height)
  Gdip_SaveBitmapToFile(PBitmapResized, A_ScriptDir "\" FileName "." FileType)
  Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapResized)
  Gdip_DisposeImage(pBitmap)
  Return (FileName)
  }

Upload(FileName,FileNameThumb,MyAHKNetUserName,MyAHKNetPassword,MyAHKNetUploadDir,MyAHKNetFTPPath) {
  FileDelete, FSB.ftp
  FileAppend, 
      (LTrim
      open %MyAHKNetFTPPath%
      %MyAHKNetUserName%
      %MyAHKNetPassword%
      binary
      cd %MyAHKNetUploadDir%
      put %FileName%.png
      put %FileNameThumb%.png
      quit
      ), FSB.ftp
  ToolTip, Upload to %MyAHKNetFTPPath% ...
  RunWait, cmd /c ftp -s:FSB.ftp >> FSB.log,, Hide
  SoundBeep
  ToolTip  Transfer completed. Bye!
  Sleep, 500
  ToolTip
  FileAppend, `n`n%ClipBoard%`n`n`t------`n`n, FSB.log ; add the BBCode-Link as additional reference to the FTP logfile.
  Return
  }

!l::Run, FSB.log ; press ALT+L if you want to check the FTP logfile
!a::Run, %MyAHKNetPath% ; press ALT+A to visit autohotkey.net

Exit:
Gdip_Shutdown(pToken)
ExitApp
Return
Might come handy if it comes to create 'clickable-forum-thumbnail-images' like this (without to use imageshack&friends):

Posted Image

Feel free to comment, as ~98,99 % of the code is tic's! So I will blame him - on your behalf :D10/09/2008 - New. Script provides the upload of the created screenshots to autohotkey.net (host configurable) using FTPs basic functionality .
derRaphael posted an alternative script (see below) using his httpQuery function for the file transfer.

Wanna flame me? Send your mail to: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> 8) - Not enough pain? What about to check out [FSC] now ?? :wink:
Keywords: thumbnail - screenshot - GDI+ - gdiplus - BB Code - phpBB - BoBo - BoBo² - capture - grep - autohotkey.net - tic - imageshack

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
K, here's a version, which allows uploads directly to an existing Ahk.net account by using its webinterface and httpQuery.

; FSB für Autohotkey v0.1
; based on BoBo's FSB Script 
; (deDE) http://de.autohotkey.com/forum/viewtopic.php?t=3537
; (enUS) http://www.autohotkey.com/forum/viewtopic.php?t=35580

; AutoHotkey.net won't work when no cookies are allowed - so we have to 
; do some lil trick to get this working.
; PHP usually allows to receive cookie Informations being sent with the 
; GET request. This is what we will do here...

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

MyAHKNetUserName  := "My User at AutoHotkey.Net"
MyAHKNetPassword  := "My Password at AutoHotkey.Net"
MyAHKNetUploadDir := "/screenshots/"  ; Do not miss the leading and trailing slash
MyAHKNetPath      := "https://ahknet.autohotkey.com/~" MyAHKNetUserName "/" SubStr(MyAHKNetUploadDir,2,-1)

imgType := "png"

If (!pToken := Gdip_Startup()) {
   MsgBox, 48, gdiplus error!, % "Gdiplus failed to start. "
							   . "Please ensure you have gdiplus on your system"
   ExitApp
}

OnExit, Exit
Return

AHKNET_Login:
	; Neccessary settings to get the SESSION cookie sent via HttpHeaders
	Tooltip("Get Cookie from AutoHotkey.net",2)
	GoSub, EpicCycleOn
	httpQueryOps := "storeHeader" 
	httpQueryDwFlags := (INTERNET_FLAG_NO_AUTO_REDIRECT:= 0x00200000) 

	; Send Request to get proper cookieData in Header
	l := httpQuery(data:="","https://ahknet.autohotkey.com/xfm/?a=login")
	VarSetCapacity(data,-1)
	EpicCycle := 0

	; Extract the SESSION Cookie
	Loop,Parse,HttpQueryHeader,`n
		if (RegExMatch(A_LoopField,"^Set-Cookie"))
			Cookie := RegExReplace(A_LoopField,"Set-Cookie: |;.*")

	; Login Procedure - so the server knows who we are
	GoSub, EpicCycleOn
	Tooltip("AutoHotkey.net Login",2)
	httpQueryDwFlags := "" ; Not Neccessary anymore
	PostData := "user=" uriEncode(MyAHKNetUserName) "&pass=" uriEncode(MyAHKNetPassword) "&cmd=Log+in"
	l := httpQuery(data:="","https://ahknet.autohotkey.com/xfm/?a=login&" Cookie, PostData)
	VarSetCapacity(data,-1)
	EpicCycle := 0
	; This was the magic request that logged us in.

	; **************************************************************************************
	; Some more testing will be neccessary here to get this properly working. Especially
	; when Log in failed for some reasons.
	; **************************************************************************************

	; This is supposed to be the upload page.
	GoSub, EpicCycleOn
	Tooltip("Accessing AutoHotkey.net upload page",2)
	l := httpQuery(data:="","https://ahknet.autohotkey.com/xfm/?a=create&d=&" Cookie)
	VarSetCapacity(data,-1)

	EpicCycle := 0
Return

AHKNET_Upload:
	; Image 1
	FileGetSize,size1,%FileName%
	SplitPath,FileName,OFN1
	FileRead,img1,%FileName%
	VarSetCapacity(placeholder1,size1,32)

	; Image 2
	FileGetSize,size2,%FileNameThumb%
	SplitPath,FileNameThumb,OFN2
	FileRead,img2,%FileNameThumb%
	VarSetCapacity(placeholder2,size2,32)

	; Create Boundary
	boundary := makeProperBoundary()

	; Generate DummyPost
	postPart_1 := "--" boundary "`n"
				. "Content-Disposition: form-data; name=""upload_dir""`n"
				. "`n"
				. MyAHKNetUploadDir "`n"
				. "--" boundary "`n"
				. "Content-Disposition: form-data; name=""upload_1""; filename=""" ofn1 """`n"
				. "Content-Type: " MimeType(img1) "`n"
				. "Content-Transfer-Encoding: binary`n"
				. "`n"
	postPart_2 := "`n"
				. "--" boundary "`n"
				. "Content-Disposition: form-data; name=""upload_2""; filename=""" ofn2 """`n"
				. "Content-Type: " MimeType(img2) "`n"
				. "Content-Transfer-Encoding: binary`n"
				. "`n"
	postPart_3 :=  "`n"
				. "--" boundary "`n"
				. "Content-Disposition: form-data; name=""upload_3""; filename=""""`n"
				. "Content-Type: application/octet-stream`n"
				. "Content-Transfer-Encoding: binary`n"
				. "`n"
				. "`n"
				. "--" boundary "`n"
				. "Content-Disposition: form-data; name=""MAX_FILE_SIZE""`n"
				. "`n"
				. "8000000`n"
				. "--" boundary "`n"
				. "Content-Disposition: form-data; name=""cmd""`n"
				. "`n"
				. "Upload all`n"
				. "--" boundary "--"
				
	post := postPart_1 placeholder1 postPart_2 placeholder2 postPart_3

	; Create Proper Headers
	headers:="Content-type: multipart/form-data, boundary=" boundary "`nContent-Length: " strlen(post)

	; Fix PostData - copy the binary imagedata into memory at posts position
	; Image 1
	DllCall("RtlMoveMemory"
				,"uInt",(offset:=&post+strlen(postPart_1))
				,"uInt",&img1,"uInt",size1)
	; Image 2
	DllCall("RtlMoveMemory"
				,"uInt",(offset:=&post+strlen(postPart_1)+size1+strlen(postPart_2))
				,"uInt",&img2,"uInt",size2)

	; Send this stuff
	; This is the place to show some nice uploading GFX or whatever
	GoSub, EpicCycleOn
	Tooltip("Upload pictures to AutoHotkey.net",2)
	l := httpQuery(data:="","https://ahknet.autohotkey.com/xfm/?a=create&" Cookie, post, headers)
	VarSetCapacity(data,-1)
	EpicCycle := 0
	If !(InStr(data,"success"))
		MsgBox,16,Error,Errow at FileUpload
	; This is the place to quit the nice uploading GFX
return

AHKNET_Logout:
	GoSub, EpicCycleOn
	httpQueryDwFlags := (INTERNET_FLAG_NO_AUTO_REDIRECT:= 0x00200000) 
	l := httpQuery(data:="","https://ahknet.autohotkey.com/xfm/?a=logout&" Cookie)
	httpQueryDwFlags := Cookie := ""
	EpicCycle := 0
Return

EpicCycleON:
	EpicCycle := 1
	SetTimer, EpicCycle, -1
Return

; EpicCycle - Stolen from Rhys
; http://www.autohotkey.com/forum/viewtopic.php?p=203787#203787
; Modified and adapted to be an indicator for current internet traffic
EpicCycle:
	Width := 56, Height := 56
	Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
	Gui, 1: Show, NA
	hwnd1 := WinExist()
	hbm := CreateDIBSection(Width, Height)
	hdc := CreateCompatibleDC()
	obm := SelectObject(hdc, hbm)
	G := Gdip_GraphicsFromHDC(hdc)
	Gdip_SetSmoothingMode(G, 4)
	
	hBrush:=Gdip_BrushCreateSolid(0xEEff0000)
	hPen:=Gdip_CreatePen(0xEEFFFFee0, 2)
	fatPen:=Gdip_CreatePen(0xEE0000FF, 5)
	eraserPen:=Gdip_CreatePen(0x00000000, 5)
	
	CoordMode, Mouse, Screen

	Loop,60
		If (EpicCycle=0)
			Break
		else {
			MouseGetPos,MX,MY
			Gdip_SetCompositingMode(G, 1)
			Gdip_Drawarc(G, FatPen, 2, 2, 50, 50, 270, A_Index*6)
			Gdip_SetCompositingMode(G, 0)
			Gdip_Drawarc(G, hPen, 2, 2, 50, 50, 270, A_Index*6)
			UpdateLayeredWindow(hwnd1, hdc, MX-25, MY-25, Width, Height)
			Sleep,10
		}
	Loop,30
		If (EpicCycle=0)
			Break
		else {
			MouseGetPos,MX,MY
			Gdip_SetCompositingMode(G, 1)
			Gdip_Drawarc(G, eraserPen, 2, 2, 50, 50, 270, A_Index*12)
			UpdateLayeredWindow(hwnd1, hdc, MX-25, MY-25, Width, Height)
			Sleep,10
		}
	
	Gdip_SetCompositingMode(G, 0)
	Gui,Destroy
	SelectObject(hdc, obm)
	DeleteObject(hbm)
	DeleteDC(hdc)
	Gdip_DeleteGraphics(G)
	if (EpicCycle=1)	
		SetTimer, EpicCycle, -1
Return

Exit:
	Gdip_Shutdown(pToken)
	ExitApp
	
+PrintScreen:: ; press SHIFT+Druck
	; Screenshoot in Originalgröße ertstellen.
    FileName := SaveScreen(1.00,imgType,"Window") "." imgType 
    Sleep, 750
	; Screenshot reduzieren auf 0,33 Prozent der Originalgröße zur Erstellung eines "Thumbnail".
    FileNameThumb := SaveScreen(0.33,imgType,"Window") "." imgType 
    ClipBoard := "[url=" MyAHKNetPath "/" FileName "][img]" MyAHKNetPath "/" FileNameThumb "[/img][/url]"
    Sleep, 750
	GoSub, AHKNET_Login
 	GoSub, AHKNET_Upload
	GoSub, AHKNET_Logout
Return

uriEncode(str)
{ ; v 0.3 / (w) 24.06.2008 by derRaphael / zLib-Style release
   b_Format := A_FormatInteger
   data := ""
   SetFormat,Integer,H
   Loop,Parse,str
      if ((Asc(A_LoopField)>0x7f) || (Asc(A_LoopField)<0x30) || (asc(A_LoopField)=0x3d))
         data .= "%" . ((StrLen(c:=SubStr(ASC(A_LoopField),3))<2) ? "0" . c : c)
      Else
         data .= A_LoopField
   SetFormat,Integer,%b_format%
   return data
}

makeProperBoundary() {
   ; (w) derRaphael / zLib Style released
   Loop,26
      n .= chr(64+a_index)
   n .= "0123456789"
   Loop,% StrLen(A_Now) {
      Random,rnd,1,% StrLen(n)
      Random,UL,0,1
      b .= RegExReplace(SubStr(n,rnd,1),".$","$" (round(UL)? "U":"L") "0")
   }
   Return b
}

MimeType(ByRef Binary) {
   ; (w) derRaphael / zLib Style released
   MimeTypes:="424d image/bmp|4749463 image/gif|ffd8ffe image/jpeg|89504e4 image/png|4657530"
          . " application/x-shockwave-flash|49492a0 image/tiff"
   @:="0123456789abcdef"
   Loop,8
      hex .= substr(@,(*(a:=&Binary-1+a_index)>>4)+1,1) substr(@,((*a)&15)+1,1)
   Loop,Parse,MimeTypes,|
      if ((substr(hex,1,strlen(n:=RegExReplace(A_Loopfield,"\s.*"))))=n)
         Mime := RegExReplace(A_LoopField,".*?\s")
   Return (Mime!="") ? Mime : "application/octet-stream"
}

Tooltip(sTooltipTxt,Seconds=5) {
   ; (w) derRaphael / zLib Style released
   if (Seconds+0=0)
      Seconds = 5
   StartTime := EndTime := A_Now
   EnvAdd,EndTime,Seconds,Seconds
   Loop,
      if (EndTime=A_Now)
         Break
      else {
         ToolTip, %sTooltipTxt%
		 sleep, 25
	  }
   ToolTip
}

SaveScreen(Size,FileType,Type)
{
	WinGetPos, X, Y, W, H, A
	If (Type = "Window") {
		pBitmap := Gdip_BitmapFromScreen(X "|" Y "|" W "|" H)
		FileName := "Window_" A_Now
	} Else {
		pBitmap := Gdip_BitmapFromScreen()
		FileName := "Screen_" A_Now
	}
	Width := Gdip_GetImageWidth(pBitmap), Height := Gdip_GetImageHeight(pBitmap)
	PBitmapResized := Gdip_CreateBitmap(Round(Width*Size), Round(Height*Size))
	G := Gdip_GraphicsFromImage(pBitmapResized)
	Gdip_SetInterpolationMode(G, 7)
	Gdip_DrawImage(G, pBitmap, 0, 0, Round(Width*Size), Round(Height*Size), 0, 0, Width, Height)
	Gdip_SaveBitmapToFile(PBitmapResized, A_ScriptDir "\" FileName "." FileType)
	Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapResized)
	Gdip_DisposeImage(pBitmap)
	Return (FileName)
}
	
#Include, httpQuery.ahk
#Include, Gdip.ahk

Yes! - It doesn't give you a warning when u entered a wrong password
Yes! - It doesn't give you a warning when u entered a wrong username
No! - It tells You when something with your upload went wrong (eg no success Message)

Comments, questions, wishes, or suggestions appreciated

Greets
dR

All scripts, unless otherwise noted, are hereby released under CC-BY

oliver.lipkau
  • Members
  • 97 posts
  • Last active: Jul 29 2015 07:12 AM
  • Joined: 17 Sep 2006
Hi BoBo.

I would like to know what would be needed to change, so the screenshot would be saved in the clipboard.

Best regads.
Oliver Lipkau

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
oliver, there's a function in the gdi+ library for BitmapToClipboard or similar

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Good idea with the included thumbnail.

Zod
  • Members
  • 214 posts
  • Last active: Jan 26 2012 08:02 PM
  • Joined: 06 Jul 2011
WOW BoBo has a REGISTERED Account. I never knew :roll:
Posted Image Stolen from SKAN