Jump to content
Sign in to follow this  
hiddenlink

How to launch external apps with the use of buttons

Recommended Posts

hiddenlink

How to launch external apps with the use of buttons.

Share this post


Link to post
Share on other sites
2words4uready

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 141, 53, 193, 125)

$Button1 = GUICtrlCreateButton("Button1", 16, 8, 113, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

run("notepad.exe")

EndSwitch

WEnd


READ BEFORE POSTINGMy UDF'sMessagesYou say plz because its shorter than please. I say no because its shorter than yes.Join My Website

Share this post


Link to post
Share on other sites
hiddenlink

What code do you have so far?

I use the run but it says it cannot execute the application.

run(".exe" , "C:Windows/System32/Restore/mstrui.exe" , 0)

Share this post


Link to post
Share on other sites
hiddenlink

;====================================================

;================= Example of a GUI =================

;====================================================

; AutoIt version: 3.0.103

; Language: English

; Author: "SlimShady111"

;

; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

;Include constants

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()

;Initialize variables

Local $GUIWidth = 300, $GUIHeight = 250

Local $Edit_1, $OK_Btn, $Cancel_Btn, $Def_Btn, $msg

#forceref $Edit_1

;Create window

GUICreate("Cockpit", $GUIWidth, $GUIHeight)

GuiCtrlCreateLabel("Optimize your Windows", 10, 10)

;Create an "OK" button

$OK_Btn = GUICtrlCreateButton("System Restore", 10, 50, 90, 25)

;Create a "CANCEL" button

$Cancel_Btn = GUICtrlCreateButton("Registry Editor", 200, 50, 90, 25)

$Def_Btn = GUICtrlCreateButton("Defragmenter", 105, 50, 90, 25)

;Show window/Make the window visible

GUISetState(@SW_SHOW)

;Loop until:

;- user presses Esc

;- user presses Alt+F4

;- user clicks the close button

While 1

;After every loop check if the user clicked something in the GUI window

$msg = GUIGetMsg()

Select

;Check if user clicked on the close button

Case $msg = $GUI_EVENT_CLOSE

;Destroy the GUI including the controls

GUIDelete()

;Exit the script

Exit

;Check if user clicked on the "OK" button

Case $msg = $OK_Btn

run("rstrui.exe" ,"C:Windows/system32/restore/rstrui.exe")

;Check if user clicked on the "CANCEL" button

Case $msg = $Def_Btn

Run("rstrui.exe" ,"c:/windows/system32/restore",1,1)

EndSelect

WEnd

EndFunc ;==>_Main

Share this post


Link to post
Share on other sites
MerkurAlex

Hey guys use


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
hiddenlink

thid doesnt run:

Case $Button7

run("iTunes.exe" , "C:\Program Files\iTunes")

Share this post


Link to post
Share on other sites
Nahuel

You are using it wrong.

Run("C:\Program files\iTunes\iTunes.exe")

The first parameter of Run() is the full path to the application you want to run. The second parameter is the working directory.

Share this post


Link to post
Share on other sites
hiddenlink

You are using it wrong.

Run("C:\Program files\iTunes\iTunes.exe")

The first parameter of Run() is the full path to the application you want to run. The second parameter is the working directory.

Ahh, ok Thanks a lot.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.