         let captureGuideView = CaptureGuideView(frame: self.frame)
         return captureGuideView
     }()
+    
+    private var mouseLocation: NSPoint {
+        return NSPoint(x: NSEvent.mouseLocation().x - frame.origin.x, y: NSEvent.mouseLocation().y - frame.origin.y)
+    }
     
     override init(contentRect: NSRect, styleMask style: NSWindowStyleMask, backing bufferingType: NSBackingStoreType, defer flag: Bool) {
         super.init(contentRect: contentRect, styleMask: .borderless, backing: .buffered, defer: false)

    }
    
    private func capture(rect: NSRect) {
        var upRightPoint = NSPoint.zero
        
        NSScreen.screens()?.forEach {
            upRightPoint = NSPoint(x: max(upRightPoint.x, $0.frame.origin.x + $0.frame.width), y: max(upRightPoint.y, $0.frame.origin.y + $0.frame.height))
        }
        
        var originY = CGFloat(0)
        if frame.origin.y > 0 {
            originY = upRightPoint.y - frame.origin.y - frame.height - (rect.height + rect.origin.y)
        } else {
            originY = NSScreen.main()!.frame.height - frame.origin.y - (rect.origin.y + rect.height)
        }
        
        let cgRect = CGRect(x: rect.origin.x + frame.origin.x, y: originY, width: rect.width, height: rect.height)
        guard let cgImage = CGWindowListCreateImage(cgRect, .optionOnScreenBelowWindow, CGWindowID(windowNumber), .bestResolution) else {
            return
        }
        
        captureGuideView.reset()
        orderOut(nil)
        
        var captureOffsetY = CGFloat(0)
        if frame.origin.y > 0 {
            captureOffsetY = frame.origin.y - (cgRect.origin.y + cgRect.height)
        } else {
            captureOffsetY = -(cgRect.origin.y - upRightPoint.y + rect.height)
        }
        captureDelegate?.didCaptured(rect: CGRect(x: cgRect.origin.x, y: captureOffsetY, width: cgRect.width, height: cgRect.height), image: cgImage)
    }
}


    
    func startCapture() {
        orderBack(nil)
        captureGuideView.cursorPoint = mouseLocation
    }
    
    override func mouseMoved(with event: NSEvent) {
        captureGuideView.cursorPoint = mouseLocation
    }
    
    override func mouseDown(with event: NSEvent) {
        captureGuideView.startPoint = mouseLocation
        captureGuideView.cursorPoint = mouseLocation
    }
    
    override func mouseDragged(with event: NSEvent) {
        captureGuideView.cursorPoint = mouseLocation
    }
    
    override func mouseUp(with event: NSEvent) {
