WinSetTransColor apparently missing

Issue #19 closed
Winter Laite created an issue

I see “WinGetTransColor” is available, but apparently not “WinSetTransColor”

Comments (6)

  1. Winter Laite reporter

    Discovered when trying to port this code:

    MyGui := Gui()
    MyGui.Opt("+AlwaysOnTop -Caption +ToolWindow")  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
    MyGui.BackColor := "EEAA99"  ; Can be any RGB color (it will be made transparent below).
    MyGui.SetFont("s32")  ; Set a large font size (32-point).
    CoordText := MyGui.Add("Text", "cLime", "XXXXX YYYYY")  ; XX & YY serve to auto-size the window.
    ; Make all pixels of this color transparent and make the text itself translucent (150):
    WinSetTransColor(MyGui.BackColor " 150", MyGui)
    SetTimer(UpdateOSD, 200)
    UpdateOSD()  ; Make the first update immediate rather than waiting for the timer.
    MyGui.Show("x0 y400 NoActivate")  ; NoActivate avoids deactivating the currently active window.
    
    UpdateOSD(*)
    {
        MouseGetPos &MouseX, &MouseY
        CoordText.Value := "X" MouseX ", Y" MouseY
    }
    

  2. Winter Laite reporter

    As an aside, the following code works in Keysharp, although of course WinSetTransColor is absent.

    The functioning of MouseGetPos in Keysharp seems to be a bit different from that of AHK.

    MyGui := Gui()
    MyGui.Opt("+AlwaysOnTop -Caption +ToolWindow")  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
    MyGui.BackColor := "EEAA99"  ; Can be any RGB color (it will be made transparent below).
    MyGui.SetFont("s32")  ; Set a large font size (32-point).
    CoordText := MyGui.Add("Text", "cLime", "XXXXX YYYYY")  ; XX & YY serve to auto-size the window.
    ; Make all pixels of this color transparent and make the text itself translucent (150):
    ; WinSetTransColor(MyGui.BackColor " 150", MyGui)
    SetTimer("UpdateOSD", 200)
    UpdateOSD()  ; Make the first update immediate rather than waiting for the timer.
    MyGui.Show("x0 y400 NoActivate")  ; NoActivate avoids deactivating the currently active window.
    
    UpdateOSD()
    {
        Result := MouseGetPos()
        CoordText.Text := ("X: " Result["X"] " Y: " Result["Y"])
    }
    

    Note the need to use ‘CoordText.Text’ instead of ‘CoordText.Value’ as I’ve written it. Perhaps there is another way.

    (The coordinates reported by this last script appear to be very accurate - the AHK code, not so much.)

  3. Winter Laite reporter

    I note (with egg on my face) that ‘CoordText’ instead of ‘CoordText.Text’ works fine.

  4. Winter Laite reporter

    8/26/2022 - after today’s commit, the code above works with the change below. Works great.

    ; Make all pixels of this color transparent and make the text itself translucent (150):
    WinSetTransColor(MyGui.BackColor " 150", MyGui)
    

    Please mark as resolved and close. Thank you!

  5. Log in to comment