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

Enhancement: new builtin shortcuts: active_office_file #2936

Open
1208nn opened this issue Aug 25, 2024 · 2 comments · May be fixed by #3046
Open

Enhancement: new builtin shortcuts: active_office_file #2936

1208nn opened this issue Aug 25, 2024 · 2 comments · May be fixed by #3046
Labels
enhancement New feature or request

Comments

@1208nn
Copy link

1208nn commented Aug 25, 2024

Just like {active_explorer_path}

It's not difficult.

This function might help users use plugins to do something on what they are focusing quickly or users can drag it in the flow search result to share it quickly.

I think it would be better if we add a copy button in the builtin shortcuts list.

An example in python:

import os
import time
import win32gui
import win32api
import win32com.client
import win32process
import win32con


def get_active_window():
    window = win32gui.GetForegroundWindow()
    thread_process_id = win32process.GetWindowThreadProcessId(window)
    return thread_process_id[1]


def get_file_path():
    pid = get_active_window()
    handle = win32api.OpenProcess(
        win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, pid)
    exe_path = win32process.GetModuleFileNameEx(handle, 0)
    if "winword.exe" in exe_path.lower():
        return os.path.abspath(win32com.client.Dispatch("Word.Application").ActiveDocument.FullName)
    elif "powerpnt.exe" in exe_path.lower():
        return os.path.abspath(win32com.client.Dispatch("PowerPoint.Application").ActivePresentation.FullName)
    elif "excel.exe" in exe_path.lower():
        return os.path.abspath(win32com.client.Dispatch("Excel.Application").ActiveWorkbook.FullName)
    else:
        return None


input()
time.sleep(2)
print(get_file_path())

input()
@1208nn 1208nn added the enhancement New feature or request label Aug 25, 2024

This comment was marked as duplicate.

@github-actions github-actions bot added the Stale label Oct 25, 2024
1208nn added a commit to 1208nn/Flow.Launcher that referenced this issue Oct 26, 2024
Fixes Flow-Launcher#2936

Add new builtin shortcut `{active_office_file}` to quickly access the active office file.

* Add a new method `GetActiveOfficeFilePath` in `Flow.Launcher.Infrastructure/Helper.cs` to retrieve the active office file path.
* Add a new builtin shortcut `{active_office_file}` in `Flow.Launcher.Infrastructure/UserSettings/Settings.cs` to use the `GetActiveOfficeFilePath` method.
* Update the `BuiltinShortcuts` list in `Flow.Launcher.Infrastructure/UserSettings/Settings.cs` to include the new `{active_office_file}` shortcut.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Flow-Launcher/Flow.Launcher/issues/2936?shareId=XXXX-XXXX-XXXX-XXXX).
@1208nn 1208nn linked a pull request Oct 26, 2024 that will close this issue

This comment was marked as duplicate.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
@jjw24 jjw24 removed the Stale label Nov 1, 2024
@jjw24 jjw24 reopened this Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants