在编辑器中保存然后刷新浏览器快捷方式技巧命令 [英] Save then refresh browser shortcut trick command in editor

查看:100
本文介绍了在编辑器中保存然后刷新浏览器快捷方式技巧命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个热键将所有内容保存在Notepad ++中,然后切换到浏览器并刷新页面。我必须每天执行数千次此操作,并执行保存所有热键,然后将Alt-Tab移至右侧窗口,然后按F5一次又一次刷新,是否必须有更好的解决方案?我愿意切换编辑器,如果还有其他编辑器可以做到这一点。

I would like a hotkey to Save All in Notepad++ then switch to the browser and refresh the page. I have to do this thousands of times a day and doing the Save All hotkey, then Alt-Tab to the right window, then F5 to refresh again and again, there must be a better solution? I am open to switching editors if there is another that can do this.

我尝试使用运行命令,但问题是尽管它允许您制作类似[firefox .exe当前文件],如果由于需要运行服务器端而想在本地主机之类的网址上打开它,则必须手动指定字符串的另一部分,例如[chrome.exe自定义var(网址)/文件名],它总是会打开一个新标签,然后造成很多混乱。另外,如果您正在编辑包含文件,则它将尝试打开该文件,而不是使用run命令时要显示的页面,刷新将是我想到的唯一可行的方法。

I have tried using run commands but the problem is although it allows you to make something like [firefox.exe "current file"], if you come down to wanting to open it at a web address like localhost because it needs to run server side, then you have to manually specify the other part of the string, like [chrome.exe "custom var(web address) / filename"] and it always opens a new tab, then creates lots of clutter. Also, if you are editing an include file then it will try to open that instead of the page you want to see when you use the run command, a refresh would be the only realistic method I can think of using.

编辑:我有Cpfohl解决方案可以工作!如果您有其他方法,请分享,因为我仍将监视该线程。

I got Cpfohl solution to work! If you have another method please share, as I will monitor this thread still.

Esc::                ; The hotkey I like to use
SetTitleMatchMode, 2 ; Match Partial Title Mode
SetKeyDelay 10, 10   ; Set Keystroke Delays
Send {F5}            ; Save All In Editor / I set to F5 in npp
IfWinExist, Firefox
   WinActivate
Send {F5}            ; Refresh Browser


推荐答案

我使用 AutoHotKey 这类东西,但是我很新。令人高兴的是,您不必切换编辑器。 AutoHotKey可以让您做任何您想做的事情(很多),但是最简单的方法是用它来完成一系列比较死板的击键操作。

I use AutoHotKey for this kind of stuff, but I'm pretty new at it. The nice part is that you don't have to switch editors. AutoHotKey lets you do anything that you want (pretty much), but it's easiest to use it to do things you can do with a relatively rote series of keystrokes.

您将编写一个在运行时运行的脚本。然后,每当您使用选定的热键时,它都会执行脚本(可以由人工按键组成)。

You'd write a script that you'd run at runtime. Then whenever you use your selected hotkey it executes the script (which can be made up of 'artificial' key-strokes).

示例脚本可能是(此脚本未经测试)并假设您打开的最后一个窗口是浏览器,即: AltTab导致浏览器打开):

An example script might be (THIS IS UNTESTED AND ASSUMES THAT THE LAST WINDOW YOU HAD OPEN WAS THE BROWSER, i.e.: that "AltTab" causes the browser to open):

!+s::           ;Binds the hot key to "Alt,Shift, S"
    Send ^+s    ;Pushes "Ctl,Shift, S"
    Send AltTab ;Pushes "Alt, Tab"
    Send F5     ;Pushes "F5"

编辑05/2020

我想指出的是,如今有 个更好的选择。通过使用任何构建工具(汇总,Webpack等),或通过使用任何文件服务器在本地托管文件(例如, https://github.com/tapio/live-server )。

I'd like to call out that nowadays there are much better options than this. Hot reloading is a solved problem by whatever build tool you're using (rollup, webpack, etc), or by whatever file server you're using to host your files locally (e.g. https://github.com/tapio/live-server).

这篇关于在编辑器中保存然后刷新浏览器快捷方式技巧命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆