         // Insert code here to tear down your application
     }
 
-    func initStatusMenu() {
+    private func getDesktopWindowNumber() -> Int {
+        let options = CGWindowListOption(arrayLiteral: CGWindowListOption.OptionOnScreenOnly)
+        let infoList = CGWindowListCopyWindowInfo(options, CGWindowID(0))
+
+        for winDict in (infoList as NSArray? as? [[String: AnyObject]])! {
+            let layer = winDict["kCGWindowLayer"] as! Int
+            let winOwnerName = winDict["kCGWindowOwnerName"] as! NSString
+            let winNumber =  winDict["kCGWindowNumber"] as! Int
+
+            if layer < 0 && winOwnerName == "Finder" {
+                return winNumber
+            }
+        }
+        return 0
+    }
+
+    private func postKeyDownAndUpEvents(keyCode: CGKeyCode, command:Bool, control:Bool, shift:Bool) {
+        // there should be a better way...
+        let flags = CGEventFlags(rawValue:
+            ((command ? CGEventFlags.MaskCommand.rawValue : 0) |
+                (control ? CGEventFlags.MaskControl.rawValue : 0) |
+                (shift ? CGEventFlags.MaskShift.rawValue : 0)))!
+
+        let src = CGEventSourceCreate(CGEventSourceStateID.HIDSystemState)
+        let keyDownEvent = CGEventCreateKeyboardEvent(src, keyCode, true)
+        let keyUpEvent = CGEventCreateKeyboardEvent(src, keyCode, false)
+
+        CGEventSetFlags(keyDownEvent, flags)
+        CGEventSetFlags(keyUpEvent, flags)
+        
+        let location = CGEventTapLocation.CGHIDEventTap
+        CGEventPost(location, keyDownEvent)
+        CGEventPost(location, keyUpEvent)
+    }
+
+    private func initStatusMenu() {
         statusItem.image = NSImage(named: "StatusBarIcon")
         statusItem.menu = self.statusMenu
         statusMenuFirst.view = self.statusMenuFirstView
     }
 
-    func initAboutWindow() {
+    private func initAboutWindow() {
         window.orderOut(self)
         if #available(OSX 10.10, *) {
             window.titlebarAppearsTransparent = true

            if tabSwitching {
                let windowLoopForwarad = (event.scrollingDeltaX > 0)
                if windowLoopForwarad {
                    postKeyDownAndUpEvents(CGKeyCode(kVK_ANSI_RightBracket), command: true, control: false, shift: true)
                } else {
                    postKeyDownAndUpEvents(CGKeyCode(kVK_ANSI_LeftBracket), command: true, control: false, shift: true)
                }
            } else {
                let windowLoopForwarad = (event.scrollingDeltaY > 0)
                postKeyDownAndUpEvents(CGKeyCode(kVK_F4), command: false, control: true, shift: !windowLoopForwarad)
            }
        }
    }

    @IBOutlet weak var intervalSlider: NSSlider!
    @IBOutlet weak var imageViewInAboutPanel: NSImageView!

    private var enabled : Bool = true
    private var switchInterval : Double = 0.0
    private var prevEventTimestamp : NSTimeInterval = 0
    private let defaults = NSUserDefaults.standardUserDefaults()
    private let statusItem: NSStatusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)

    func applicationDidFinishLaunching(aNotification: NSNotification) {

