Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

WinCut - cut out piece of window on the fly


  • Please log in to reply
28 replies to this topic
Roland
  • Members
  • 307 posts
  • Last active: Mar 09 2014 07:55 PM
  • Joined: 08 Jun 2006

nicely done.

maybe a restore hotkey might be useful...

+#Esc::
WinSet, Region,, A
return

or such..


Thanks for the suggestion - has been added.

IceBrain
  • Guests
  • Last active:
  • Joined: --
Great script, I absolutely love it! Thank you very much for making this!

Andreone
  • Members
  • 257 posts
  • Last active: Mar 19 2008 05:30 PM
  • Joined: 20 Jul 2007

Do you get the gui when you drag?

Nope. I tried #InstallMousehook, not better.

msgbox % x "-" y " " x+w "-" y " " x+w "-" y+h " " x "-" y+h " " x "-" y

1052-815 1052-815 1052-815 1052-815 1052-815

If I set an arbitrary region, like
WinSet, Region, % wx "-" wy " W800 H600", ahk_id %win%, it works.
it works
but if I set
a:=wx+200
b:=wy+200
WinSet, Region, % wx "-" wy " " a "-" b, ahk_id %win%
it fails again.

Note: I'm running 1.0.47.4

Any idea? If I have the time, I'll try more testing later, but right now, I have to go back to my regular job, or I'll have trouble with my boss :wink:

vapor2
  • Members
  • 4 posts
  • Last active: Aug 11 2008 12:36 PM
  • Joined: 11 Sep 2007
Great script for learning WinSet!! I am attempting to make some mods to the script to enable multiple cuts (see code). However, with the mods I have made I seem to get a "shredded" window instead of nice neat cuts. Any suggestions?

#singleinstance force

+#lbutton::
hotkey, esc, cancel, on
cancel:=0
coordmode, mouse
mousegetpos, sx, sy, win
wingetclass, class, ahk_id%win%
if class in progman,shell_traywnd
  return
wingetpos, wx, wy,,, ahk_id%win%
gui, +lastfound +alwaysontop +toolwindow -caption
gui, color, 00ffff
winset, transparent, 50
gui, show, noactivate
loop {
    if !getkeystate("lbutton", "p")
      break
    ifequal, cancel, 1, gosub exit
    mousegetpos, x, y
    gui, show, % "x" sx "y" sy "w" x-sx "h" y-sy
  } wingetpos, gx, gy, w, h
gui, destroy
wingetpos, wx, wy,,, ahk_id%win%
x:=gx-wx, y:=gy-wy
a := "a" . win
b := %a%
b := b . x . "-" . y . " " . x+w . "-" . y . " " . x+w . "-" . y+h . " " . x . "-" . y+h . " " . x . "-" . y . " "
%a% := b
winset, region, % b, ahk_id%win%
hotkey, esc, cancel, off
return

cancel:
cancel:=1
return

exit:
hotkey, esc, cancel, off
gui destroy
exit

+#esc::
winset, region,, a
winget, win, id, a
a := "a" . win
%a% := ""
return


Vapor2

elinks
  • Guests
  • Last active:
  • Joined: --
Very cool,

I cant drag the window after I cut it out.

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007

No idea about the crashes Mustang gets. Though I've only used WinSet,Region a couple times, I've never had it crash the target app (or the script.)

Should have said before, Im running Aero theme

I'll try to explain what happens
In some windows, e.g. Internet Explorer, nothing happens
In other windows, e.g. AutoHotkey Help, I end up with just the titlebar (thought it has crashed because before you introduced the Escape hotkey I had to restart the app to get it working again)
And in another windows, e.g. AHK Gui, I end up with the titlebar and the border

All these varried results
None of which produced the desired result
So I gave up testing it for you and reported it as broken :cry:

vapor2
  • Members
  • 4 posts
  • Last active: Aug 11 2008 12:36 PM
  • Joined: 11 Sep 2007
To drag the window I discovered that <ALT><SPACE> combo still works and brings up the menu with the move option.
First click on the "CUT" window, then <ALT><SPACE> to bring up the move menu, Select move (the mouse will reposition to where the title bar used to be), then use the arrow keys to move the window (the mouse will be useless for this operation).

Edit: The mouse will be mostly useless :) You can drag around with the mouse after you use the arrow keys for an initial small move to lock the mouse cursor into move mode. But your mouse moves will be bounded by the screen boundaries whereas the arrow keys will allow moving the cut window to almost anywhere on the screen. This can potentially be very useful if you have multiple monitors (I don't).
Vapor2

Roland
  • Members
  • 307 posts
  • Last active: Mar 09 2014 07:55 PM
  • Joined: 08 Jun 2006

Do you get the gui when you drag?

Nope. I tried #InstallMousehook, not better.

msgbox % x "-" y " " x+w "-" y " " x+w "-" y+h " " x "-" y+h " " x "-" y

1052-815 1052-815 1052-815 1052-815 1052-815

If I set an arbitrary region, like
WinSet, Region, % wx "-" wy " W800 H600", ahk_id %win%, it works.
it works
but if I set
a:=wx+200
b:=wy+200
WinSet, Region, % wx "-" wy " " a "-" b, ahk_id %win%
it fails again.

Note: I'm running 1.0.47.4

Any idea? If I have the time, I'll try more testing later, but right now, I have to go back to my regular job, or I'll have trouble with my boss :wink:


It looks like the problem is with GetKeyState() - it doesn't 'see' that the left mouse button is down.

Roland
  • Members
  • 307 posts
  • Last active: Mar 09 2014 07:55 PM
  • Joined: 08 Jun 2006

Great script for learning WinSet!! I am attempting to make some mods to the script to enable multiple cuts (see code). However, with the mods I have made I seem to get a "shredded" window instead of nice neat cuts. Any suggestions?


I have never attempted anything like what you're trying to do... I took a quick look at it, but couldn't spot the problem. Maybe someone else can figure it out.

Roland
  • Members
  • 307 posts
  • Last active: Mar 09 2014 07:55 PM
  • Joined: 08 Jun 2006

I cant drag the window after I cut it out.


I recommend you try NiftyWindows.

Roland
  • Members
  • 307 posts
  • Last active: Mar 09 2014 07:55 PM
  • Joined: 08 Jun 2006

No idea about the crashes Mustang gets. Though I've only used WinSet,Region a couple times, I've never had it crash the target app (or the script.)

Should have said before, Im running Aero theme

I'll try to explain what happens
In some windows, e.g. Internet Explorer, nothing happens
In other windows, e.g. AutoHotkey Help, I end up with just the titlebar (thought it has crashed because before you introduced the Escape hotkey I had to restart the app to get it working again)
And in another windows, e.g. AHK Gui, I end up with the titlebar and the border

All these varried results
None of which produced the desired result
So I gave up testing it for you and reported it as broken :cry:


All I can say is that it works for me in all of the apps you mentioned.
Really have no idea what is causing your problems... Are you running some kind of Windows skin maybe or something? Just a thought...

Neodudeman
  • Members
  • 17 posts
  • Last active: Nov 22 2007 07:41 PM
  • Joined: 14 Mar 2007
For some reason, when I try to run this script, I get the error:

Error at line 31.

Line Text: cancel
Error: This line does not contain a recognized action.

The program will exit.


Which is weird, because it seems like no one else has a cancel problem.

I'm also running the most current version of AHK, so that's not it.

It's so weird. :cry:

---------------

EDIT:

I fixed it. Turned out that the cancel it was complaining about was a gosub label. So I just put the : in. Then it complained about the gosub exit not being found, so I found the exit label, and put in the : again. What a weird copy error.

So it turns out that when I copy/pasta'd it, it copied everything except the :'s. How Weird.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

... WinSet,Region doesn't seem to affect the glass frame (caption bar and border) around the window, other than making them unclickable. :shock:

Posted Image

I found a good workaround for this: disable the glass frame. (A non-Aero-style frame will instead be visible.)
if A_OSVersion = WIN_VISTA
    DllCall("dwmapi\DwmSetWindowAttribute","uint",win,"uint",2,"int*",1,"uint",4)
This sets the DWMWA_NCRENDERING_POLICY attribute to DWMNCRP_DISABLED. To reset it (i.e. from +#Esc), set it back to DWMNCRP_USEWINDOWSTYLE:
if A_OSVersion = WIN_VISTA
    DllCall("dwmapi\DwmSetWindowAttribute","uint",WinExist("A"),"uint",2,"int*",[color=green]0[/color],"uint",4)


Freddy
  • Members
  • 4 posts
  • Last active: Feb 08 2010 04:25 PM
  • Joined: 28 Jun 2009
Hello all! :)

And first of all, sorry that I'm reviving a two year old thread here...

It's just that I discovered a strange problem with the solution Lexikos gave here above.
It works perfectly in almost all cases, except that there are a couple of windows that refuse to cooperate... :p

For example this window:

Posted Image

which is one of the windows belonging to Windows Complete PC Backup.
As you can see, all Lexikos' code does for this window, is remove the window border and title bar completely, instead of replacing the glass border with a regular one. Using the second line of code to reset it, does nothing for these windows: the border stays gone.
I say windows because, besides this one here, the other windows belonging to Windows Complete PC Backup have the same problem, as does the installation confirmation window of Acronis True Image. And I assume there are more like these, but so far these are the ones that I have found.

Maybe it helps when I add that these windows also can not be made transparent, nor do they respond at all to the "WinSet, Region" command, nor can they be minimized, not even with their task bar button.

I'm asking for help here, as I would like to know:

1. Why does this happen?
2. How could I identify the windows that act this way, to make general exception rules for them?
3. And if possible, is there a workaround for this problem as well?

I really hope so!... Thanks in advance!

Freddy