ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA: Use AHK GUI to make translucent overlay over apps that are not skinnable

<< < (3/11) > >>

skwire:
Here, have a play with this.  Save this out to an AHK file and run it.  Bring up any window and press F1.  You should see the overlay and buttons for that window.  You can keep pressing F1 over whatever window is active and the script will re-create the overlay for that window.  It's more of a proof of concept for now than, say, final code.  When you're done playing, exit the script from its tray icon.  Bedtime for me but I'll check back in in the morning.


--- ---F1::
{
    Gui, 1: Destroy
    Gui, 2: Destroy

    ; Get stats for the active window.
    WinGetPos, X, Y, W, H, A

    ; Build out first GUI for the overlay.
    Gui, 1: +Toolwindow -Caption +Lastfound +AlwaysOnTop
   
    Gui, 1: Font, s22 ; Change the s# value to adjust font size.
    Gui, 1: Add, Text, xm+70 ym+5 w100 h25 0x200 vmyText, CAP1 ; Change the xm/ym values to position the text.
    Gui, 1: Font

    Gui, 1: Color, Green ; Change overlay colour here.

    Gui, 1: Show, % "x" . x . "y" . y . "w" . w . "h" . h, Overlay

    GUI_ID := WinExist()
    ; Set it transparent and make it click-through.
    WinSet, Transparent, 50         , % "ahk_id " . GUI_ID ; Change the numerical value for opaqueness amount.
    WinSet, ExStyle    , ^0x00000020, % "ahk_id " . GUI_ID ; Leave this value alone.

    ; Build out second GUI for the buttons.
    Gui, 2: Margin, 0, 0
    Gui, 2: +Toolwindow -Caption +Lastfound +AlwaysOnTop
    Gui, 2: Add, Button, x y w100 h25 vmyButton1 gonClick, Click 1
    Gui, 2: Add, Button, x y w100 h25 vmyButton2 gonClick, Click 2
    Gui, 2: Show, % "x" . ( x + w ) . " y" .  y
}
Return

onClick:
{
    Gui, 2: Submit, NoHide
    If ( A_GuiControl = "myButton1" )
    {
        ; Do stuff here.
        MsgBox, You clicked Button 1.
    }
    Else If ( A_GuiControl = "myButton2" )
    {
        ; Do other stuff here.
        MsgBox, You clicked Button 2.
    }
}
Return

dwilbank:
Well sir. I'm going to have to go to work tomorrow just to play with this.
Thanks, and will have a report for you soon!

dwilbank:
Cool.
I fooled with the color and font size and suspect I can change the font color too with a little research.
(What about the font itself? Or are we stuck with this Arial type font?)

The only thing left is to take out code, believe it or not.

All our machines run at the same screen resolution (1280x768), and our encoding app always runs full screen, so I don't need the overlays to be dynamically positioned at all.
Strict X and Y and W and H values which I can change by hand would be perfect. (I'll be spacing multiple colored boxes and up to 12 buttons all over the interface where there is unused space)

Will I be able to place buttons within the same space as the color overlay?

Can't wait to try v2!


--- ---F1::
{
    Gui, 1: Destroy
    Gui, 2: Destroy

    ; Get stats for the active window.
    WinGetPos, X, Y, W, H, A

    ; Build out first GUI for the overlay.
    Gui, 1: +Toolwindow -Caption +Lastfound +AlwaysOnTop
   
    Gui, 1: Font, s60 ; Change the s# value to adjust font size.
    Gui, 1: Add, Text, xm+570 ym+125 w100 h25 0x200 vmyText, EVDCAP 6 ; Change the xm/ym

values to position the text.
    Gui, 1: Font

    Gui, 1: Color, Red ; Change overlay colour here.

    Gui, 1: Show, % "x" . x . "y" . y . "w" . w . "h" . h, Overlay

    GUI_ID := WinExist()
    ; Set it transparent and make it click-through.
    WinSet, Transparent, 85         , % "ahk_id " . GUI_ID ; Change the numerical value for opaqueness

amount.
    WinSet, ExStyle    , ^0x00000020, % "ahk_id " . GUI_ID ; Leave this value alone.

    ; Build out second GUI for the buttons.
    Gui, 2: Margin, 0, 0
    Gui, 2: +Toolwindow -Caption +Lastfound +AlwaysOnTop
    Gui, 2: Add, Button, x y w100 h25 vmyButton1 gonClick, Click 1
    Gui, 2: Add, Button, x y w100 h25 vmyButton2 gonClick, Click 2
    Gui, 2: Show, % "x" . ( x + w ) . " y" .  y
}
Return

onClick:
{
    Gui, 2: Submit, NoHide
    If ( A_GuiControl = "NTSC" )
    {
        ; Do stuff here.
        MsgBox, (code for switching to NTSC to be inserted later)
    }
    Else If ( A_GuiControl = "PAL" )
    {
        ; Do other stuff here.
        MsgBox, (code for switching to PAL to be inserted later)
    }
}
Return

skwire:
I fooled with the color and font size and suspect I can change the font color too with a little research.
(What about the font itself? Or are we stuck with this Arial type font?)-dwilbank (September 12, 2009, 03:07 PM)
--- End quote ---

Yes, most everything about the font can be change e.g. colour, style, weight, etc.

All our machines run at the same screen resolution (1280x768), and our encoding app always runs full screen, so I don't need the overlays to be dynamically positioned at all.
Strict X and Y and W and H values which I can change by hand would be perfect. (I'll be spacing multiple colored boxes and up to 12 buttons all over the interface where there is unused space)-dwilbank (September 12, 2009, 03:07 PM)
--- End quote ---

I figured as much about the resolution.  As for multiple boxes, you will need to create a Gui instance for each.  If you want me to do it, I will need a screenshot with information showing what you want where.

Will I be able to place buttons within the same space as the color overlay?-dwilbank (September 12, 2009, 03:07 PM)
--- End quote ---

Yes.

dwilbank:
I could send a screenshot monday if you want, but I think I might have to position and reposition the boxes myself (probably two wide boxes, one filling the top of the screen, and one filling the bottom, leaving the middle open) several times before all my coworkers are happy.

Just separating the box size and position from the WinGetPos part of the code would allow me to do that.
I looked at the line that said:

Gui, 1: Show, % "x" . x . "y" . y . "w" . w . "h" . h, Overlay

and I couldn't figure out where I could type in numeric values to give a custom size and shape to the box.

So...

The 2nd Box would become GUI 2,

and if I plan to make, say, 12 buttons to launch 12 different video encoding profiles, those would become GUI 3 through GUI 14?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version