Last active
December 17, 2021 16:48
-
-
Save siuoly/e65e504ac42a5644b7dfd2ef3a5d70b5 to your computer and use it in GitHub Desktop.
一鍵刷新瀏覽器 ,不用離開編輯器 Refresh the browser without leaving focus the editor. For wsl Vim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; reference | |
; auto hot key, refresh chrome, without leaving the focus of editor | |
; //www.autohotkey.com/board/topic/113163-refresh-google-chrome-with-a-button-will-pay/?p=661651 | |
; For wsl && vim editor | |
; how execute windows file on wsl | |
; https://docs.microsoft.com/en-us/windows/wsl/filesystems#run-windows-tools-from-wsl | |
; 1. using "convert .ahk to .exe" program, convert this ahk file. | |
; 2. copy the converted file "F5_chrome.exe" to <your_wsl_path> | |
; 3-1. command on terminal 'cmd.exe /c `wslpath -w ~/.vim/after/ftplugin/html/F5_chrome.exe`' , will execute this exe file. | |
; 3-2. or add a keymap on vim: nnoremap <f5> :call system( 'cmd.exe /c `wslpath -w <yout_wsl_path>`')<cr> | |
; 3-2-2. Using <f5> to refresh the pa | |
ChromeSend(keys){ ;keys = the keys you want to be sent e.g. "asbnd{space}lk{enter}" | |
if (!WinActive("ahk_class Chrome_WidgetWin_1")){ | |
WinGetActiveTitle,currActive | |
WinActivate,ahk_class Chrome_WidgetWin_1 | |
WinWaitActive,ahk_class Chrome_WidgetWin_1 | |
} | |
Send, %keys% | |
WinActivate,%currActive% ;no need to if this since it'll be empty if chrome was active | |
} | |
SetWinDelay,-1 ;~ to make winactivate etc snappier and less obtrusive | |
ChromeSend("{F5}") | |
exitapp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment