AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Work Break Timer, Task/Idea Logger, ScreenCapture - v. 3.00
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Feb 26, 2008 8:43 am    Post subject: Re: Screenshots of both monitors Reply with quote

BlackLight wrote:
Would it be possible to make screenshots from a 2nd monitor as well?

The original ScreenCapture script
http://www.autohotkey.com/forum/topic18146.html
used
Code:
SysGet, Mon, Monitor, 1

Looks like someone modified it while copying it.
You may use for second monitor instead
Code:
SysGet, Mon, Monitor, 2
Back to top
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Tue Feb 26, 2008 9:05 am    Post subject: Re: Experience so far and Enhancement ideas Reply with quote

Starbuck wrote:
- Allow for a reset on the hour in order to get breaks at regular times as well as regular intervals. I sort of like the idea of knowing exactly when I'll be breaking from one effort or another and letting people know exactly when I'll be able to break.

-When changing the settings, allow the new settings to take effect immediately. As it is I think you need to close down the program or wait for the current cycle to finish before it starts with new settings.

My first thought is to combine both requests as one. I could just add a "reset" button in the icon tray. When clicked, it does a complete script reload. For the first request, at the beginning of the hour, you click "Reset". For the second request, after making changes to the settings, you click "Reset" to take effect immediately. If you're in the middle of a work/break cycle, it would discontinue that cycle and start over as if it had been shut down and restarted.
This isn't the most elegant way to accomplish both your requests but is the easiest. Would that work for you?

Starbuck wrote:
- Add ability to associate time blocks with specific kinds of activity. We don't need to follow this all the time but the guideline can help us to remember what we should be doing at specific times and get us back on track, continuing related activity in the next cycle. Examples of regular activity include:
--- Reading news/forums.
--- Lunch
--- Real work
--- Email
--- Open discussion time

I may need a little more explanation to better understand.
Do you mean something like:
6-7am - Read news/orums
7-11am - Real work
11-12pm - email
12-1pm - Lunch
etc.
with a pop-up reminder when you should be working on one of the activities

Or ...
do you just mean to have the ability to create a drop down list that will automatically populate the title of a new task with the selected list entry?

Or ...
Something else

Starbuck wrote:
- For time keeping (again, a perhaps unintended but yet primary use of this utility) it would be nice to see the following in the task entry popups:
--- Pulldown for client or department codes - general, not too many. (Yes, I suppose we already have a freeform field for this but I find myself entering non-standard codes almost every time I type something in there.)

Yes, I've got this on my ToDoList. I think the first pass wil probably be something you have to manually enter into a new section on the ini file and change the control to a combo text/dropdown list that pulls the list from the ini file.

BTW, like you, I use TDL, so I don't really get too fussed about entering "non-standard" codes or text when describing an activity (title description). Since I do daily/weekly/monthly TDL reviews of both what I have to do and what I've done; for the "Done" stuff, I just drag/drop or cut/paste into the TDL project/sub-project/task it falls under. Everything rolls up anyway so, for example, if I have a TDL Task titled "Review/Respond to email" regardless of what the completed task is titled (i.e. "respond to WBT emails", "review new emails", "respond to "next action" emails, etc.) they all get placed under the TDL task "Review/Respond to email". The same process works for clients, projects, sub-projects, etc. Make sense?

I mention this as I'm not sure, at the end of the day, which is faster. Clicking, thinking and selecting from a drop-down list, then adding additional info in the comments or just typing it all free form. Even if you have a lot of individual "Check email" task title entries, after dragging them where they belong under TDL, it all rolls up anyway. What are your thoughts?

Starbuck wrote:
--- Checkbox for billable.
These can be added by the code at the back-end of the comments, delimited by pipes: otherdata|comments|code|billable

Good idea. I'll put it on my ToDoList. Again, will probably set default to non-billable but can be changed in ini file.

Starbuck wrote:
-Sound for timer should be selectable, with one check for break start and another for break end. We're right at the keyboard so we probably don't need audio for break start, the visual cue is good enough. And we might be away from the keyboard during break, so we probably do need audio for break end.

- Allow playing an audio (WAV, MPEG, AU) file rather than a pre-defined sound. I should get familiar with AHK and add this one for myself.

Agreed, another thing to add to my ToDoList. Maybe you'll beat me to the punch Cool

Starbuck wrote:
- Allow for a configurable ASCII character that replaces embedded carriage returns. Multiple lines in comments mess up exports but if we can control the delimiter we can zap that into CRLF later.

I've noticed this myself and agree. Just don't know how to do it. Tic or others, any ideas?

Starbuck wrote:
We can easily just put a pipe into our comments to add new fields for ourselves. So if I want a billable flag all I need to do is put " |b " after the comment. Then when the data is imported into Excel there will be a new column for billable items. Kewl, eh? You guys probably do this all the time. Embarassed

Actually, I hadn't thought of that, but you'd have to add the header field in the new column (i.e. Billable)and if other columns are suggested and I add them, things could get messed up. Then again, not being a dB guy, what do I know. Anyway, I like the addition of a "Billable" column so I'll just add it to the code.


Starbuck wrote:
Finally, I understand that this is open source freeware and while I'm familiar with a ton of programming languages and environments, AHK isn't one of them ... yet. The usefulness of this tool (which I refer to as WBT along with TDL) is compelling enough to make me take interest in this AHK thing so that I can maintain my own code, make my own enhancements, and hopefully give changes back to the group - I just need to find some time, which is why I took interest in WBT in the first place. Smile

Learning AHK, enhancing and sharing your improvements would be awesome. For someone with your programming background, I'll bet it will be the easiest scripting language you've ever tackled. Regardless, the AHK experts who lurk this forum are awesome when it comes to asking for help. I'm not a programmer and they're the reason I've gotten this far.

Starbuck wrote:
It makes me wonder what else is out there in AHK-land that can be used. I'll definitely be looking at it soon.

As an automation scripting language, I've tried just about everything out there over the years and for ease of learning curve and functionality, it's the best I've found for the value (open source). And I've sent donations more than once.
_________________
Lars


Last edited by TotalBalance on Tue Feb 26, 2008 10:52 am; edited 7 times in total
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Feb 26, 2008 10:03 am    Post subject: Re: Screenshots of both monitors Reply with quote

Anonymous wrote:
Code:
SysGet, Mon, Monitor, 2

If you want to capture the whole screen, you may use:
Code:
SysGet, nL, 76
SysGet, nT, 77
SysGet, nW, 78
SysGet, nH, 79
Back to top
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Tue Feb 26, 2008 11:02 am    Post subject: Re: Screenshots of both monitors Reply with quote

Anonymous wrote:
Anonymous wrote:
Code:
SysGet, Mon, Monitor, 2

If you want to capture the whole screen, you may use:
Code:
SysGet, nL, 76
SysGet, nT, 77
SysGet, nW, 78
SysGet, nH, 79

As all of this is beyond my expertise, I guess my question is ...
How do I re-code the WBT script to 1) capture 1st and/or 2nd screen 2) handle full screen or active window based on first selection.
_________________
Lars
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Tue Feb 26, 2008 1:16 pm    Post subject: Reply with quote

If you look in my TextToImage function (which i will be updating with gdi+ when i have it working) then you will see the lines:

Code:
nL := nT := 0, nW := A_ScreenWidth, nH := A_ScreenHeight                        ; Get coordinates for full screen
.............................
DllCall("BitBlt", "UInt", mDC, "Int", 0, "Int", 0, "Int", nW, "Int", nH, "UInt", hDC, "Int", nL, "Int", nT, "UInt", 0x40000000|0x00CC0020)


change those to the coordinates that you want to capture. slight modification of the function would be needed. instead of the 1st param being "screen" you could make it "screen", "screen1", "screen2"......

and then change the coordinates appropriately depending on the number, with screen being all screens, screen1 being 1st etc.
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Tue Feb 26, 2008 1:20 pm    Post subject: Reply with quote

Tic,

So you actually think I understand what you've suggested!?

LOL
_________________
Lars
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Feb 26, 2008 1:40 pm    Post subject: Reply with quote

TotalBalance wrote:
How do I re-code the WBT script to 1) capture 1st and/or 2nd screen 2) handle full screen or active window based on first selection.

I don't think it's difficult for you to do. I have a script for it but was not written by me, and the author recently asked us do not post anymore his new scripts in the public places...
Back to top
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Tue Feb 26, 2008 2:38 pm    Post subject: Reply with quote

TotalBalance wrote:
Tic,

So you actually think I understand what you've suggested!?

LOL


Sorry dude Wink

Heres an updated function to capture chosen monitor(s).

Pass "screen" as 1st param to capture all monitors to one image
Pass "screen1" as 1st param to capture 1st monitor to one image
Pass "screen2" as 1st param to capture 2nd monitor to one image
etc.....

Code:
; TextToImage v1.08 by tic
;
; TextToImage can overlay writing to a screenshot of the entire screen or active window, or from an existing image and write to file
; TextToImage(In, Text, Output, x, y, Font, TColour, Size, Weight)
;
; In: Can either be the "Screen" or "Window" and will take a screenshot of the respective choice, or the location of an exisitng image
;
; Text: This is the text to overlay onto the screenshot
;
; Output: This is the path and filename that the image will be written to.
; The extension can be .bmp,.jpg,.png,.tif,.gif and will be written as that type accordingly
;
; x: This is the x-coordinate to place the text. This coordinate will be the distance from the left the text will be placed.
; This value may be a ratio. For instance 4:5 would place the text at the position 4/5ths of the width of the image
; You must also consult which mode align is in
;
; y: This is the y-coordinate to place the text. This coordinate will be the distance from the top the text will be placed.
; This value may be a ratio. For instance 1:3 would place the text at the position 1/3ths of the height of the image
; You must also consult which mode align is in
;
; Size: This is the height of the text in pixels
;
; Align: This must have 2 styles set, The text's x placement (Left,Centre,Right) and the text's y placement (Top,Bottom)
; It must be used for example as Left|Bottom - This would place the text at the bottom of it's bounding area and aligned left
;
; Weight: This is the boldness of the text. Make the value greater to make it more bold
;
; Font: This is the font to set the text to be
; Examples are: Arial, Bookman Old Style, Times New Roman
;
; TColour: This is the colour to set the text in RGB format.
; So FF0000 is red
;
; Style: Can contain the words Underline,Italic,Strikeout and will set the text in the appropriate styles

TextToImage(In="Screen", Text="TextToImage", Output="TextToImage.bmp", x="1:2", y="1:2", Size="20", Align="Bottom|Centre", Weight="400", Font="Arial", TColour="000000", Style="")
{
    hGdiPlus := DllCall("LoadLibrary", "Str", "gdiplus.dll")
    VarSetCapacity(si, 16, 0), si := Chr(1)
    DllCall("gdiplus\GdiplusStartup", "UIntP", pToken, "UInt", &si, "UInt", 0)
   
    If In Contains Screen,Window
    {
        If (In = "Screen")
      {
         SysGet, nL, 76                                                ; Get coordinates for all monitors
         SysGet, nT, 77
         SysGet, nW, 78
         SysGet, nH, 79
      }
      Else If ((SubStr(In, 1, 6) = "Screen") && ((Substr(In, 0) & 1) != ""))
      {
         SysGet, Coords, Monitor, % Substr(In, 0)   ;%
         nL := CoordsLeft, nT := CoordsTop, nW := CoordsRight, nH := CoordsBottom
      }   
        Else If (In = "Window")
        {
            WinGetPos, nL, nT, nW, nH, A                                                ; Get coordinates for active window
            WinGet, ID, ID, A
            WinGetTitle, Title, A
            Winget, MinMax, MinMax, A
            If !(DllCall("IsWindowVisible", UInt, ID) && (Title) && (MinMax != -1))      ; Check active window is visible
            {
                GoSub, TTS_GdiplusShutdown
                Return, "Window is not visible"
            }
        }       
        mDC := DllCall("CreateCompatibleDC", "UInt", 0)
        NumPut(VarSetCapacity(bi, 40, 0), bi)
        NumPut(nW-nL, bi, 4)
        NumPut(nH-nT, bi, 8)
        NumPut(32, NumPut(1, bi, 12, "UShort"), 0, "UShort")
        hBM := DllCall("gdi32\CreateDIBSection", "UInt", mDC, "UInt", &bi, "UInt", 0, "UIntP", "", "UInt", 0, "UInt", 0)
        oBM := DllCall("SelectObject", "UInt", mDC, "UInt", hBM)                        ; Place bitmap object Into compatible DC
        hDC := DllCall("GetDC", "UInt", 0)                                             ; Get DC of screen and bitblt
      
        DllCall("BitBlt", "UInt", mDC
      , "Int", 0, "Int", 0
      , "Int", nW-nL, "Int", nH-nT
      , "UInt", hDC, "Int"
      , nL, "Int", nT
      , "UInt", 0x40000000|0x00CC0020)
    }
    Else
    {
        VarSetCapacity(wFile, StrLen(In)*2+2)
        DllCall("kernel32\MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &In, "Int", -1, "UInt", &wFile, "Int", VarSetCapacity(wFile)//2)
        DllCall("gdiplus\GdipCreateBitmapFromFile", "UInt", &wFile, "UIntP", pBitmap)

        If !pBitmap
        {
            Gosub, TTS_GdiplusShutdown
            Return, "Failed to load image"
        }
       
        DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "UInt", pBitmap, "UIntP", hBM, "UInt", 0)
      DllCall("gdiplus\GdipDisposeImage", "Uint", pBitmap)
        mDC := DllCall("CreateCompatibleDC", "UInt", 0)
        oBM := DllCall("SelectObject", "UInt", mDC, "UInt", hBM)
      hDC := DllCall("GetDC", "UInt", 0)
    }

    StringSplit, OutputArray, Output, .
    Extension := "." . OutputArray%OutputArray0%
    If Extension not in .bmp,.jpg,.png,.tif,.gif                                    ; Check file extension is correct
    {
        GoSub, TTS_GdiplusShutdown
        Return, "Invalid file extension. Only bmp,jpg,png,tif,gif are available"
    }

    VarSetCapacity(bm, 24, 0)
    If !DllCall("GetObject", "UInt", hBM, "Int", 24, "UInt", &bm)
    {
        GoSub, TTS_GdiplusShutdown
        Return, "GetObject failed on bitmap {" hBM "}"
    }
    Width := NumGet(bm, 4, "Int")                                                  ; Get properties of bitmap
    Height := NumGet(bm, 8, "Int")
    bpp := NumGet(bm, 18, "Ushort")
   
    DllCall("SetBkMode", "UInt", mDC, "UInt", 1)                                   ; Leave background untouched for background mix mode
    DllCall("SetGraphicsMode", "UInt", mDC, "UInt", 2)                            ; Set graphics mode for DC to allow world transformations                           

    VarSetCapacity(logfont, 60, 0)
   
    LogPixelsSY := DllCall("GetDeviceCaps", "UInt", hDC, "Int", 90)                 ; Number of pixels per logical inch along the screen height
    DllCall("ReleaseDC", "UInt", 0, "UInt", hDC)
    TextHeight := -(Size*logPixelsSY)/72
   
   NumPut(TextHeight, logfont, 0)                                       ; Set text height
   ;NumPut(TextWidth, logfont, 4) ; Change text width
   
    NumPut(Weight, logfont, 16)                                          ; Set text weight
   If InStr(Style, "Underline")                                       ; Set style to be either underline,italic,Strikeout
   NumPut(1, logfont, 21)
   If InStr(Style, "Italic")
   NumPut(1, logfont, 20)
   If InStr(Style, "Strikeout")
   NumPut(1, logfont, 22)
   
   NumPut(5, logfont, 26)                                             ; ClearType antialiasing XP and above only
   
    AlignWord := "Right,Top,Bottom,Centre,Left"
    AlignNum := "2,0,8,6,0"
   
    StringSplit, AlignWords, AlignWord, `,
    StringSplit, AlignNums, AlignNum, `,
   
    Loop, %AlignWords0%
    StringReplace, Align, Align, % AlignWords%A_Index%, % AlignNums%A_Index%, All
    StringSplit, Pos, Align, |
    Align := Pos1 | Pos2

    StringLeft, FaceName, Font, 32
    DllCall("lStrcpy", "UInt", &logfont + 28, "Str", FaceName)                       ; Set font
    DllCall("SetTextAlign", "UInt", mDC, "UInt", Align)                             ; Align text
    #hFont := DllCall("CreateFontIndirect", "UInt", &logfont)
    #hOldFont := DllCall("SelectObject", "UInt", mDC, "UInt", #hFont)                ; Change DC Font
    TColour := "0x" . TColour
    prevColor := DllCall("SetTextColor", "UInt", mDC, "UInt", ((TColour & 0xFF) << 16) + (TColour & 0xFF00) + ((TColour >> 16) & 0xFF), "UInt")
   
    If InStr(x, ":")
    {
        StringSplit, XRatio, x, :
        XPos := XRatio1*(Width//XRatio2)
    }
   Else
   XPos := x
   
    If InStr(y, ":")                                                                ; Get ratios of x and y position
    {
        StringSplit, YRatio, y, :
        YPos := YRatio1*(Height//YRatio2)
    }
   Else
   YPos := y
   
    StringSplit, Text, Text, `n
       
    Loop, %Text0%
    {   
        DllCall("TextOut", "UInt", mDC, "Int", XPos, "Int", YPos, "Str", Text%A_Index%, "UInt", StrLen(Text%A_Index%))
        YPos += 1.5*Size                                                            ; Draw text Into device
    }   
                                                                                   
    DllCall("SelectObject", "UInt", mDC, "UInt", #hOldFont)
    DllCall("DeleteObject", "UInt", #hFont)                                         ; Restore DC Font
       
    DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UInt", hBM, "UInt", 0, "UIntP", pImage)
   DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
   DllCall("DeleteObject", "Uint", hBM)
   DllCall("DeleteDC", "Uint", mDC)
    DllCall("gdiplus\GdipGetImageEncodersSize", "UIntP", nCount, "UIntP", nSize)    ; Get encoder
    VarSetCapacity(ci, nSize)
    DllCall("gdiplus\GdipGetImageEncoders", "UInt", nCount, "UInt", nSize, "UInt", &ci)
       
    Loop, %nCount%
    {
        nSize := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76 * (A_Index - 1) + 44), "Int", -1, "UInt", 0, "Int",  0, "UInt", 0, "UInt", 0)
        VarSetCapacity(sString, nSize)
        DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76 * (A_Index - 1) + 44), "Int", -1, "Str", sString, "Int", nSize, "UInt", 0, "UInt", 0)
   
        If !InStr(sString, Extension)                                               ; Find encoder matching extension
        Continue
        pCodec := &ci + 76 * (A_Index - 1)
        Break
    }
    If pImage                                                                     ; Save image to file
    {
        sString := Output
        nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0)
        VarSetCapacity(wString, nSize * 2)
        DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize)
   
        DllCall("gdiplus\GdipSaveImageToFile", "UInt", pImage, "UInt", &wString, "UInt", pCodec, "UInt", 0)
      DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
    }
    GoSub, TTS_GdiplusShutdown
    Return, XPos . "|" . YPos

   TTS_GdiplusShutdown:
    DllCall("gdiplus\GdiplusShutdown" , "UInt", pToken)                            ; Shutdown and free library
    DllCall("FreeLibrary", "UInt", hGdiPlus)
   Return
}
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Feb 26, 2008 9:55 pm    Post subject: Reply with quote

tic wrote:
Heres an updated function to capture chosen monitor(s).

Your definitions are inconsistent. Read again about SysGet and WinGetPos. I can see why Sean didn't like you copy his scripts.
Back to top
Guest






PostPosted: Tue Feb 26, 2008 10:39 pm    Post subject: Reply with quote

tic wrote:
Code:
; TextToImage v1.08 by tic
;
; TextToImage can overlay writing to a screenshot of the entire screen or active window, or from an existing image and write to file
; TextToImage(In, Text, Output, x, y, Font, TColour, Size, Weight)
;
; In: Can either be the "Screen" or "Window" and will take a screenshot of the respective choice, or the location of an exisitng image
;
; Text: This is the text to overlay onto the screenshot
;
; Output: This is the path and filename that the image will be written to.
; The extension can be .bmp,.jpg,.png,.tif,.gif and will be written as that type accordingly
;
; x: This is the x-coordinate to place the text. This coordinate will be the distance from the left the text will be placed.
; This value may be a ratio. For instance 4:5 would place the text at the position 4/5ths of the width of the image
; You must also consult which mode align is in
;
; y: This is the y-coordinate to place the text. This coordinate will be the distance from the top the text will be placed.
; This value may be a ratio. For instance 1:3 would place the text at the position 1/3ths of the height of the image
; You must also consult which mode align is in
;
; Size: This is the height of the text in pixels
;
; Align: This must have 2 styles set, The text's x placement (Left,Centre,Right) and the text's y placement (Top,Bottom)
; It must be used for example as Left|Bottom - This would place the text at the bottom of it's bounding area and aligned left
;
; Weight: This is the boldness of the text. Make the value greater to make it more bold
;
; Font: This is the font to set the text to be
; Examples are: Arial, Bookman Old Style, Times New Roman
;
; TColour: This is the colour to set the text in RGB format.
; So FF0000 is red
;
; Style: Can contain the words Underline,Italic,Strikeout and will set the text in the appropriate styles

TextToImage(In="Screen", Text="TextToImage", Output="TextToImage.bmp", x="1:2", y="1:2", Size="20", Align="Bottom|Centre", Weight="400", Font="Arial", TColour="000000", Style="")
{
    hGdiPlus := DllCall("LoadLibrary", "Str", "gdiplus.dll")
    VarSetCapacity(si, 16, 0), si := Chr(1)
    DllCall("gdiplus\GdiplusStartup", "UIntP", pToken, "UInt", &si, "UInt", 0)
   
    If In Contains Screen,Window
    {
        If (In = "Screen")
      {
         SysGet, nL, 76                                                ; Get coordinates for all monitors
         SysGet, nT, 77
         SysGet, nW, 78
         SysGet, nH, 79
      }
      Else If ((SubStr(In, 1, 6) = "Screen") && ((Substr(In, 0) & 1) != ""))
      {
         SysGet, Coords, Monitor, % Substr(In, 0)   ;%
         nL := CoordsLeft, nT := CoordsTop, nW := CoordsRight, nH := CoordsBottom
      }   
        Else If (In = "Window")
        {
            WinGetPos, nL, nT, nW, nH, A                                                ; Get coordinates for active window
            WinGet, ID, ID, A
            WinGetTitle, Title, A
            Winget, MinMax, MinMax, A
            If !(DllCall("IsWindowVisible", UInt, ID) && (Title) && (MinMax != -1))      ; Check active window is visible
            {
                GoSub, TTS_GdiplusShutdown
                Return, "Window is not visible"
            }
        }       
        mDC := DllCall("CreateCompatibleDC", "UInt", 0)
        NumPut(VarSetCapacity(bi, 40, 0), bi)
        NumPut(nW-nL, bi, 4)
        NumPut(nH-nT, bi, 8)
        NumPut(32, NumPut(1, bi, 12, "UShort"), 0, "UShort")
        hBM := DllCall("gdi32\CreateDIBSection", "UInt", mDC, "UInt", &bi, "UInt", 0, "UIntP", "", "UInt", 0, "UInt", 0)
        oBM := DllCall("SelectObject", "UInt", mDC, "UInt", hBM)                        ; Place bitmap object Into compatible DC
        hDC := DllCall("GetDC", "UInt", 0)                                             ; Get DC of screen and bitblt
      
        DllCall("BitBlt", "UInt", mDC
      , "Int", 0, "Int", 0
      , "Int", nW-nL, "Int", nH-nT
      , "UInt", hDC, "Int"
      , nL, "Int", nT
      , "UInt", 0x40000000|0x00CC0020)
    }
    Else
    {
        VarSetCapacity(wFile, StrLen(In)*2+2)
        DllCall("kernel32\MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &In, "Int", -1, "UInt", &wFile, "Int", VarSetCapacity(wFile)//2)
        DllCall("gdiplus\GdipCreateBitmapFromFile", "UInt", &wFile, "UIntP", pBitmap)

        If !pBitmap
        {
            Gosub, TTS_GdiplusShutdown
            Return, "Failed to load image"
        }
       
        DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "UInt", pBitmap, "UIntP", hBM, "UInt", 0)
      DllCall("gdiplus\GdipDisposeImage", "Uint", pBitmap)
        mDC := DllCall("CreateCompatibleDC", "UInt", 0)
        oBM := DllCall("SelectObject", "UInt", mDC, "UInt", hBM)
      hDC := DllCall("GetDC", "UInt", 0)
    }

    StringSplit, OutputArray, Output, .
    Extension := "." . OutputArray%OutputArray0%
    If Extension not in .bmp,.jpg,.png,.tif,.gif                                    ; Check file extension is correct
    {
        GoSub, TTS_GdiplusShutdown
        Return, "Invalid file extension. Only bmp,jpg,png,tif,gif are available"
    }

    VarSetCapacity(bm, 24, 0)
    If !DllCall("GetObject", "UInt", hBM, "Int", 24, "UInt", &bm)
    {
        GoSub, TTS_GdiplusShutdown
        Return, "GetObject failed on bitmap {" hBM "}"
    }
    Width := NumGet(bm, 4, "Int")                                                  ; Get properties of bitmap
    Height := NumGet(bm, 8, "Int")
    bpp := NumGet(bm, 18, "Ushort")
   
    DllCall("SetBkMode", "UInt", mDC, "UInt", 1)                                   ; Leave background untouched for background mix mode
    DllCall("SetGraphicsMode", "UInt", mDC, "UInt", 2)                            ; Set graphics mode for DC to allow world transformations                           

    VarSetCapacity(logfont, 60, 0)
   
    LogPixelsSY := DllCall("GetDeviceCaps", "UInt", hDC, "Int", 90)                 ; Number of pixels per logical inch along the screen height
    DllCall("ReleaseDC", "UInt", 0, "UInt", hDC)
    TextHeight := -(Size*logPixelsSY)/72
   
   NumPut(TextHeight, logfont, 0)                                       ; Set text height
   ;NumPut(TextWidth, logfont, 4) ; Change text width
   
    NumPut(Weight, logfont, 16)                                          ; Set text weight
   If InStr(Style, "Underline")                                       ; Set style to be either underline,italic,Strikeout
   NumPut(1, logfont, 21)
   If InStr(Style, "Italic")
   NumPut(1, logfont, 20)
   If InStr(Style, "Strikeout")
   NumPut(1, logfont, 22)
   
   NumPut(5, logfont, 26)                                             ; ClearType antialiasing XP and above only
   
    AlignWord := "Right,Top,Bottom,Centre,Left"
    AlignNum := "2,0,8,6,0"
   
    StringSplit, AlignWords, AlignWord, `,
    StringSplit, AlignNums, AlignNum, `,
   
    Loop, %AlignWords0%
    StringReplace, Align, Align, % AlignWords%A_Index%, % AlignNums%A_Index%, All
    StringSplit, Pos, Align, |
    Align := Pos1 | Pos2

    StringLeft, FaceName, Font, 32
    DllCall("lStrcpy", "UInt", &logfont + 28, "Str", FaceName)                       ; Set font
    DllCall("SetTextAlign", "UInt", mDC, "UInt", Align)                             ; Align text
    #hFont := DllCall("CreateFontIndirect", "UInt", &logfont)
    #hOldFont := DllCall("SelectObject", "UInt", mDC, "UInt", #hFont)                ; Change DC Font
    TColour := "0x" . TColour
    prevColor := DllCall("SetTextColor", "UInt", mDC, "UInt", ((TColour & 0xFF) << 16) + (TColour & 0xFF00) + ((TColour >> 16) & 0xFF), "UInt")
   
    If InStr(x, ":")
    {
        StringSplit, XRatio, x, :
        XPos := XRatio1*(Width//XRatio2)
    }
   Else
   XPos := x
   
    If InStr(y, ":")                                                                ; Get ratios of x and y position
    {
        StringSplit, YRatio, y, :
        YPos := YRatio1*(Height//YRatio2)
    }
   Else
   YPos := y
   
    StringSplit, Text, Text, `n
       
    Loop, %Text0%
    {   
        DllCall("TextOut", "UInt", mDC, "Int", XPos, "Int", YPos, "Str", Text%A_Index%, "UInt", StrLen(Text%A_Index%))
        YPos += 1.5*Size                                                            ; Draw text Into device
    }   
                                                                                   
    DllCall("SelectObject", "UInt", mDC, "UInt", #hOldFont)
    DllCall("DeleteObject", "UInt", #hFont)                                         ; Restore DC Font
       
    DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UInt", hBM, "UInt", 0, "UIntP", pImage)
   DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
   DllCall("DeleteObject", "Uint", hBM)
   DllCall("DeleteDC", "Uint", mDC)
    DllCall("gdiplus\GdipGetImageEncodersSize", "UIntP", nCount, "UIntP", nSize)    ; Get encoder
    VarSetCapacity(ci, nSize)
    DllCall("gdiplus\GdipGetImageEncoders", "UInt", nCount, "UInt", nSize, "UInt", &ci)
       
    Loop, %nCount%
    {
        nSize := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76 * (A_Index - 1) + 44), "Int", -1, "UInt", 0, "Int",  0, "UInt", 0, "UInt", 0)
        VarSetCapacity(sString, nSize)
        DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76 * (A_Index - 1) + 44), "Int", -1, "Str", sString, "Int", nSize, "UInt", 0, "UInt", 0)
   
        If !InStr(sString, Extension)                                               ; Find encoder matching extension
        Continue
        pCodec := &ci + 76 * (A_Index - 1)
        Break
    }
    If pImage                                                                     ; Save image to file
    {
        sString := Output
        nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0)
        VarSetCapacity(wString, nSize * 2)
        DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize)
   
        DllCall("gdiplus\GdipSaveImageToFile", "UInt", pImage, "UInt", &wString, "UInt", pCodec, "UInt", 0)
      DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
    }
    GoSub, TTS_GdiplusShutdown
    Return, XPos . "|" . YPos

   TTS_GdiplusShutdown:
    DllCall("gdiplus\GdiplusShutdown" , "UInt", pToken)                            ; Shutdown and free library
    DllCall("FreeLibrary", "UInt", hGdiPlus)
   Return
}
Back to top
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Tue Feb 26, 2008 11:19 pm    Post subject: Reply with quote

delete

Last edited by tic on Wed Feb 27, 2008 10:56 am; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Feb 26, 2008 11:51 pm    Post subject: Reply with quote

Replace
Code:
nL := CoordsLeft, nT := CoordsTop, nW := CoordsRight, nH := CoordsBottom

with
Code:
nL := CoordsLeft, nT := CoordsTop, nW := CoordsRight - CoordsLeft, nH := CoordsBottom - CoordsTop

and
Code:
nW-nL, nH-nT
with
Code:
nW, nH
in the following.

And, you're relying on the assumption that the monitor number is less than 10, which might not remain true. I'll not tell Sean about this.
Back to top
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Wed Feb 27, 2008 12:02 am    Post subject: Reply with quote

delete

Last edited by tic on Wed Feb 27, 2008 10:56 am; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Feb 27, 2008 12:07 am    Post subject: Reply with quote

tic wrote:
well thank you for the modifications, but i would hardly see it as being such a big deal that you claim "my definitions are incosistent".

You still don't get it. Your original script won't work correctly for "Screen" and "Window".
Back to top
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Wed Feb 27, 2008 12:12 am    Post subject: Reply with quote

delete.

Last edited by tic on Wed Feb 27, 2008 10:55 am; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 6 of 8

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group