Advertisement
This is comment for paste
Outlook Ad Overlay Btn (discontinued, was meant for Time Saver).ahk
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;WinSetTransColor is better but here's some WinSetRegion test code:
- #Requires AutoHotkey 2.0
- #SingleInstance Force
- ; --- PART 1: Example Setup (You will replace this with your actual GUI/Window setup) ---
- ; Assume these are your main GUI's (the one that will get the hole) details
- ; These are the screen coordinates and dimensions you used to SHOW your main GUI.
- mainX := 100
- mainY := 100
- mainWidth := 600
- mainHeight := 400
- mainGui := Gui("-Caption")
- mainGui.Title := "Main GUI (Always On Top)"
- mainGui.BackColor := "Gray" ; To clearly see the hole
- mainGui.Opt("+AlwaysOnTop") ; Make it always on top
- mainGui.AddButton("x220 y350 w300", "Refresh e-mails")
- mainGui.Show("x" mainX " y" mainY " w" mainWidth " h" mainHeight)
- ; Assume these are your child window's (the one being covered) details
- ; These are the screen coordinates and dimensions of the window that will define the hole.
- childX := 450
- childY := 400
- childWidth := 300
- childHeight := 150
- childGui := Gui("-Caption")
- childGui.Title := "Child Window (Visible Through Hole)"
- childGui.BackColor := "Navy"
- childGui.Add("Text", "cWhite", "I am the child window!")
- childGui.Show("x" childX " y" childY " w" childWidth " h" childHeight)
- ; Give windows a moment to appear
- Sleep 100
- ; --- PART 2: Core Logic to Create the Hole in mainGui ---
- ; IMPORTANT: Get the *current actual screen position* of the main GUI.
- ; This is important in case it was moved after being shown.
- WinGetPos(&CurrentMainScreenX, &CurrentMainScreenY, &CurrentMainWidth, &CurrentMainHeight, "ahk_id " mainGui.Hwnd)
- ; 1. Calculate the hole's coordinates *relative to the main GUI's top-left corner (0,0)*
- ; The WinSetRegion command expects relative coordinates for both the outer and inner polygons.
- HoleLeftRelative := childX - CurrentMainScreenX
- HoleTopRelative := childY - CurrentMainScreenY
- HoleRightRelative := HoleLeftRelative + childWidth
- HoleBottomRelative := HoleTopRelative + childHeight
- ; 2. Construct the outer polygon string (representing the entire main GUI)
- ; Coordinates are 0-0 up to its current actual width and height.
- OuterPolygonString := "0-0 " CurrentMainWidth "-0 " CurrentMainWidth "-" CurrentMainHeight " 0-" CurrentMainHeight " 0-0"
- ; 3. Construct the inner polygon string (representing the hole)
- InnerPolygonString := ""
- InnerPolygonString .= HoleLeftRelative "-" HoleTopRelative " "
- InnerPolygonString .= HoleRightRelative "-" HoleTopRelative " "
- InnerPolygonString .= HoleRightRelative "-" HoleBottomRelative " "
- InnerPolygonString .= HoleLeftRelative "-" HoleBottomRelative " "
- InnerPolygonString .= HoleLeftRelative "-" HoleTopRelative ; Close the polygon
- ; 4. Combine the outer and inner polygons into the final region string
- RegionStringForWinSetRegion := OuterPolygonString " " InnerPolygonString
- ; 5. Apply the region to your main GUI
- WinSetRegion(RegionStringForWinSetRegion, "ahk_id " mainGui.Hwnd)
- ; --- PART 3: Event Handlers (for clean exit) ---
- mainGui_OnClose() {
- ExitApp
- }
- childGui_OnClose() {
- ExitApp
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement