[Script] WinHole

Post your working scripts, libraries and tools
Helgef
Posts: 2117
Joined: 17 Jul 2016, 01:02
Contact:

[Script] WinHole

15 Apr 2017, 18:22

Introduction
This is a script for making a see-through hole (circle) in the window under the mouse. The center of the hole follows the mouse, the hole can be inverted.

Preview
For a short video preview, visit sendvid.com. (Makes an inverted hole in a window which shows a cup of coffee, revealing the code for this script beneath, toggles inverted setting.)

Download

winhole.ahk
(3.91 KiB) Downloaded 80 times

How to use
Hotkeys:
  • Esc,exit script. Restores the window first, if needed.
  • F1 Toggle on/off.
  • F2 Toggle inverted setting when the toggle is on.
  • F3 Toggle pause when the toggle is on. When paused, the hole doesn't follow the mouse.
  • WheelUp Increases the radius of the hole
  • WheelDown Decreases the radius of the hole
Optional setup:
At the top of the script, these settings can be changed,
  • radius, the starting radius of the circle.
  • incrementthe amount to decrease/increase radius of circle when turning the scroll wheel.
  • inverted, If false, the region is see-throughable.
  • rate, the period (ms) of the timer.
For changing the shape of the hole, modify region, it should an array where each element is a pair of coordinates which forms a shape with closed boundary, eg, region:=[{x:x0,y:y0},{x:x1,y:y1},...,{x:xn,y:yn},{x:x0,y:y0}], where xk,yk are integers.

Additional regions
Put the functions in the code, and replace two occasions of region:=makeCircle(radius) with region:=x(radius).
A fancy heart

A regular triangle

About the implementaion
The hole is a polygon set by WinSet,Region, x-y....

Known issues and limitations

  • Very limited testing, only tested on 1.1.25.01 Unicode 64, Win7.
  • Tested only with the circle region.
  • Some windows doesn't seem to respond well to WinSet,Region,...
Misc
This was made for fun, if you make a custom shape, please share it, I'll link to it from this post :)
You may use this in any way and any context you like.
Good luck :wave:

Edit: Minor change in the heart code
Last edited by Helgef on 21 Apr 2017, 08:21, edited 2 times in total.
User avatar
tidbit
Posts: 977
Joined: 29 Sep 2013, 17:15
Location: USA

Re: [Script] WinHole

15 Apr 2017, 18:26

very interesting :idea:
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
Helgef
Posts: 2117
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Script] WinHole

16 Apr 2017, 02:00

tidbit wrote:very interesting :idea:
I actually found a real life application for it, I was going to upload the code for the script, so I had my file explorer open beneath my browser, the script was running so I made a hole in the browser, picked up the file, closed the hole and dropped the file in post editor. :lol:
Here is a custom region for you,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Put in script, and replace (at two places) region:=makeCircle(radius) with region:=heart4tidbit(radius). :thumbup:
hearth4tidbit.png
hearth4tidbit.png (55.17 KiB) Viewed 1086 times
Last edited by Helgef on 21 Apr 2017, 08:20, edited 1 time in total.
just me
Posts: 4589
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Script] WinHole

16 Apr 2017, 06:18

Hi Helgef,

good job!

If you want to play a bit more with it you might be interested in calling the Regions API directly:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


If you're interested you could complete the wrapper functions.
Remaining with AHK 1.1.25.02 until v2 will become beta.
Helgef
Posts: 2117
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Script] WinHole

16 Apr 2017, 09:56

Hi just me :mrgreen:
I took a quick look at your code, that seems much easier to work with. Nice one. :thumbup:
noname
Posts: 334
Joined: 19 Nov 2013, 09:15

Re: [Script] WinHole

17 Apr 2017, 01:25

I actually found a real life application for it


I was trying it when recording with audacity a youtube music video to get a look at the levels I could simply punch a hole in the fullscreen chrome window.
Win10 has some quirks when resizing ,this will be a quick shortcut.

The 2000 points limit looked overkill but seeing the circle code ........... :idea:

Thanks for annotating the code !
User avatar
Drugwash
Posts: 213
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: [Script] WinHole

20 Apr 2017, 06:29

Funny toy! :)
I'd upgrade it with an alternate option to show the entire window that's currently under cursor beneath the topmost window.
In example, if there is a full screen browser and a small Notepad window beneath it, activating the script would show the entire Notepad window as long as the cursor hovers within its boundaries. Maybe skip Desktop (or not).
A 'temporary' hotkey might come in handy too, in addition to the toggle - only show the hole while hotkey is kept pressed, close it when released.
User avatar
hoppfrosch
Posts: 280
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: [Script] WinHole

21 Apr 2017, 00:03

Just remembering the good ole times: Shimanov once build a donut shaped window .... tasty!
User avatar
Coderooney
Posts: 6
Joined: 23 Mar 2017, 22:41

Re: [Script] WinHole

21 Apr 2017, 01:08

Hehehe this is really cool!! For practical uses, you could even set up one of those Cardan grille codes:

Image
Helgef
Posts: 2117
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Script] WinHole

21 Apr 2017, 08:28

I'm glad you found it useful/funny/nostaligic/inspiring. :lol:

I've been thinking on some of the possibilites to cut windows for useful purposes, I'll probably won't bother with it much more though, but if I would, I'd use the functions by just me, just above.

Cheers.
Helgef
Posts: 2117
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Script] WinHole

22 Apr 2017, 04:26

SwissWin
This was done for experimental purposes, and requires the rgn_ functions a few post up, by just me.
SwissWin(state,mode:="swiss",inv:=false)
  • state, "on" or "off"
  • mode, "swiss" for cutting all controls, or "ctrl" for cutting one control.
  • inv, false or true for inverting the cut.
Hotkey descriptions:
  • F1, cuts out the non-control area of the window under the mouse.
  • F2, invert F1.
  • F3, cuts out all but the control under the mouse
  • F4, invert F2
  • F5, restore.
  • ESC, restore and exit.

Some windows have some control covering the whole window, in those cases the effect isn't really seen or hides the whole window.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Good luck.
Edit:
Drugwash wrote:Typo in the code: guiecape: --> guiescape:

Ty, fixed.
Last edited by Helgef on 22 Apr 2017, 05:29, edited 1 time in total.
User avatar
Drugwash
Posts: 213
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: [Script] WinHole

22 Apr 2017, 05:00

Typo in the code: guiecape: --> guiescape:
20170201225639
Posts: 23
Joined: 01 Feb 2017, 22:57

Re: [Script] WinHole

22 Apr 2017, 10:03

thanks for the nice utility.



here's a reasonably faithful reenactment of a recent situation where i used winhole to peek at a (auto-refresh) file that lists of the current content of important global arrays
https://my.mixtape.moe/kmpnfe.webm




a user experience observation: i find that i use this much more when i configure it so that the hole is created when some key is pressed down and destoryed upon keyup (as opposed to toggle on/off)

as in:

Code: [Select all] [Download] GeSHi © Codebox Plus

#h::
run winhole.ahk ; file is modified so hole is created in auto-execute section
Keywait h
Send {ESC}
return
Helgef
Posts: 2117
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Script] WinHole

22 Apr 2017, 12:01

@ A_Now :)
I'm glad you found it useful, I like your idea with the run,winhole.ahk hotkey. If you add

at the top of winhole.ahk, and eg,

Code: [Select all] [Download] GeSHi © Codebox Plus

; create the hole here, in the autoexecute section
keywait, esc, d
exit()

and finally, add

to your run,... script, then you can keep punshing holes through the windows beneath, by applying your run,... hotkey, then hit esc to close all holes. :lol:
20170201225639
Posts: 23
Joined: 01 Feb 2017, 22:57

Re: [Script] WinHole

24 Apr 2017, 14:08

this is awesome. thanks for sharing this tip!
when i posted the above i actually didn't realize that you can *activate* the window you see through the hole and select text etc (that is, activate it without destroying the hole). it's even more useful than i thought!

Return to “Scripts and Functions”

Who is online

Users browsing this forum: arcticir and 14 guests