Sign in to follow this  
Followers 0
arminius

menu won't execute executables

12 posts in this topic

ok here is the code

CODE
While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

Run("C:\Documents and Settings\Cieran\My Documents\Scripts\Screensaver\Good.exe")

Case $msg = $Button_2

ShellExecute("Bad.au3", "", "C:\Documents and Settings\Kieren\My Documents\Scripts\Screensaver", "Run")

Case $msg = $Button_3

ShellExecute("Surreal.au3", "", "C:\Documents and Settings\Kieren\My Documents\Scripts\Screensaver", "Run")

Case $msg = $Button_6

ShellExecute("Chatter.au3", "", "C:\Documents and Settings\Kieren\My Documents\Scripts\Chat Programs", "Run")

Case $msg = $Button_7

Run("C:\Documents and Settings\Cieran\My Documents\Scripts\Chat Programs\Chatter - Logoff.exe")

EndSelect

Wend

the shellexecutes are how I had it at the early state so I could make edits to the programs, but now that I want to compile them, I click on the buttons with .exe, and nothing happens, no error message, just doesn't wanna execute?

Share this post


Link to post
Share on other sites



I tried this i wrote real quick and it uses a button to run an .exe and it works:

#include <GUIConstants.au3>

GUICreate("Test", 70, 20)

$button = GUICtrlCreateButton("Run .exe", 1, 1, 70, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $button
        Run("Notepad.exe")
        Sleep(1000)
        ShellExecute("Notepad.exe")
    EndSelect
WEnd
GUIDelete()
Exit
but you could try removing the C:\DOCUMENTS ect. and just use the name of the file with the extension. Hope thats helps, Clipper34

Share this post


Link to post
Share on other sites

arminius

I click on the buttons with .exe, and nothing happens, no error message, just doesn't wanna execute

Wrong Run parameter in ShellExecute() func. From the help:

verb [optional] The "verb" to use, common verbs include:

open = (default) Opens the file specified. The file can be an executable file, a document file, or a folder

edit = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail

print = Prints the document file specified. If "filename" is not a document file, the function will fail

properties = Displays the file or folder's properties

where you found the Run parameter? :)

Share this post


Link to post
Share on other sites

I just wanna run an .exe

is that possible?

Share this post


Link to post
Share on other sites

Run("notepad.exe")

If it is not a registered exe then use the full path to the exe

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I've tried just the file name, it says cannot find external file, I try the full path and when I click on the button nothing happens, no error message but no script execution

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I've tried just the file name, it says cannot find external file, I try the full path and when I click on the button nothing happens, no error message but no script execution

You probably have spaces in the exe path.

$s_Path = "My Exe Path And My ExeName.exe"

Run('"' & $s_Path & '"')

Surround them by double quotes.

Edit:

P.S.

.au3 extension is not an executable.

To do that as an executable, you need to use /AutoIt3ExecuteScript .

Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $s_MyAu3File & '"')

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Another approach, I used this to run an au3 file in the same folder

Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptDir & "\4.au3"))

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I tried your code

CODE
$s_Path = "C:\Documents and Settings\Kieren\My Documents\Scripts\Screensaver\Good.exe"

CODE
Case $msg = $Button_1

Run('"' & $s_Path & '"')

and nothing happened as normal

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Try this...

$s_Path = "C:\Documents and Settings\Kieren\My Documents\Scripts\Screensaver\Good.exe"
$s_Path = FileGetShortName($s_Path)

Case $msg = $Button_1
    If Not FileExists($s_Path) Then
        MsgBox(0x0, "Error", "The file was not found    ", 5)
    Else
        Run($s_Path)
    EndIf

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

it didn't come up with a message box, but it also didn't execute the script

Share this post


Link to post
Share on other sites

are there any arguments/parameters needed???

try this with "working directory" ( replace the run statement ABOVE )

Run($s_Path, @WorkingDir)

8)


NEWHeader1.png

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