AutoHotkey Community

It is currently May 27th, 2012, 6:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 

Download Barometer
I love it!
I love you! [Sorry! This is only selectable if your name is Angelina Jolie]
I want to adopt that tic-person. Send me its address.
UselessToolnameAlert
Who I am? Where I am??? GOSH, I'd better leave this thread ...
You may select 1 option

View results
Author Message
PostPosted: September 9th, 2008, 1:57 pm 
Offline

Joined: April 23rd, 2007, 2:23 pm
Posts: 9
    BoBoVision proudly presents .. F .. S .. B .. !
Code:
/*
     
      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: http://www.autohotkey.net/~tic/Gdip.ahk
SetBatchLines, -1

MyAHKNetUserName  := "MyUsername"
MyAHKNetPassword  := "MyPassword"
MyAHKNetUploadDir := "MyDirectory"
MyAHKNetFTPPath   := "autohotkey.net"
MyAHKNetPath      := "http://www.autohotkey.net"

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):

    Image

    Feel free to comment, as ~98,99 % of the code is tic's! So I will blame him - on your behalf :D
10/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: IReallyDontC@reDu.de 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


Last edited by BoBo on September 10th, 2008, 3:12 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2008, 1:55 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
K, here's a version, which allows uploads directly to an existing Ahk.net account by using its webinterface and httpQuery.

Code:
; 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      := "http://www.autohotkey.net/~" 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:="","http://www.autohotkey.net/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:="","http://www.autohotkey.net/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:="","http://www.autohotkey.net/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:="","http://www.autohotkey.net/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:="","http://www.autohotkey.net/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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 1:53 pm 
Offline

Joined: September 17th, 2006, 6:15 pm
Posts: 85
Location: Munique/Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 4:06 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
oliver, there's a function in the gdi+ library for BitmapToClipboard or similar

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 7:17 am 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
Good idea with the included thumbnail.

_________________
~sumon Appifyer AHK Nova halted Recommended: AHK_L (Why?)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2011, 3:15 pm 
Offline

Joined: July 6th, 2011, 5:37 pm
Posts: 214
Location: Looking over my domain
WOW BoBo has a REGISTERED Account. I never knew :roll:

_________________
Image Stolen from SKAN


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group