Menu

#140 Regain focus on new file open

open
nobody
5
2022-01-27
2022-01-27
David
No

Hi, JPEGView is a great program, but I have a suggestion. Is it possible to make the program regain focus when opening new file in explorer? I use single instance and when I click on new images I would like the program to regain focus and move to the foreground. It would be a good QoL improvement because the program tends to get lost underneath other windows.

If the focus functionality is difficult to implement maybe there is a way to circumvent it. For example upon opening new file close existing instance and start new one. If there is a solution trough ini editing I would appreciate. Thanks.

Discussion

  • Melvin Nava

    Melvin Nava - 2022-01-27

    If I understand correctly, you could associate image files with JPEGView and the program would activate when double clicking images.. You could also set file explorer to act on single clicks..

    What you actually want could be achieved with some scripting with AutoHotkey and JPEGView..

    Mind you.. JPEGView seems to be abandonware since 2018.

     
  • David

    David - 2022-01-27

    Thanks for your reply. The images are associated with JPEGView and the program does open on double click. The program is configured to use one instance.

    What I mean is while we have one instance opened it doesn't regain focus on new images. In simple words - it doesn't move to the foreground to show us the new image as we would expect and if you have many windows obscuring it you wont see any reaction from JPEGView at all. Same if the program was minimized - it switches the images but stays minimized.

    We could, of course, try some AHK script that would associate with images, run/close, regain focus etc but it seems like a difficult solution. I was just wondering whether there is simpler way to do this.

     
  • Melvin Nava

    Melvin Nava - 2022-01-27

    That's an odd behavior. I don't actually have JPEGView associated to test it, but it doesn't seem like an issue with JPEGView, but possibly with FileExplorer, Windows, or other program.. You could try running sfc /scannow in an elevated prompt and restarting.. Sometimes it fixes things.

    Important: I checked again and this is not an issue with Windows but normal JPEGView behavior. read my next comment for more info.

    I actually use AHK to bind both the MIDDLE MOUSE BUTTON and NUMPAD ENTER to open folders and filetypes with different programs. For example, I have all images associated with XnViewMP and all videos with PotPlayer, and yet I can quickly use the MBUTTON or NumPadEnter to open images with JPEGView and videos with MPC-HC. I mention this because every time I open a file with these hotkeys the program window (JPEGView, MPC-HC, etc) activates and opens in the foreground, without any special code.

    In any case, writing a script in AHK for any use is usually not complicated. With a few lines of code you can open any selected image in JPEGView using NUMPADENTER and bring it to the foreground:

    NumpadEnter::
    {
        sClipOrig := ClipboardAll
        SendEvent % "^c"
        ClipWait 2
        sImageFile := Clipboard
        Run % "D:\path\to\JPEGView.exe " . sImageFile
        Sleep 20
        WinActivate % "ahk_exe JPEGView.exe"
        Clipboard := sClipOrig
        Return
    }
    

    There's much that can be done easily with AHK.. But in this case you present I would recommend you find the issue with Windows and fix it. Because opening the associated program will always be faster.

     

    Last edit: Melvin Nava 2022-01-27
  • Melvin Nava

    Melvin Nava - 2022-01-27

    I'm sorry.. I checked again and you're right.. JPEGView does open files in the background (when it's already running). This is not an issue with Windows. Even with my alternative hotkeys JPEGView does open in the background.

    However, you could still use AHK for this functionality.

    Or a different software like XnViewMP whenever you want to have image previews.

     

    Last edit: Melvin Nava 2022-01-27
  • Melvin Nava

    Melvin Nava - 2022-01-27

    Jaja, I've just adapted WinActivate into my AHK hotkeys and JPEGView now opens in the foreground.. I guess I hadn't realize I needed this too.. 👍

     
  • David

    David - 2022-01-27

    Thanks again for your reply and for the script. Yes, it's not related to my system. If you can see the GIF I supplied - JPEGView perfectly goes to the foreground on start but if I switch to another window it wont regain focus automatically when new images are opened, it wont " refresh " focus.

    Basically I thought maybe there is an easy solution to this without messing with focuses of the window - to close existing instance and open new one every time i click on other image. That would potentially solve this since new window is always focused and not minimized.

    I used all kinds of image viewers from ACDSee to irfanview, but this one I like the most. Minimalistic, powerful and quick to launch . Too bad it's being abandoned.

    For the side note AHK indeed is an amazing tool, I use it often myself to tune some programs behavior

     
  • Melvin Nava

    Melvin Nava - 2022-01-27

    Ok.. If the AHK hotkey works for you, you have a solution..

    I've tested it and can also be easily done in VBScript:

    '**
    '** Open file in JPEGView and bring it to the foreground:
    '**     $ OpenJpegView.vbs file.jpg
    '**
    Dim objShell
    Set objShell = CreateObject("WScript.Shell")
    objShell.Run "D:\path\to\JPEGView.exe " & Wscript.Arguments(0), 9, False
    WScript.Sleep(20)
    objShell.AppActivate " - JPEGView"
    

    So this way you could associate your images with a VBScript instead.. if you have the patience to find the right registry entries... In my case:

    HKEY_CLASSES_ROOT\.jpg
    HKEY_CLASSES_ROOT\XnViewMP.jpg
    HKEY_CLASSES_ROOT\XnViewMP.jpg\shell\open\command
        » "D:\path\to\JPEGView.exe" "%1"
    

    This would have to be done with every file extension you intend for it to work.

    But do not attempt use Windows to automatically associate images with a VBScript because then file icons will get mess up (images will use an ugly icon from WScript.exe).

    AfterNote: I also love JPEGView (it's fast and simple), but the main issue it has is that it doesn't support all image formats, and is at this point abandoned.. This is why I use a different program as default image viewer, and then I use the MBUTTON or NUMPADENTER hotkeys to quickly open images with JPEGView (and/or other specific filetypes with other specific programs).

     

    Last edit: Melvin Nava 2022-01-28
  • David

    David - 2022-01-27

    I appreciate, friend. This will help for the time being.

     

Log in to post a comment.

MongoDB Logo MongoDB