Flow-Launcher / Flow-Launcher/Flow.Launcher

Enhancement: new builtin shortcuts: active_office_file

Open
#2,936 4 comments 0 reactions 0 assignees View on GitHub
enhancement keep-fresh
Dominant language
C#
Stars
15.6k
Forks
644
Avg merge
3d 14h
Merged PRs (30d)
4

Description

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`:
```py
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()

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.