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

AutoHotkey collaboration #43

Open
JUN-PRODUCE opened this issue Dec 6, 2021 · 2 comments
Open

AutoHotkey collaboration #43

JUN-PRODUCE opened this issue Dec 6, 2021 · 2 comments

Comments

@JUN-PRODUCE
Copy link

JUN-PRODUCE commented Dec 6, 2021

Thanks for the great solution.
I will share the AHK code that.
In the future, we plan to combine it with DEEPL's API to display it.

^F12:: ;Ctrl + F12 key
Critical, On
Clipboard := ""
Send, ^l
Sleep, 10
Send, ^c
Sleep, 50
ClipWait, 1
	Haystack = "%Clipboard%"
	Needle := ".pdf"
	If InStr(Haystack, Needle)
		{ ;This is a PDF
		Process, Exist, python.exe ;Double activation prevention
		If ErrorLevel<>0
		{
		Return
		}
		Else
		{
		Run, cmd.exe /c "\paper2html-master\paper2html\main.py", X:\temp\pdf_cashe, Min, ;Start if it is not launched,paper_cashe(ram disk set)
			Sleep, 2000
			Process_High("pdftoppm.exe/python.exe/cmd.exe/conhost.exe")
			}
		Run, http://localhost:5000/paper2html/convert?url=%Clipboard%
		}
		Else
		{ ;Alert if not a PDF
		MsgBox, 48, ,NOT PDF,
		Return
		}
SetTimer, close_python, -300000 ;idle Automatic end of server after 5 minutes
Return
close_python:
Process, Close, python.exe
SetTimer, close_python, off
Return

Process_High(Process_p1){
    Loop,parse,Process_p1,/
    {
        Process,Exist,%A_LoopField%
        if (  NewPID:=ErrorLevel )
            Process,Priority,%NewPID%,High
    }
    Return
}
@ktaaaki
Copy link
Owner

ktaaaki commented Dec 8, 2021

Thanks for using our code and sharing your code!
I usually use it from the bookmarklet in my browser, but I may also use it from a shortcut key.

Also, if you want to use DeepL for a selection range of texts, there may be a browser extension for that. chrome has it.

@JUN-PRODUCE
Copy link
Author

bookmarklet is a good solution for people who have a paper2html server running all the time.
In order to incorporate paper2html server startup and automatic termination into the process, we adopted AHK, which is compatible with shortcuts.

I look forward to future updates :)
ありがとうございます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants