Jump to content

Cannot get return value from a .exe file


czhe
 Share

Recommended Posts

Hi all,

I have the following code:

Global $iResWidth;
$iResWidth=Run('"D:\AutoIt\res.exe" -getCurrent pixelwidth')
MsgBox(0, "whatever", $iResWidth)

The res.exe file is supposed to return 1680, which is my desktop's horizontal resolution, but instead it returns a random number each time I run my code.

I know the correct value is returned in command prompt.

What am I doing wrong?

Thanks,

czhe

Link to comment
Share on other sites

You want to return the width of your desktop? Use @DesktopWidth... it's a built in AutoIt macro. Also @DesktopHeight. It's much more versatile then using an external script (which I don't see how you'd parse data from...)

If you want to use the res.exe, I suggest having it write data to an ini file or something, I don't know how you could get data just by running the program

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

...

Global $iResWidth;
$iResWidth=Run('"D:\AutoIt\res.exe" -getCurrent pixelwidth')
MsgBox(0, "whatever", $iResWidth)

The res.exe file is supposed to return 1680, which is my desktop's horizontal resolution, but instead it returns a random number each time I run my code.

...

Hi czhe,

Run() returns the Process Identifier (a random integer given to a process to identify it).

RunWait() returns the exit code that should hopefully return the exit code of width of your desktop by running res.exe.

Use RunWait() instead of Run() to get your expected result. :D

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...