Jump to content

Simple Program Launcher (First Script)


Zerothian
 Share

Recommended Posts

Well as the title says, this is my first script that i have written on my own.

I used the GUI Creator (Forgot the name) In the AutoIT editor for the GUI itself but i wrote the part to launch the programs and pop a MsgBox.

I know it's very basic but i only started learning scripting with AutoIt today xD.

C&C Welcome. Also any suggestion on how to tidy the script up would be appreciated as well.

Thanks.

; Created by Zero'
; Simple 4 Program Launcher w/Buttons
; Date: 25/04/2012

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Clark's Launcher", 319, 29)
Global $Button1 = GUICtrlCreateButton("Steam", 0, 0, 75, 25)
Global $Button2 = GUICtrlCreateButton("Firefox", 80, 0, 75, 25)
Global $Button3 = GUICtrlCreateButton("Origin", 160, 0, 75, 25)
Global $Button4 = GUICtrlCreateButton("Spotify", 240, 0, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Run("C:Program Files (x86)SteamSteam.exe")
            msgbox(262192, "Clark's Launcher", "Steam Has Been Launched", 3)
        Case $Button2
            Run("C:Program Files (x86)Mozilla Firefoxfirefox.exe")
            MsgBox(262192, "Clark's Launcher", "Firefox Has Been Launched", 3)
        Case $Button3
            Run("C:Program Files (x86)OriginOrigin.exe")
            MsgBox(262192, "Clark's Launcher", "Origin Has Been Launched", 3)
        Case $Button4
            Run("C:UsersxxxxAppDataRoamingSpotifyspotify.exe")
            MsgBox(262192, "Clark's Launcher", "Spotify Has Been Launched", 3)
    EndSwitch
WEnd
Edited by Zerothian
Link to comment
Share on other sites

Zerothian you seem eager to learn, so get your teeth stuck into this >>

This example is the same but it demonstrates the basics such as loops, arrays and environment variables. Good luck.

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aArray[5][2] = [[4, 2],['Firefox', '%PROGRAMFILES(X86)%Mozilla Firefoxfirefox.exe'],['Spotify', @AppDataDir & 'Spotifyspotify.exe'], _
            ['FirefoxEx', '%PROGRAMFILES(X86)%Mozilla Firefoxfirefox.exe'],['SpotifyEx', @AppDataDir & 'Spotifyspotify.exe']]
    Local $hGUI = GUICreate('Example Launcher', 365, 40, -1, -1), $iLeft = 5, $iMsg = 0

    For $i = 1 To $aArray[0][0]
        $aArray[$i][0] = GUICtrlCreateButton($aArray[$i][0], $iLeft, 5, 85, 25)
        $iLeft += 90
    Next
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $aArray[1][0] To $aArray[$aArray[0][0]][0]
                For $i = 1 To $aArray[0][0]
                    If $iMsg = $aArray[$i][0] Then
                        If Run(_WinAPI_ExpandEnvironmentStrings($aArray[$i][1])) Then
                            MsgBox(4096, '', GUICtrlRead($aArray[$i][0]) & ' Launched.', 3, $hGUI)
                        EndIf
                        ExitLoop
                    EndIf
                Next
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Thanks for the example mate ;). It gave me an undeclared global variable error on the $GUI_EVENT_CLOSE. But i included...

#include <StaticConstants.au3>
#Include <GUIConstantsEX.au3>

And it launched fine now i am going to scour the script and find out what makes it tick :). Thanks again.

Zero

Link to comment
Share on other sites

What version of AutoIt are you using? I have V3.3.8.1.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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