From 65ee965b9d469a2b1d7baec3e8c333b4643cb07b Mon Sep 17 00:00:00 2001 From: LeeeSe <724818342@qq.com> Date: Tue, 7 May 2024 16:52:08 +0800 Subject: [PATCH] Bump version to 0.8.4 in Cargo.toml --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 10 ++-- docs/README-EN.md | 114 +------------------------------------------- src/float_window.rs | 12 +++-- src/lib.rs | 30 ++++++++---- ui/info.plist | 2 + 7 files changed, 41 insertions(+), 131 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 454c3ac..7be1631 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "MessAuto" -version = "0.8.3" +version = "0.8.4" dependencies = [ "arboard", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 63870da..1b97952 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "MessAuto" -version = "0.8.3" +version = "0.8.4" edition = "2021" description = "Automatic extraction of Email and SMS verification code for Mac platform." diff --git a/README.md b/README.md index 049c6b4..8cd0f17 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,10 @@ ARM64 版本打开时会提示文件损坏,因其需要 Apple 开发者签名 - 移动 MessAuto.app 到 `/Applications` 文件夹下 - 终端执行`xattr -cr /Applications/MessAuto.app` -如果 MessAuto 出现无法自动粘贴验证码的问题,一般出现在重新安装新版本时,可以尝试以下解决方案: +如果 MessAuto 出现无法自动粘贴验证码的问题,一般是没有辅助功能权限或者自动化权限,可以尝试以下解决方案: -打开系统偏好设置 -> 安全性与隐私 -> 辅助功能,将其中 MessAuto 删除,并添加新的 MessAuto.app +1. 打开系统偏好设置 -> 安全性与隐私 -> 辅助功能,将其中 MessAuto 删除,并添加新的 MessAuto.app +2. 运行`tccutil reset AppleEvents com.doe.messauto`来重置 MessAuto 的自动化权限,然后重启应用并不断勾选自动粘贴选项来让 MessAuto 主动发起自动化权限请求 ## TODO @@ -104,6 +105,7 @@ macOS 平台可以方便地接收来自 iPhone 的短信,无需每次打开手 - 邮件 App 需要常驻后台,否则无法实时获取到最新的邮件 - 完全磁盘访问权限(为了访问位于 `~/Library` 下的 `Message.app` 的 `chat.db` 文件,以获取最新的短信) - 辅助功能权限(模拟键盘操作,自动粘贴并回车) +- 自动化权限(模拟键盘操作,位置:设置->安全性与隐私->隐私->自动化,此权限只能程序主动请求用户同意,用户无法主动授予) ## 已知缺陷 @@ -121,7 +123,7 @@ cd MessAuto cargo run # 安装 cargo-bundle -cargo install cargo-bundle +cargo install cargo-bundle --git https://github.com/zed-industries/cargo-bundle.git --branch add-plist-extension # 打包应用 cargo bundle --release ``` @@ -137,7 +139,7 @@ cargo bundle --release - 给了权限但还是弹出权限请求:暂时的解决方法是从设置面板的辅助功能和磁盘权限列表中将原来的 MessAuto 通过下面的"-"号移除,当再次弹出权限请求时正常同意即可工作 -- 如果 MessAuto 出现无法自动粘贴验证码的问题,一般出现在重新安装新版本时,可以尝试:打开系统偏好设置 -> 安全性与隐私 -> 辅助功能,将其中 MessAuto 删除,并添加新的 MessAuto.app +- 权限都给了,验证码可以提取到剪贴板但不会自动粘贴,可能是程序初次请求自动化权限用户拒绝或直接忽略了,这个权限的位置在:设置->安全性与隐私->隐私->自动化,用户无法直接添加,只能通过程序再次请求,所以只能通过重置权限的方式解决,运行这条命令并重启程序:`tccutil reset AppleEvents com.doe.messauto`,反复勾选自动粘贴选项来触发自动化权限请求:`tccutil reset AppleEvents com.doe.messauto` ## 感谢 diff --git a/docs/README-EN.md b/docs/README-EN.md index d1b4f70..2a34ea6 100644 --- a/docs/README-EN.md +++ b/docs/README-EN.md @@ -1,113 +1 @@ -

- -

- -

- [中文] [English]
-

- -# MessAuto - -MessAuto is a macOS app that automatically extracts Email and SMS verification codes to pasteboard. It is 100% developed -with Rust and is suitable for any app. It is a free alternative to [2FHey](https://2fhey.com/). - -The following GIF shows the process of completing SMS verification and login within ten seconds with the support of -MessAuto. After clicking the button, you only need to wait for about 5 seconds. - -

-Verification-in-10s.gif -

- -Features: - -- Not just iMessage.app, but Mail.app too! -- Multi-language support: currently supports Chinese, English, and Korean; automatically switches based on the system - language. -- Light-weight: the app occupies 4 M storage and 14 M memory. -- Concise: without GUI, only a quiet taskbar tray icon, but powerful. -- Wide applicability: the Safari plan can only be used in the Safari browser, and this app is suitable for any app. -- Open source and free: the fee-based plan [2FHey](https://2fhey.com/) requires at least $5. - -## Usage - -MessAuto is a menu bar app without GUI. When you launch it for the first time, MessAuto will pop up a window to guide -you to authorize full disk access permission. - -After granting permission, you can see the MessAuto icon in the menu bar by restarting the app. Click the icon to list -the menu: - -- Auto paste: MessAuto stores the detected verification code in your clipboard. If you don't want to paste it manually, - you can enable this option. When this option is enabled, MessAuto will actively remind you to authorize the - accessibility feature. -- Auto enter: one step further than auto paste. Only when auto paste is enabled, can auto enter be selected. -- Hide for now: temporarily hide the icon. The icon will reappear when the app is restarted, suitable for users who do - not often restart the Mac. -- Hide forever: permanently hide the icon. Even if the app is restarted, the icon will not appear again. This is - suitable for users who restart Mac frequently. If you need to show the icon again, you need to delete - the `~/.config/messauto/messauto.json` file and restart the app. -- Launch at login: Nobody doesn't open it, right? -- Configuration: click on it will open a configuration file in json format, in which you can customize the keywords -- Listen email: turn on to listen to emails at the same time - -> Keywords: also called trigger words, when the message contains keywords such as "verification code", the program will -> perform a series of subsequent operations, otherwise the message will be ignored. - -

-statesitem.jpg -

- -⚠️ Note that the ARM64 version will prompt a file damage when opened because it needs Apple developer signature to start -normally. The author does not have an Apple developer certificate. However, you can still solve the problem through one -command: - -- Move MessAuto.app to the `/Applications` folder. -- Execute `xattr -cr /Applications/MessAuto.app` in Terminal. - -## TODO - -- [x] Optimize CAPTCHA extraction rules -- [x] Customized Keywords -- [x] Add configuration options to the menu -- [ ] ~~Automatic deletion of extracted CAPTCHA text messages (no valid ideas)~~ -- [x] In-App Updates -- [x] Github Action automated release -- [x] Add log -- [ ] Make App Home Page -- [x] Add email verification code detection function - -## Motivation - -macOS can conveniently receive short messages from the iPhone without having to open the phone to check the verification -code every time. Safari can even directly obtain the verification code and display it in the input box automatically. -However, this useful feature is only available in Safari, but not everyone likes to use it. In order to bring this -feature to all apps, I developed this app. - -In the subsequent use, I also found that many verification codes are not only sent via SMS, but also via email, so I -added support for email. - -## Requirements - -- Use a **macOS system** and can receive **messages** from an iPhone. -- The Mail app needs to be resident in the background, otherwise the latest email cannot be obtained in real time. -- Full disk access permission (to access the `chat.db` file in `~/Library/Message.app` to get the latest message.) -- Accessibility permissions (simulates keyboard operations, auto paste and enter) - -## Known issues - -- Some apps or websites do not support Enter login and require manual clicking of login. - -## Build - -- `git clone https://github.com/LeeeSe/MessAuto.git` -- `cd MessAuto` -- `cargo install cargo-bundle` -- `cargo bundle --release` - -## Thanks - -* Thanks to [@尚善若拙](https://sspai.com/post/73072) for providing ideas for obtaining SMS. - -## Log directory - -Log file directory: `~/.local/share/messauto/logs/messauto.log` -Keep only the log of the most recent startup of the software +TODO. diff --git a/src/float_window.rs b/src/float_window.rs index ef74959..e344bca 100644 --- a/src/float_window.rs +++ b/src/float_window.rs @@ -91,11 +91,15 @@ pub fn main(code: &str, from_app: &str) -> Result<(), slint::PlatformError> { let old_clpb_contents = get_old_clipboard_contents(); clpb.set_text(captcha.as_str()).unwrap(); - paste_script().unwrap(); - info!("{}", t!("paste-verification-code")); + match paste_script() { + Ok(_) => info!("{}", t!("paste-verification-code")), + Err(e) => error!("{}: {:?}", t!("error-paste-verification-code"), e), + } if config.auto_return { - return_script().unwrap(); - info!("{}", t!("press-enter")); + match return_script() { + Ok(_) => info!("{}", t!("press-enter")), + Err(e) => error!("{}: {:?}", t!("error-press-enter"), e), + } } if config.recover_clipboard { sleep(Duration::from_secs(2)); diff --git a/src/lib.rs b/src/lib.rs index 5aafdc7..9ed4824 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -455,11 +455,15 @@ pub fn messages_thread() { let _child = open_app(real_captcha, t!("imessage").to_string()); } else if config.auto_paste && !config.float_window { ctx.set_text(&real_captcha).unwrap(); - paste_script().unwrap(); - info!("{}", t!("paste-verification-code")); + match paste_script() { + Ok(_) => info!("{}", t!("paste-verification-code")), + Err(e) => error!("{}: {:?}", t!("error-paste-verification-code"), e), + } if config.auto_return { - return_script().unwrap(); - info!("{}", t!("press-enter")); + match return_script() { + Ok(_) => info!("{}", t!("press-enter")), + Err(e) => error!("{}: {:?}", t!("error-press-enter"), e), + } } if config.recover_clipboard { sleep(Duration::from_secs(2)); // wait applescript to finish @@ -695,11 +699,21 @@ async fn async_watch>(path: P) -> notify::Result<()> { let _child = open_app(real_captcha, t!("mail").to_string()); } else if config.auto_paste { clpb.set_text(&real_captcha).unwrap(); - paste_script().unwrap(); - info!("{}", t!("paste-verification-code")); + match paste_script() { + Ok(_) => info!("{}", t!("paste-verification-code")), + Err(e) => error!( + "{}: {:?}", + t!("error-paste-verification-code"), + e + ), + } if config.auto_return { - return_script().unwrap(); - info!("{}", t!("press-enter")); + match return_script() { + Ok(_) => info!("{}", t!("press-enter")), + Err(e) => { + error!("{}: {:?}", t!("error-press-enter"), e) + } + } } if config.recover_clipboard { async_std::task::sleep(Duration::from_secs(2)).await; //wait for pasted diff --git a/ui/info.plist b/ui/info.plist index 28a15d8..27b1708 100644 --- a/ui/info.plist +++ b/ui/info.plist @@ -1,2 +1,4 @@ +NSAppleEventsUsageDescription +MessAuto needs to control System Events LSUIElement