Sign in to follow this  
Followers 0
zeffy

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

7 posts in this topic

#1 ·  Posted (edited)

.

Edited by Zef

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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]

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Really not sure what you are about. But a third way to run a program

#include <Process.au3>
$rc = _RunDos("start Http://www.autoitscript.com")

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

The quotes indeed made the difference - very weird for a path containing no white space, but good to know.

Thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0