Jump to content



Photo

Simple Program Launcher (First Script)


  • Please log in to reply
6 replies to this topic

#1 Zerothian

Zerothian

    Seeker

  • New Members
  • 2 posts

Posted 25 April 2012 - 10:50 PM

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.

Plain Text         
; 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, 25 April 2012 - 10:52 PM.








#2 playlet

playlet

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 459 posts

Posted 25 April 2012 - 10:59 PM

Welcome to the forum! ;)

That's exactly how I started my own launcher. Just keep exploring the goodies of this wonderful programming language :)

#3 Brenner96

Brenner96

    Seeker

  • New Members
  • 1 posts

Posted 26 April 2012 - 01:47 AM

Welcome to the forum!

Use Iniget for download a file in internet

#4 guinness

guinness

    guinness

  • MVPs
  • 11,062 posts

Posted 26 April 2012 - 04:21 AM

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

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_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()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_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()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#5 Zerothian

Zerothian

    Seeker

  • New Members
  • 2 posts

Posted 26 April 2012 - 10:34 AM

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

#6 guinness

guinness

    guinness

  • MVPs
  • 11,062 posts

Posted 26 April 2012 - 10:37 AM

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

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_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()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_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()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#7 cyberguy91

cyberguy91

    Seeker

  • Normal Members
  • 5 posts

Posted 28 April 2012 - 06:00 PM

Welcome to the forum!

Use Iniget for download a file in internet


I think you mean InetGet




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users