Skip to content

Instantly share code, notes, and snippets.

View francisfeng's full-sized avatar
🤒
Working hard!

Francis Feng francisfeng

🤒
Working hard!
View GitHub Profile
@francisfeng
francisfeng / save-tabs-safari-anybox.applescript
Last active March 28, 2024 22:29
Save all tabs of Safari’s current window to Anybox
tell application "Safari"
repeat with tabItem in tabs of window 1
set link to URL of tabItem
tell application id "cc.anybox.Anybox"
save link
end tell
end repeat
end tell
@francisfeng
francisfeng / command-c.swift
Last active January 12, 2021 03:11
Simulating Command + C (aka Copy command) in macOS
// 0x08 is key code for "c"
guard let keydownEvent = CGEvent(keyboardEventSource: nil, virtualKey: 0x08, keyDown: true) else { return }
guard let keyupEvent = CGEvent(keyboardEventSource: nil, virtualKey: 0x08, keyDown: false) else { return }
keydownEvent.flags = CGEventFlags.maskCommand
keydownEvent.post(tap: CGEventTapLocation.cghidEventTap)
keyupEvent.flags = CGEventFlags.maskCommand;
keyupEvent.post(tap: CGEventTapLocation.cghidEventTap)
// For it to work, Accessibility needs to be enabled in