ktaaaki/paper2html

AutoHotkey collaboration

JUN-PRODUCE opened this issue · 2 comments

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
}

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.

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 :)
ありがとうございます。