Page 1 of 2

UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 17:15
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

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 17:40
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...

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 18:03
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

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 18:12
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 :)

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 18:50
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.

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 18:59
by highend
I've used http://www.ntwind.com/software/hstart.html in the past but nowadays runret() in XY... xD

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 21:38
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

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 21:56
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

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 04 Dec 2014 23:11
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.

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 05 Dec 2014 15:18
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.

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 05 Dec 2014 16:48
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.

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 05 Dec 2014 17:09
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).

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 05 Dec 2014 18:26
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) :)

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 05 Dec 2014 19:35
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.

Re: UTF-16LE encoded PaperFolders and Irfanview

Posted: 13 Dec 2014 16:12
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