Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] 隐藏窗口,快速粘贴设置快捷键不生效 #869

Open
wangj919 opened this issue Dec 2, 2024 · 3 comments
Open

[bug] 隐藏窗口,快速粘贴设置快捷键不生效 #869

wangj919 opened this issue Dec 2, 2024 · 3 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug Something isn't working

Comments

@wangj919
Copy link

wangj919 commented Dec 2, 2024

Describe the bug

image

Reproduction

No response

Expected behavior

No response

Software Information

{
  "appName": "EcoPaste",
  "appVersion": "0.4.0",
  "platform": "macos",
  "platformArch": "aarch64",
  "platformVersion": "15.1.1"
}

Additional context

No response

@wangj919 wangj919 added status: needs triage This issue needs to triage, applied to new issues type: bug Something isn't working labels Dec 2, 2024
@Ineffable919
Copy link

image 这两个快捷键设置都不生效

@nanhaishiyounan
Copy link

+1,我的mac也无效

@gityoud
Copy link

gityoud commented Dec 18, 2024

src-tauri/src/plugins/paste/src/commands/macos.rs

// 粘贴
#[command]
pub async fn paste<R: Runtime>(app_handle: AppHandle<R>, window: WebviewWindow<R>) {
    set_macos_panel(&app_handle, &window, MacOSPanelStatus::Resign);

    std::thread::sleep(std::time::Duration::from_millis(150));

    // 使用更详细的 AppleScript
    let script = r#"
tell application "System Events"
    -- 获取当前激活的应用
    set frontApp to name of first application process whose frontmost is true
    -- 确保有足够的时间让应用获得焦点
    delay 0.15
    -- 检查剪贴板是否准备好
    if frontApp is not "" then
        tell process frontApp
            -- 执行粘贴
            keystroke "v" using command down
            -- 给粘贴操作一些时间
            delay 0.1
            return "Paste completed in " & frontApp
        end tell
    else
        return "No active application found"
    end if
end tell
"#;

    Command::new("osascript")
        .args(["-e", script])
        .output()
        .expect("failed to execute process");
}

可以试试这个思路

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants