Macro/Script to "Save file and refresh FireFox"

Macro/Script to "Save file and refresh FireFox"

1581
Power UserPower User
1581

    Feb 15, 2012#1

    I don't have any clue of macros and scripts, so maybe it is not possible ...

    I'm working with dual-monitor: one monitor with UE and an open HTML, other monitor with Firefox which displays my HTML.
    Now I have to "edit - save - click to FF - refresh FF - click to UE - edit - save - click to FF ..."

    Is there a way that I can combine "save HTML in UE and refresh FF" in one button from UE?

    Thanks and regards

    Peter

    6,675585
    Grand MasterGrand Master
    6,675585

      Feb 15, 2012#2

      With an UltraEdit macro or script it is not possible to execute commands of Firefox. So the answer is NO for this approach.

      Perhaps with the AutoHotkey tool you can combine Ctrl+S (Save), Alt+Tab (Switch to previous application which is hopefully Firefox) and F5 (Refresh) to a single hotkey. But I'm not familiar with AutoHotkey tool like other UltraEdit users (see More AHK Goodness - show list of project files).

      2362
      MasterMaster
      2362

        Feb 15, 2012#3

        Using AutoHotKey (AHK), you can not only create a simple script you need to perform such a function, but you can compile it into an executable file, when can then be run as a tool by pressing a hot-key within UE.

        The combination of AHK and UE, in my opinion, is simply to great of a benefit to ignore.

        1581
        Power UserPower User
        1581

          Feb 15, 2012#4

          To be honest I already looked some times at AHK, and every time I stopped due to my limited knowledge. So I'm hoping for a nice guy who releases a few lines or a small exe for me and the entire community. :roll:

          Peter

          2362
          MasterMaster
          2362

            Feb 19, 2012#5

            It doesn't take much to do this. I have implemented the following and it works fine for me. It is only a few lines, but you will need to compile them into an EXE with Ahk2Exe.exe in order to run it as a user tool.

            Here is the AutoHotKey script. I am using AutoHotKey_L, but the following should work with basic, I think.

            Code: Select all

            SetTitleMatchMode, 2
            IfWinExist, Mozilla Firefox
            {
            	WinActivate, Mozilla Firefox
            	Send, {F5}
            }
            
            You could change it up a bit to where you could make a tool to send pretty much any keystroke to any window, where you would send part of the window title to the command line, followed by the keystroke to be sent to the command line, by changing it to:

            Code: Select all

            SetTitleMatchMode, 2
            if %0% > 1
            {
              IfWinExist, %1%
              {
              	WinActivate, %1%
              	Send, %2%
              }
            }
            
            Then, once compiled, you would call it like:

            Code: Select all

            "\path\to\compiledscript.exe" "Mozilla Firefox" "{F5}"
            That would allow you to create tools using the same executable, which could conceivably send any keystroke(s) to any application that is currently running on your system.

            I have tested these on my system, and they compile and function correctly for me using Firefox as the target. It does leave Firefox as the active window. If you would prefer to make UltraEdit the active Window afterwards, then it can be modified...

            Code: Select all

            SetTitleMatchMode, 2
            IfWinExist, Mozilla Firefox
            {
            	WinActivate, Mozilla Firefox
            	Send, {F5}
            }
            IfWinExist, UltraEdit ;Replace UltraEdit with UEStudio if you are using UEStudio.
            {
            	WinActivate, UltraEdit ;Replace UltraEdit with UEStudio if you are using UEStudio.
            }
            
            Hope this helps.

            1581
            Power UserPower User
            1581

              Feb 20, 2012#6

              Hello rhapdog

              thanks a lot for your detailed reply. I will try it and will report, but it will take maybe two weeks because at the moment I got a lot of other jobs.

              Thanks and regards

              Peter

              2362
              MasterMaster
              2362

                Feb 25, 2012#7

                I might want to add that if you are using multiple instances of UltraEdit or UEStudio, then it will only find the first one when switching back. Shouldn't be a problem, since you just switched away, however.

                40
                Basic UserBasic User
                40

                  Mar 04, 2012#8

                  There are other ways too.
                  1. In FF right click on the page and from the context menu select 'Reload every' -> 5 seconds. FF will auto-refresh the page, no need to do anything in UE.
                    (If you don't see 'Reload every' option, it may not be built-in but to come from the TabMixPlus plugin, not sure.)
                  2. Insert a meta refresh tag in the page HEAD like this
                    <META HTTP-EQUIV="refresh" CONTENT="2">
                    to reload every 2 seconds. Make sure to remove it when the page is ready.
                  3. Make a tool in UE that opens the active file in FF. Tool command line should be sort of
                    C:\Program Files\Mozilla Firefox\firefox.exe "%f"
                    and in the Options tab tick 'Save active file' and 'Windows program'. UE will save the file and pass it to FF. To avoid opening a new window every time, set FF to work in single window mode so that instead of a new instance it opens a new tab. Again, single window option may come from the TabMixPlus plugin. It's quite useful anyway.

                  1581
                  Power UserPower User
                  1581

                    Mar 05, 2012#9

                    Hello hveld

                    thanks - these are really interesting ideas :)

                    Thanks to both users.

                    Peter

                    29
                    Basic UserBasic User
                    29

                      Nov 12, 2012#10

                      This thread is quite old and hopefully UE has moved on a bit. For modern web developers it's a basic feature that the IDE can:
                      1) Show my webpage in a split window
                      2) Refresh the webpage when I save any file
                      Any progress on this in UE or should we all move to Komodo et al?

                      2362
                      MasterMaster
                      2362

                        Nov 12, 2012#11

                        cawoodm wrote:This thread is quite old and hopefully UE has moved on a bit. For modern web developers it's a basic feature that the IDE can:
                        1) Show my webpage in a split window
                        2) Refresh the webpage when I save any file
                        Whoa! I couldn't disagree more with what you're saying here.

                        Someone who is an experienced web developer, and by that I mean the person develops actual web-based applications/software, knows that the page may display and/or behave differently depending on the user's browser.  

                        Having integrated browsing, while it may be a convenience for simple HTML pages, is never a substitute for loading up multiple browsers and multiple versions of those browsers to test your site.  I have AutoHotkey scripts to automate this task for me (much more than just for Firefox.)  The script saves the file, then refreshes all browsers that are currently loaded.

                        However, I certainly don't want the browsers to refresh every time I save a file.  Considering many web applications consist of hundreds of files, and you may need to edit several files before you refresh, then that feature will only get in your way and slow you down.

                        Komodo? Seriously? Again, that's for people who don't ever work with very large projects, because in very large projects, it slows to a crawl and is crash prone.  But hey, if you like the "free" products that have features geared toward beginners that "sound cool" to someone who hasn't been doing it long enough to know better or someone who has been coding for the web a while but never created a truly substantial product, then by all means go for such a product.  I'll stick with UEStudio, which keeps me productive in real world development, both on the web and for desktop applications.

                        My 2 cents.  Sorry if I sound harsh, but I tend to be quite blunt about comparisons with "free" editors, as I have tried them over the last few years, because I was still using an old version of UE a few years ago (version 5.21) and I decided to look around before paying for the upgrade.  I found that my old 5.21 version of UE actually kept me more productive than the "free" products of 3 years ago.  I now have lifetime unlimited upgrades for UE and UEStudio.  Don't even get me started on how much more productive they are over what is available today, because there is a character limit on posts, and it would take 20 to 30 posts to get started good.

                        No, I don't work for nor am I affiliated with IDM except in being a customer.

                        6,675585
                        Grand MasterGrand Master
                        6,675585

                          Nov 12, 2012#12

                          In addition to the statement written by rhapdog on which I agree without any exception, here are some more information for you.

                          UltraEdit Latest Changes lists currently all enhancements made on UE v18.xx this year and since this topic has been started. You won't find anything related browser view, most likely because nobody or not enough users requested enhancements in this area by email to IDM support.

                          UltraEdit has built-in a browser view to view the code of current file with using installed Internet Explorer. See the topic usage of integrated browser view for details how to get a split view with code in one window and the browser view in another window arranged vertically. As far as I know other editors respectively IDEs designed for webpage development also do not really split document window of active file. Instead they have a separate browser view just positioned below or above the document windows with the code and refresh automatically on save active file or when switching to another file the browser view content.

                          But viewing a webpage in real browser windows (at least finally in multiple browsers) is in my point of view always better. It makes more sense to use the browsers for testing webpages when using multiple monitors. Of course it is possible to arrange also UltraEdit window above/below the browser window if just 1 monitor is available. But because of the lost vertical space for the webpage display in the browser window caused by title bar, address bar, menu bar, toolbar and status bar, it would be better to buy a second monitor as they are cheap nowadays.

                          Alt+Tab followed by F5 is still my preferred method to refresh a page in browser window. Of course a user tool like described above can be used too and with enabling Save all files first or just Save active file in the user tools options the execution of the user tool by hotkey can replace the save command executed usually by pressing Ctrl+S.

                          Nevertheless, if you have good ideas on how to improve the integrated browser view, please send them by email to IDM support. Additionally you may post the ideas also in the My 2 Cents forum and invite other UltraEdit users to request the same. The more user request an enhancement, the more likely it will be to get the requested enhancements implemented in a future version.