forked from 1j01/jspaint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprettify-html.ahk
69 lines (66 loc) · 1.59 KB
/
prettify-html.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; AutoHotkey script for formatting HTML with DirtyMarkup
; They actually have an API, but I decided to go this route instead of... looking for a CLI... which does exist
; Usage:
; * Open https://www.10bestdesign.com/dirtymarkup/
; * Check "Allow proprietary attributes"
; * Switch to your editor where you have some HTML
; * Press F12
F12::
; SetKeyDelay, 69, 69
; (extra) delays are needed only for interacting with the webpage
; so I've done sleeps below instead
; (they might also be needed if the editor is a webpage)
OriginalClipboard := ClipboardAll
Clipboard :=
WinGet, CodeEditorWinID, ID, A
Send, ^a
Send, ^c
ClipWait, 1
If ErrorLevel
{
MsgBox, Failed to copy from code editor (no change to clipboard in timeout period)
Goto, ResetAndEnd
}
If Trim(Clipboard) =
{
MsgBox, Failed to copy from code editor (clipboard empty)
Goto, ResetAndEnd
}
WinActivate, DirtyMarkup
WinWaitActive, DirtyMarkup, , 1
If ErrorLevel
{
MsgBox, Failed to activate DirtyMarkup; I'm not gonna open it for u just open it lol (and focus the tab)
Goto, ResetAndEnd
}
Click, 420, 420
Sleep, 50
Send, ^a
Sleep, 150 ; not sure this needs to be higher
Send, ^v
Sleep, 150 ; not sure this needs to be higher
Click, 69, 420
Clipboard :=
Click, 420, 420
Sleep, 50
Send, ^a
Sleep, 50
Send, ^c
ClipWait, 1
If ErrorLevel
{
MsgBox, Failed to copy from DirtyMarkup
Goto, ResetAndEnd
}
WinActivate ahk_id %CodeEditorWinID%
Send, ^a
Send, ^v
ResetAndEnd:
Clipboard := OriginalClipboard
Return
; Shortcut to move to next file
; This could be set up in your editor instead
F11::
Send ^0 ; Ctrl+0 focuses the sidebar in VS Code
Send {Down}{Enter}
Return