Jump to content

How to use shellexecute to open image with ImageEye.


Recommended Posts

Hi,

I am trying to make a program that will open any image file with Image Eye 7.4. ImageEye (700kb) is a small image viewer. Here's is what I've created.

1st attempt to open a file in ImageEye.

ShellExecute("C:\Program Files\Image Eye\ImageEye.exe",""); double click on any image file will open in imageeye

I associate all image files to open with ImageEye.au3. Next I double click on an image file and the result is a menu pop up. I'd expected an image to popup.

Posted Image

2st attempt to open a file in ImageEye.

ShellExecute("C:\Program Files\Image Eye\ImageEye.exe","frog.jpg"); double click on any image file will open in imageeye

A second attempt to open the file in ImageEye.au3 or ImageEye.au3.exe will result with the same picture no matter what file I click on. Another words, no matter what image I click the frog picture will appear.

Posted Image

What I really like is a code that allows me to click on any image file and it'll open in image eye. For example:

ShellExecute("C:\Program Files\Image Eye\ImageEye.exe","*.jpg", "*.png"); double click on any image file with a wildcard *.jpg or *.png will open in image eye

How can I create a code that will make any image to execute normally on ImageEye.exe?

Thanks.

Link to comment
Share on other sites

Try Run instead:

$prog = "C:\Program Files\Image Eye\ImageEye.exe"
$file = " frog.jpg" ;better to use full path instead of filename only!
Run($prog & $file, "")

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Try Run instead:

$prog = "C:\Program Files\Image Eye\ImageEye.exe"
$file = " frog.jpg" ;better to use full path instead of filename only!
Run($prog & $file, "")

Br,

UEZ

Thanks. I ran the code and it generated an error, "variable used without being declared." see attach pic. Will this code open any image other than frog.jpg? I'm looking for a code that opens any image.

Reason for edit: to attach an image.

post-46358-0-36093400-1306735042_thumb.g

Edited by Frogscape
Link to comment
Share on other sites

ShellExecute("C:\Program Files\Image Eye\ImageEye.exe",""); double click on any image file will open in imageeye

I associate all image files to open with ImageEye.au3. Next I double click on an image file and the result is a menu pop up. I'd expected an image to popup.

You hopefully mean a compiled script as being ImageEye.exe? I would recommend that you do not name your script with the same name as the target that you want to run. You get the popup from ImageEye.exe as you passed a blank parameter to ImageEye.exe. Your script is going to need to handle incoming command line parameters to do this task. In the help file if searched, you may find stuff about $CMDLINE and other stuff about command line parameters mentioned. This is what you may need to learn.

Here is a script to try

; $CMDLINE[0] contains count of command line parameters passed to your script
If $CMDLINE[0] Then
    ; $CMDLINE[1] contains the 1st parameter passed to your script
    Run('"' & @ProgramFilesDir & '\Image Eye\ImageEye.exe" "' & $CMDLINE[1]  & '"'); double click on any image file will open in imageeye
EndIf

You are going to have to setup file associations for your script to handle the file types you want to allow this to work. I am surprised that ImageEye.exe can not do this all for you without needing a script.

If file associations are setup, then you could use ShellExecute() to handle the image files to run the default program as set in the registry.

; $CMDLINE[] contains count of command line parameters passed to your script
If $CMDLINE[0] Then
    ; $CMDLINE[1] contains the 1st parameter passed to your script
    ShellExecute('"' & $CMDLINE[1]  & '"'); double click on any image file will open in imageeye
EndIf
Link to comment
Share on other sites

I don't know what your purpose really is about? Because you can associate all images with ImageEye directly using windows explorer. Why do you want to start ImageEye with a script?

Anyway, try this:

Global $prog = "C:\Program Files\Image Eye\ImageEye.exe "
Global $file = FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)")
If @error Then Exit MsgBox(0, "Information", "You must select an image file!")
Global $pid = Run($prog & $file, "")

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I don't know what your purpose really is about? Because you can associate all images with ImageEye directly using windows explorer. Why do you want to start ImageEye with a script?

Good question and thanks for your patience. Starting ImageEye and then having the ability to run other scripts has many benefits. Every time I click on an image, I can run a new instance of notepad. Once notepad is open, I type in the detail information about the photograph into notepad. I then save and close.

Here's an example of a working script (initially created by MHz:)

; $CMDLINE[0] contains count of command line parameters passed to your script
If $CMDLINE[0] Then     ; $CMDLINE[1] contains the 1st parameter passed to your script   
    Run('"' & @ProgramFilesDir & '\Image Eye\ImageEye.exe" "' & $CMDLINE[1]  & '"')
    ; double click on any image file will open in imageeye
  
    Run("C:\Program Files\notepad2.exe") ; opens a new instance of notepad.

EndIf ; must end a statement with EndIf or otherwise it will crash

The second reason/purpose is the ability to change the scary looking image eye icon. ImageEye is a great viewer but the scary icon that displays in windows explorer is from a horror film. This script will change all the icons into one that I create myself. A peaceful looking icon can lower our blood pressure. :huh2:

Anyway, try this:

Global $prog = "C:\Program Files\Image Eye\ImageEye.exe "
Global $file = FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)")
If @error Then Exit MsgBox(0, "Information", "You must select an image file!")
Global $pid = Run($prog & $file, "")

Br,

UEZ

Thanks for the script. I don't know why it keeps saying "it couldn't open file."

Reason for edit: spelling.

post-46358-0-69613500-1307084246_thumb.g

Edited by Frogscape
Link to comment
Share on other sites

You hopefully mean a compiled script as being ImageEye.exe? I would recommend that you do not name your script with the same name as the target that you want to run. You get the popup from ImageEye.exe as you passed a blank parameter to ImageEye.exe. Your script is going to need to handle incoming command line parameters to do this task. In the help file if searched, you may find stuff about $CMDLINE and other stuff about command line parameters mentioned. This is what you may need to learn.

Here is a script to try

; $CMDLINE[0] contains count of command line parameters passed to your script
If $CMDLINE[0] Then
    ; $CMDLINE[1] contains the 1st parameter passed to your script
    Run('"' & @ProgramFilesDir & '\Image Eye\ImageEye.exe" "' & $CMDLINE[1]  & '"'); double click on any image file will open in imageeye
EndIf

You are going to have to setup file associations for your script to handle the file types you want to allow this to work. I am surprised that ImageEye.exe can not do this all for you without needing a script.

If file associations are setup, then you could use ShellExecute() to handle the image files to run the default program as set in the registry.

; $CMDLINE[] contains count of command line parameters passed to your script
If $CMDLINE[0] Then
    ; $CMDLINE[1] contains the 1st parameter passed to your script
    ShellExecute('"' & $CMDLINE[1]  & '"'); double click on any image file will open in imageeye
EndIf

The first script works great! Thank you.

The second script looped forever and only a reboot stopped that. It's possible that I didn't run it correctly.

About naming my compiled script with the same name as the target, thanks for pointing that out. I didn't notice that. That explains why my inability to see the difference made it difficult for me to write scripts. And it's great that you actually are helping people improve by pointing me to what I to read further. Thanks again. :huh2:

Link to comment
Share on other sites

The first script works great! Thank you.

The second script looped forever and only a reboot stopped that. It's possible that I didn't run it correctly.

The 1st script is what you want. The 2nd script does look for incoming to the script which you have probably set with association, so it would execute itself, my apologies for that mistake.

The code of UEZ looks good except for the risk taken with whitespace in paths with no quotes to keep the path strings intact. In my example you may notice that I quote the paths. Ignore whitespace in paths with the knowledge that it may fail.

This may work better with quotes

Global $prog = "C:\Program Files\Image Eye\ImageEye.exe"
Global $file = FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)")
If @error Then Exit MsgBox(0, "Information", "You must select an image file!")
Global $pid = Run('"' & $prog '" "' & $file & '"')
Link to comment
Share on other sites

Thanks for the script. I don't know why it keeps saying "it couldn't open file."

The problem was probably the exe name -> ImageEye.exe instead of Image Eye.exe

Global $prog = '"' & @ProgramFilesDir & '\Image Eye\Image Eye.exe" '
If Not FileExists($prog) Then Exit MsgBox(0, "Information", $prog & "cannot be found!")
Global $file = '"' & FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)") & '"'
If @error Then Exit MsgBox(0, "Information", "You must select an image file!")
Global $pid = Run($prog & $file, "")

Added quotes to be sure that the file can be opened properly.

I installed Image Eye in my vm and tested the script -> working.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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