Jump to content

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

Cut away parts of a window


  • Please log in to reply
16 replies to this topic
anhcamlinh
  • Members
  • 10 posts
  • Last active: Jan 13 2006 10:09 AM
  • Joined: 21 Nov 2005

;CutAway
;Cut away parts of a window using the left mouse button.
;Undo the cutting with the right mouse button.

Window=noclick

START:
MouseGetPos,x1,y1,window
x1+=15
y1+=15
ToolTip,Leftclick and drag to cut`nRightclick or ESC to undo,%x1%,%y1%
Goto,START

LButton::
ToolTip
LOOP:
MouseGetPos,x2,y2
x2-=%x1%
y2-=%y1%
If x2<0
{
  x2-=1
  If x2>-30
    x2=-30
}
else
{
  x2+=1
  If x2<30
     x2=30
}
If y2<0
{
  y2-=1
  If y2>-30
    y2=-30
}
else
{
  y2+=1
  If y2<30
     y2=30
}
WinSet,Region,%x1%-%y1% W%x2% H%y2%,ahk_id %window%
GetKeyState,LButtonState,LButton,P
If LButtonState = U
  ExitApp
Goto,LOOP
Return

ESC::
RButton::
If window=noclick
  MouseGetPos,,,window
WinSet,Region,,ahk_id %window%
ExitApp

Your code has worked not well. In particular, it didn't cutaway when I drag from pointA to pointB. I re-editted your code to fix it. I copied this line Winset ... to the subpart of "If LButtonState = U"...
However, your code still has not worked well if I click one. In particular, I click one, and I think that the cut window will become a small rectangular with the center is the pointer position, but your code is not as my thought. I have re-editted the code as following:
width = 100
height = 100

START:
MouseGetPos,x1,y1
ToolTip,Leftclick and drag to cut`nRightclick or ESC to undo,%x1%,%y1%
Goto,START

LButton::
ToolTip
topLeftX := x1 - width/2
topLeftY := y1 - height/2

LOOP:
MouseGetPos,x2,y2,window

if x1 <> %x2%
{
    topLeftX := x1
    topLeftY := y1
    width := x2 - x1
    height := y2 - y1
}

GetKeyState,LButtonState,LButton,P
If LButtonState = U 
    WinSet,Region,%topLeftX%-%topLeftY% W%width% H%height%,ahk_id %window%   
else
  Goto LOOP
ExitApp  

ESC::
RButton::
Winget actWinId, ID, A
WinSet,Region,,ahk_id %actWinId%
ExitApp


tommy
  • Members
  • 84 posts
  • Last active: Nov 03 2014 06:15 AM
  • Joined: 05 Oct 2010
is there a reason this cut away script wont work in windows 7. it will cut the window - i just cant get it to esc or right-click back to the normal window.