AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WinCut - cut out piece of window on the fly
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Roland



Joined: 08 Jun 2006
Posts: 244

PostPosted: Sun Sep 09, 2007 12:47 pm    Post subject: Reply with quote

Joy2DWorld wrote:
nicely done.

maybe a restore hotkey might be useful...

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


or such..


Thanks for the suggestion - has been added.
Back to top
View user's profile Send private message
IceBrain
Guest





PostPosted: Sun Sep 09, 2007 10:04 pm    Post subject: Reply with quote

Great script, I absolutely love it! Thank you very much for making this!
Back to top
Andreone



Joined: 20 Jul 2007
Posts: 257
Location: Paris, France

PostPosted: Mon Sep 10, 2007 1:15 pm    Post subject: Reply with quote

Quote:
Do you get the gui when you drag?
Nope. I tried #InstallMousehook, not better.
Quote:
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
Code:
WinSet, Region, % wx "-" wy " W800 H600", ahk_id %win%, it works.
it works
but if I set
Code:
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
Back to top
View user's profile Send private message
vapor2



Joined: 11 Sep 2007
Posts: 4

PostPosted: Tue Sep 11, 2007 2:27 pm    Post subject: Reply with quote

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?

Code:

#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
Back to top
View user's profile Send private message
elinks
Guest





PostPosted: Wed Sep 12, 2007 2:13 am    Post subject: Reply with quote

Very cool,

I cant drag the window after I cut it out.
Back to top
Mustang



Joined: 17 May 2007
Posts: 415
Location: England

PostPosted: Wed Sep 12, 2007 2:31 am    Post subject: Reply with quote

lexikos wrote:
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 Crying or Very sad
Back to top
View user's profile Send private message
vapor2



Joined: 11 Sep 2007
Posts: 4

PostPosted: Wed Sep 12, 2007 12:09 pm    Post subject: Reply with quote

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 Smile 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
Back to top
View user's profile Send private message
Roland



Joined: 08 Jun 2006
Posts: 244

PostPosted: Wed Sep 12, 2007 9:24 pm    Post subject: Reply with quote

Andreone wrote:
Quote:
Do you get the gui when you drag?
Nope. I tried #InstallMousehook, not better.
Quote:
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
Code:
WinSet, Region, % wx "-" wy " W800 H600", ahk_id %win%, it works.
it works
but if I set
Code:
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.
Back to top
View user's profile Send private message
Roland



Joined: 08 Jun 2006
Posts: 244

PostPosted: Wed Sep 12, 2007 9:26 pm    Post subject: Reply with quote

vapor2 wrote:
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.
Back to top
View user's profile Send private message
Roland



Joined: 08 Jun 2006
Posts: 244

PostPosted: Wed Sep 12, 2007 9:28 pm    Post subject: Reply with quote

elinks wrote:

I cant drag the window after I cut it out.


I recommend you try NiftyWindows.
Back to top
View user's profile Send private message
Roland



Joined: 08 Jun 2006
Posts: 244

PostPosted: Wed Sep 12, 2007 9:33 pm    Post subject: Reply with quote

Mustang wrote:
lexikos wrote:
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 Crying or Very sad


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...
Back to top
View user's profile Send private message
Neodudeman



Joined: 14 Mar 2007
Posts: 17

PostPosted: Sat Sep 15, 2007 2:45 am    Post subject: Reply with quote

For some reason, when I try to run this script, I get the error:

Quote:

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. Crying or Very sad

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

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.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2699
Location: Australia, Qld

PostPosted: Thu Nov 08, 2007 4:02 am    Post subject: Reply with quote

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

I found a good workaround for this: disable the glass frame. (A non-Aero-style frame will instead be visible.)
Code:
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:
Code:
if A_OSVersion = WIN_VISTA
    DllCall("dwmapi\DwmSetWindowAttribute","uint",WinExist("A"),"uint",2,"int*",0,"uint",4)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group