AHK: How to change window transparency when window is not active? - user-interface

I would like to change the GUI to transparent when the window is not active.

Add this in the beginning of the code:
OnMessage(0x06, "WM_ACTIVATE") ;TRIGGER FUNCTION WHEN WINDOW'S ACTIVE STATUS IS CHANGED
Add this function to your code:
WM_ACTIVATE()
{
IfWinActive, MyWindow
WinSet, Transparent, 255, MyWindow ; TRANSPARENCY OFF
else
WinSet, Transparent, 200, MyWindow ; SET TRANSPARENCY BETWEEN 0-255
}

Related

CATScript - Text, Lines and Frames in Black

The code is as below (CATScript):
Sub CATMain()
' enter sheet background
Set oView = oDrawingDocument.DrawingRoot.ActiveSheet.Views.Item("Background View")
oView.Activate
' select all views in current screen
Set oSelection = oDrawingDocument.Selection
oSelection.Search "Type=*,scr"
' set visual to black
oSelection.VisProperties.SetRealColor 0, 0, 0, 0
' exit sheet background
Set oView = oDrawingDocument.DrawingRoot.ActiveSheet.Views.Item("Main View")
oView.Activate
End Sub
The code works seamlessly except that oSelection.VisProperties.SetRealColor 255, 255, 255, 0 does not change any of the selected lines and frames to black in my 2D drawing. Manually I can do this so pretty sure I'm just using the wrong syntax. SetVisibleColor neither works, but then also I can only find that these syntaxes are used for changing color in 3D and I am using it for a 2D drawing. Anyone here knows the syntax to manipulate the color icon in the 'Graphic Properties' workspace for a 2D drawing?
This is the solution I found after some research and trial&error:
'CHANGE LINE COLOR
Set oSelectionGI = oDrawingDocument.Selection
oSelectionGI.Search("CATDrwSearch.CATEarlyGenItem,all")
oSelectionGI.VisProperties.SetRealColor 0,0,0,0
'CHANGE TEXT COLOR
Set oSelectionDC = oDrawingDocument.Selection
oSelectionDC.Search("CATDrwSearch.DrwText,all")
oSelectionDC.VisProperties.SetRealColor 0,0,0,0
'CHANGE TABLE COLOR
Set oSelectionDT = oDrawingDocument.Selection
oSelectionDT.Search("CATDrwSearch.DrwTable,all")
oSelectionDT.VisProperties.SetRealColor 0,0,0,0

Swift sender tint color

I'm working on a tic tac toe game where each square is its own button and the image of the button changes when the square is tapped. I have done this by connecting all of the square buttons to the same IBAction #IBAction func buttonPressed(sender: AnyObject) and by using sender.setImage() to change the image. The problem is, the images are all blue. I can change this blue to a different color by changing the global tint color, but what I really want is for the O and X images to be different colors. sender.tintColor throws an error and button.tintColor, as I have in the code below, just changes the color of one image back and forth every time a square is tapped. I have tried setting the global tint to no color in the File Inspector, but it just goes back to the default blue. Any thoughts?
if activePlayer == 1 {
sender.setImage(UIImage(named: "o-img"), forState: .Normal)
activePlayer = 2
button.tintColor = UIColor.blackColor()
} else {
sender.setImage(UIImage(named: "x-img"), forState: .Normal)
activePlayer = 1
button.tintColor = UIColor.whiteColor()
}
When you drag the image to the view controller's code to connect, before clicking "Ok" change the sender to UIImage instead of AnyObject.
You need to disable the button so the next player can not tap on it.
sender.enabled = false
As it turns out, changing the button type from 'System' to 'Custom' removes the tint. Hope that helps someone else who came across the same issue!

Inactive caption text color in Windows 10

In Windows 10, how do you get the color of inactive caption text?
In the example below, "Untitled - Notepad" is gray when window is inactive:
But the color I get is black when I try the following functions:
color = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
//color = black, wrong
HTHEME htheme = OpenThemeData(hwnd, L"WINDOW");
color = GetThemeSysColor(htheme, COLOR_INACTIVECAPTIONTEXT);
//color = black, wrong
GetThemeColor(htheme, WP_CAPTION, CS_INACTIVE, TMT_TEXTCOLOR, &color);
//color = black, wrong
DrawThemeText and DrawThemeTextEx also print the inactive caption in black.
All of these functions work fine in Windows 7 because inactive caption remains the same color, only the Aero glass thing changes color. But it's not the same in Windows 10.

How to change back color of button

So I am creating a program and I have one button and need to change the background color from yellow to green and back again for an infinite amount of times. How do I do this?
I can make one button change to one color but I cannot make one button change between two colors.
here is an examples to change a button between colors
this will change the color of a button everytime you click it
if Button1.BackColor = Color.FromArgb(0, 128, 0) then
Button1.BackColor = Color.FromArgb(255,255,0)
else
Button1.BackColor = Color.FromArgb(0, 128, 0)
end if

Setting a windows region without disabling theming

Does anyone know how to assign a window region (SetWindowRgn or Control.Region in WinForms) without killing the theming in the non-client area?
For example, running the following generates a Windows 2000-style unthemed title bar, border, etc:
var form = new Form { Width=500, Height=500, BackColor = Color.Azure };
form.Text = "But soft, what light through yonder window breaks?";
var region = new Region (new Rectangle (Point.Empty, form.Size));
region.Exclude (new Rectangle (100, 100, 300, 300));
form.Region = region;
form.ShowDialog();
I'm guessing it's to do with this MSDN article which says:
As long as a window has a non-NULL
region applied to it (SetWindowRgn),
the UxTheme Manager assumes that this
is a specialized window and the window
will not use visual styles.
...hence UxThemes assumes it's a specialized window. Is there a way to tell the UxTheme Manager explicitly to theme a window?
The answer to your question is that you cannot.
But a workaround, to give you a transparent section in your form, would be to add the WS_EX_LAYERED extended window style to your form. Then you can tell the Window Manager that you want to use a chroma-color key to make part of your form transparent:
SetLayeredWindowAttributes(
Form.Handle, // __in HWND hwnd,
RGB(0, 255, 0), //green is the color key __in COLORREF crKey,
255, //window is opaque otherwise __in BYTE bAlpha,
LWA_COLORKEY //use color-key (rather than per-pixel alpha) __in DWORD dwFlags
);
Then you can put your "transparent" area as lime green:
Which then at runtime will be transparent:
Update: When i use layered window to have full transparency mouse events do trickle through to what's underneath. Notice the "flag" icon highlight:
See also
Window Overview -> Window Features -> Layered Windows
SetLayeredWindowAttributes Function
Extended Window Styles
Layered Windows

Resources