Jump to content

Alternative to Run() and ShellExecute() that supports unicode?


zeffy
 Share

Recommended Posts

Hi zeffy.Glad to see you on Autoit Forum.

This works for me fine:

#include <Array.au3>
#include <File.au3>
Dim $avarray


_FileReadToArray(@ScriptDir & "\language.txt",$avarray)

Run("cmd.exe /c " & $avarray[1],@ScriptDir,@SW_HIDE)

Here is language.txt file was saved with UTF8 encoding because its content writed in unicode: => əünı.exe

Script works fine and have`nt any problems.

+ You can use fileinstall() for include your language.txt.

I use this method on my native applications.

sORRY for my awfull English.

Edited by Sh3llC043r
[size="5"] [/size]
Link to comment
Share on other sites

Hi zeffy.Glad to see you on Autoit Forum.

This works for me fine:

#include <Array.au3>
#include <File.au3>
Dim $avarray


_FileReadToArray(@ScriptDir & "\language.txt",$avarray)

Run("cmd.exe /c " & $avarray[1],@ScriptDir,@SW_HIDE)

Here is language.txt file was saved with UTF8 encoding because its content writed in unicode: => əünı.exe

Script works fine and have`nt any problems.

+ You can use fileinstall() for include your language.txt.

I use this method on my native applications.

sORRY for my awfull English.

That's not really what I mean lol, I have the script encoded with UTF-8 with BOM, but i can't get it to send unicode through Run() or ShellExecute(). Can anyone help me?
Link to comment
Share on other sites

  • 1 month later...

I have a similar problem with IrfanView when trying to open unicode paths through AutoIt.

That image viewer opens for example a file in

E:\春の朝は寒い\SomeImage.jpg

perfectly fine if it's set to do so in the registry:

[HKEY_CLASSES_ROOT\IrfanView\shell\open\command]
@="\"D:\\Admin\\Common\\IrfanView\\i_view32.exe\" \"%1\""

But it won't do so when being called by

Dim $TestPath="E:\春の朝は寒い\SomeImage.jpg"
Run ("D:\Admin\Common\IrfanView\i_view32.exe " & $TestPath)
Exit

The funny thing is, when sending the same file to Word from Autoit, Word is able to see the file in the unicode path.

So for Word, the way Autoit is sending the unicode path string makes sense, but for IrfanView it doesn't.

IrfanView allegedly has only partial unicode support (only for filenames), and it does handle unicode filenames when called by the shell, but weirdly not from AutoIt.

Link to comment
Share on other sites

perfectly fine if it's set to do so in the registry:

[HKEY_CLASSES_ROOT\IrfanView\shell\open\command]
@="\"D:\\Admin\\Common\\IrfanView\\i_view32.exe\" \"%1\""

The registry parameter being passed above is quoted i.e "%1"

But it won't do so when being called by

Dim $TestPath="E:\春の朝は寒い\SomeImage.jpg"
Run ("D:\Admin\Common\IrfanView\i_view32.exe " & $TestPath)
Exit

$TestPath above is not quoted.

Try the code below

Dim $TestPath="E:\春の朝は寒い\SomeImage.jpg"
Run ('"D:\Admin\Common\IrfanView\i_view32.exe" "' & $TestPath & '"')
Exit

Though I do not see white space as your issue. Give Shellexecute() a try with similar syntax as above.

Edited by MHz
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...