UTF-16LE encoded PaperFolders and Irfanview

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

Hi, I use Irfanview from a taskbar icon with a command line similar to this below to quickly change wallpaper by using a text file listing. A single click on the taskbar icon changes the wallpaper to another image in the list.

Code: Select all

D:\Graphics\IrfanView\i_view32.exe /filelist=D:\Tools\XYplorer\Paper\Wallpaper\Maine.txt /random /wall=3 /killmesoftly
However, the text files generated in Paperfolder are UTF-16LE encoded and they do not work in Irfanview. So consequently, I have to use a another copy of the text file encoded in ANSI for it to work properly in the above command line.

I suppose I could use SC readfile and writefile a file in ANSI and delete the new file on the fly, but that would mean doing it a xyscript and maybe using XY_send_message.ahk or possibly a batch file. Does any one know of a simpler way to skirt around this issue? I did request support on the Irfanview forum for UTF-16LE when inputting a text file from the command line.
Thanks,
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by highend »

I'm not sure if this could help but you can convert it via windows batch.

But ofc you'd still need a batch file that does it ;)

Code: Select all

@chcp 1252 >NUL
@type "D:\Tools\XYplorer\Paper\Wallpaper\Maine.txt" > "%TEMP%\Wallpaper.txt"
D:\Graphics\IrfanView\i_view32.exe /filelist=%TEMP%\Wallpaper.txt /random /wall=3 /killmesoftly
If IView doesn't support UTF16LE you need at least "something" that converts it...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

Thanks highend, I too was looking at the DOS conversion commands. I had came up with this...it has wrapped in the post but it's all one line.

Code: Select all

C:\Windows\System32\cmd.exe /a /c type D:\Tools\XYplorer\Paper\Wallpaper\Ireland.txt>D:\Tools\XYplorer\Paper\Wallpaper\Ire.txt && D:\Graphics\IrfanView\i_view32.exe /filelist=D:\Tools\XYplorer\Paper\Wallpaper\Ire.txt /random /wall=3 /killmesoftly
I'm actually a bit surprised in that it works on a one liner from the taskbar icon's Properties, Target box. However, I haven't been able to suppress the command box which flashes on the screen. The Irfanview command line by itself didn't flash a command box whereas this does. I was hoping to accomplish this without the batch file...I figured, if I was going to create a batch file why not have the 2nd copy in ANSI encoding though I suppose it ensures the newly created file is always the same as the original PaperFolder.
Thanks,
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by highend »

There is no way to call the dos stuff without a visible cmd window unless you use another cli tool that is able to hide it :)
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

I was afraid of that. I keep forgetting that using the "run" command in XY scripting with the "no show" parameter is what is suppressing the Command Line box. Maybe I should use XY send messenger along with an XY script instead. Are you aware off hand of any CLI replacements that are able to suppress the Command Line box. I've just read a little about ComEMU and Console2. I've used PowerShell but only from XYplorer so it was done using run with the no show parameter.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by highend »

I've used http://www.ntwind.com/software/hstart.html in the past but nowadays runret() in XY... xD
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

Thanks highend. You mentioned hStart once before when I was having an issue running something on my Windows 8 computer. If I recall though the issue I had with hStart is that it remains in memory. I was able to use a script and XY messenger but it is a bit foolish to involve XY in doing something like this (i.e., running a taskbar program) since XY will have to be "active". I've always got it running, but who wants it to pop up on the screen when you're changing a wallpaper. Of course, the same goes for the use of "runret". I'm looking at the possibility of using VB since supposedly that can hide a command line window....if not I'll just keep a second copy of the PaperFolder text file but in ANSI format. Thanks
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by highend »

I've never had that issue that it is staying active after starting an app...

Nevertheless, vbscript wise:

Code: Select all

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

Using hStart to call out a batch file from a taskbar button works like a charm and I checked in task manager after use and saw no signs of hstart. So it's being released from memory. A year ago when I tried it on my Windows 8 machine I noticed that hstart was still residing in memory after use. Go figure. I may experiment with the VB script anyway. Thanks.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

A follow-up in case someone else is interested in using Irfanview to quickly change wallpaper from a taskbar icon. It's actually kind of nice, provided you keep the desktop relatively clean of desktop icons, since clicking the taskbar button becomes a photo viewer of sorts. If you establish an XY PaperFolder of bunch of different photos from areas you visited (or whatever). You could set one taskbar icon as a wallpaper changer for pictures of Japan another for Hawaii etc.

As I mentioned earlier since XY's PaperFolders are encoded UTF-16LE, Irfanview does not read them properly. So we have to encode the file as ANSI for use with Irfanview. The command line or Target box for the taskbar icon would look something like this: Note: hstart is a free command line tool which will hide the DOS command line console (see link in highend's post above).

Code: Select all

D:\Tools\Hstart\hstart64.exe /NOCONSOLE "D:\Tools\XYplorer\Scripts\WallpaperChanger.bat Maine"
The PaperFolder the batch is referring to is:

Code: Select all

D:\Tools\XYplorer\Paper\Wallpaper\Maine.txt
So that I don't need to have a separate batch file for each PaperFolder, I made a batch file (WallpaperChanger.bat) referred to in the taskbar's command line Target box. This is what the batch file looks like:

Code: Select all

@echo off
set ARG=%1
REM You may also need the following line in other countries (e.g., Germany )
REM  @chcp 1258 >NUL
@chcp 1252 >NUL
@type D:\Tools\XYplorer\Paper\Wallpaper\%ARG%.txt>D:\Temp\wallpaper.txt
D:\Graphics\IrfanView\i_view32.exe /filelist=D:\Temp\wallpaper.txt /random /wall=3 /killmesoftly
DEL /Q D:\Temp\wallpaper.txt
 
You obviously would have to change folder locations, but this way you can use the same batch file for each taskbar icon. As you can see from the batch file, it uses the fist parameter to direct it to the proper PaperFolder, in this case "Maine". The "wallpaper.txt" file is deleted after use. Previous to this I had to have a separate text file with the listing of images which was ANSI encoded. With this method I can use the actual Paperfolder text file and not have to worry about keeping another ANSI version of the file up to date. The image files I select for use in the PaperFolder are ones that I've converted or cropped to the aspect ratio of my screen.
Ken

Edit: Incorporated comments below.
Last edited by klownboy on 05 Dec 2014 23:05, edited 2 times in total.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by highend »

If you are e.g. from germany, you need an additional "chcp 1258" in the batch file, otherwise umlauts aren't translated correctly.
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

Thanks highend. You don't need the "@chcp 1252 >NUL" as well do you (from your previous post)? I assumed that was taken care of by the cmd /A parameter which ensures the results are in ANSI format (i.e., just a different method).
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by highend »

I rather use an internal command (chcp) for the current instance instead of invoking a new cmd.exe to get the same result (personal preference) :)
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by klownboy »

Ah yes, I was forgetting the fact that I'm already running cmd.exe by running the batch file and then opening another. I tweaked the batch file above. Thanks highend.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: UTF-16LE encoded PaperFolders and Irfanview

Post by totmad1 »

Hi klownboy (Ken)
hope you don't mind but i'm posting here as it is a script i've produced to use PaperFolders and Irfanview.
it can be run from startup via /script= and also as single or multiple selection from image folder or PaperFolder.
if run from startup you will see that you can have "season" or "anniversary" or "monthly". I've only done examples.
I originally did this for another image viewer which didn't have the facility of "random".

Code: Select all

      global $list;
     $image_list = "";
     $image_list = get("SelectedItemsPathNames", "<crlf>");
        $ext=getpathcomponent($image_list, "ext", 1) ;
          if($ext !="jpg" OR $ext !="bmp" OR $ext !="png"){$image_list = "";}
     if($image_list == ""){
       sub _lists;
     $image_list = readfile("<xypaper>\wallpaper\$list");
     }
     $count = gettoken("$image_list", "count", "<crlf>");
      $see= rand(1,$count);
     $Choice=gettoken($image_list,$see,"<crlf>");
    run "%Porta%\IrfanView\i_view32.exe $Choice  /wall=3 /killmesoftly"
"_lists"
    global $list;
    $Mth = now("mm"); $Day = now("dd");
         If($Day =="25" AND $Mth = "1"){$list="HBirth.txt"}
    ElseIf($Mth >="1" AND $Mth <="3"){$list="Winter.txt";}
    ElseIf($Mth >="4" AND $Mth <="6"){$list="Spring.txt";}
    ElseIf($Mth >="7" AND $Mth <="9"){$list="Summer.txt";}
    ElseIf($Mth =="10" OR $Mth =="11"){$list="Fall.txt";}
    Else{$list="xmas.txt"}
hope this might be of interest
totmad1 (totally mad one)

Post Reply