Jump to content

Program Launcher


Flamingwolf
 Share

Recommended Posts

This is a quick program I made for my computer at school to run programs whenever I log in. It's pretty self explanatory, but if you don't understand what something does, just ask and I'll let you know.

It uses an ini file to know what programs to launch, so it's pretty customizable. If there's no "proglaunch.ini" it will generate one that opens a website [google]

Launcher app:

#include <File.au3>

If not FileExists("proglaunch.ini") Then
    MsgBox(0, "Program Launcher", "ERROR: No proglaunch.ini file detected. A default ini will be created.")
    _FileCreate("proglaunch.ini")
    IniWrite("proglaunch.ini", "howmany", "number", 1)
    IniWrite("proglaunch.ini", "settings", "settings", 0)
    IniWrite("proglaunch.ini", "stufftorun", "1", "http://google.com/")
EndIf

$howMuch2Open = IniRead("proglaunch.ini", "howmany", "number", -1)

For $i = 1 To $howMuch2Open Step +1
    $i2 = StringSplit(IniRead("proglaunch.ini", "stufftorun", $i, -1), "\")
    If IniRead("proglaunch.ini", "settings", "settings", -1) = 0 Then
        if not ProcessExists($i2[$i2[0]]) Then
            ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
        Else
            If MsgBox(4, "Program Launcher", "Process '" & $i2[$i2[0]] & "' already exists. Run it again?") = 6 Then
                If MsgBox(4, "Program Launcher", "Do you wish to close the old process '" & $i2[$i2[0]] & "' before reopening it?") = 6 Then
                    ProcessClose($i2[$i2[0]])
                    ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
                Else
                    ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
                EndIf
            EndIf
        EndIf
    ElseIf IniRead("proglaunch.ini", "settings", "settings", -1) = 1 Then
        if not ProcessExists($i2[$i2[0]]) Then
            ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
        Else
            ProcessClose($i2[$i2[0]])
            ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
        EndIf
    ElseIf IniRead("proglaunch.ini", "settings", "settings", -1) = 2 Then
        ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
    EndIf
Next
ExitoÝ÷ ØHØ­x¦®¶­sb6æ6ÇVFRfÇC´'WGFöä6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´uT6öç7FçG4WæS2fwC°¢6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´Æ7D&÷6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´wVÆ7D&÷æS2fwC°¢6æ6ÇVFRfÇCµvæF÷w46öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´fÆRæS2fwC° ¢b33c´f÷&ÓÒuT7&VFRgV÷C´f÷&ÓgV÷C²Â#3BÂ#Â2Â#RÂÓÂ&Dõ"b33cµu5ôUõDôôÅtäDõrÂb33cµu5ôUõDõÔõ5BÂb33cµu5ôUõtäDõtTDtRÂb33cµu5ôUô44UDdÄU2¢b33c¶Æ7BÒuT7G&Ä7&VFTÆ7BgV÷C²gV÷C²ÂÂÂ#rÂ3b¢b33c¶vVæW&FTäÒuT7G&Ä7&VFT'WGFöâgV÷C´vVæW&FRägV÷C²Â#ÂCÂRÂ#R¢b33c¶÷VääÒuT7G&Ä7&VFT'WGFöâgV÷C´÷VâägV÷C²ÂÂCÂRÂ#R¢b33c·VBÒuT7G&Ä7&VFT'WGFöâgV÷C´WBgV÷C²ÂBÂsbÂCÂ#R¢b33c¶ÆVæ6&öw2ÒuT7G&Ä7&VFT'WGFöâgV÷C´ÆVæ6b333²gV÷C²ÂÂsbÂCÂ#R¢b33c¶FVÅ6VÂÒuT7G&Ä7&VFT'WGFöâgV÷C´FVÆWFR6VÆV7FVBFVÒgV÷C²ÂcBÂsbÂ2Â#R¤uT6WE7FFR5uõ4õr ¤6öç7Bb33cµtÕôE$õdÄU2Ò#30¤uT&Vv7FW$×6rb33cµtÕôE$õdÄU2ÂgV÷CµtÕôE$õdÄU2gV÷C² ¤gVæ2÷Vää¢bfÆTW7G2gV÷C·&övÆVæ6æægV÷C²FVà¢b33c¶æÒæ&VE6V7FöâgV÷C·&övÆVæ6æægV÷C²ÂgV÷C·7GVfgF÷'VâgV÷C²¢f÷"b33c¶ÒFòb33c¶æ³Õ³Ó²7FW³¢uT7G&Å6WDFFb33c¶Æ7BÂb33c¶æ²b33c¶Õ³Ò¢æW@¢VæD`¤VæDgVæ2³ÓÒfwC¶÷Vää ¤gVæ2vVæW&FTä¢b33c·ÒôuT7G&ÄÆ7D&÷ôvWD6÷VçBb33c¶Æ7B¢æw&FRgV÷C·&övÆVæ6æægV÷C²ÂgV÷C¶÷vÖçgV÷C²ÂgV÷C¶çVÖ&W"gV÷C²Âb33c·¢æw&FRgV÷C·&övÆVæ6æægV÷C²ÂgV÷C·6WGFæw2gV÷C²ÂgV÷C·6WGFæw2gV÷C²ÂgV÷C³gV÷C²¢f÷"b33c¶ÒFòb33c·¢æw&FRgV÷C·&övÆVæ6æægV÷C²ÂgV÷C·7GVfgF÷'VâgV÷C²Âb33c¶ÂôuT7G&ÄÆ7D&÷ôvWEFWBb33c¶Æ7BÂb33c¶Ò¢æW@¤VæDgVæ2³ÓÒfwC¶vVæW&FTä ¤gVæ2ÆVæ6&öw2¢b33c¶÷t×V6$÷VâÒæ&VBgV÷C·&övÆVæ6æægV÷C²ÂgV÷C¶÷vÖçgV÷C²ÂgV÷C¶çVÖ&W"gV÷C²ÂÓ ¢f÷"b33c¶ÒFòb33c¶÷t×V6$÷Vâ7FW³¢b33c¶"Ò7G&æu7ÆBæ&VBgV÷C·&övÆVæ6æægV÷C²ÂgV÷C·7GVfgF÷'VâgV÷C²Âb33c¶ÂÓÂgV÷C²b3#²gV÷C²¢bæ÷B&ö6W74W7G2b33c¶%²b33c¶%³ÕÒFVà¢6VÆÄWV7WFRæ&VBgV÷C·&övÆVæ6æægV÷C²ÂgV÷C·7GVfgF÷'VâgV÷C²Âb33c¶ÂÓ¢VÇ6P¢&ö6W746Æ÷6Rb33c¶%²b33c¶%³ÕÒ¢6VÆÄWV7WFRæ&VBgV÷C·&övÆVæ6æægV÷C²ÂgV÷C·7GVfgF÷'VâgV÷C²Âb33c¶ÂÓ¢VæD`¢æW@¢W@¤VæDgVæ2³ÓÒfwC¶ÆVæ6&öw0 ¤gVæ2FVÅ6V¢b33c·ÒôuT7G&ÄÆ7D&÷ôvWD7W%6VÂb33c¶Æ7B¢ôuT7G&ÄÆ7D&÷ôFVÆWFU7G&ærb33c¶Æ7BÂb33c·¢b33c·ÒôuT7G&ÄÆ7D&÷ôvWD6÷VçBb33c¶Æ7B¢bb33c·fÇC²b33c·FVà¢ôuT7G&ÄÆ7D&÷õ6WD7W%6VÂb33c¶Æ7BÂb33c·¢VÇ6P¢ôuT7G&ÄÆ7D&÷õ6WD7W%6VÂb33c¶Æ7BÂb33c·Ò¢VæD`¤VæDgVæ2³ÓÒfwC¶FVÅ6VÀ ¥vÆR¢b33c¶ä×6rÒuTvWD×6r¢7vF6b33c¶ä×6p¢66Rb33c´uTôUdTåEô4Äõ4P¢W@¢66Rb33c·V@¢W@¢66Rb33c¶÷Vää¢÷Vää¢66Rb33c¶vVæW&FTä¢vVæW&FTä¢66Rb33c¶ÆVæ6&öw0¢ÆVæ6&öw2¢66Rb33c¶FVÅ6VÀ¢FVÅ6V¢VæE7vF6¥tVæ@ ¤gVæ2tÕôE$õdÄU2b33c¶væBÂb33c´×6rÂb33c·u&ÒÂb33c¶Å&Ò¢Æö6Âb33c·DG&÷Âb33c¶&WBÂb33c¶6÷Vç@¢·7G&ær'VffW""fÆRF¢b33c·DG&÷ÒFÆÅ7G'V7D7&VFRgV÷C¶6%³#cÒgV÷C²¢¶vWBfÆR6÷Vç@¢b33c¶&WBÒFÆÄ6ÆÂgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷C´G&uVW'fÆRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c·u&ÒÂgV÷C·VçBgV÷C²ÂÓÂgV÷C·G"gV÷C²ÂFÆÅ7G'V7DvWEG"b33c·DG&÷ÂgV÷C¶çBgV÷C²ÂFÆÅ7G'V7DvWE6¦Rb33c·DG&÷¢b33c¶6÷VçBÒb33c¶&WE³Ð¢¶vWBfÆRF0¢Æö6Âb33c´7W$æfòÒuTvWD7W'6÷$æfòb33c´f÷&Ó¢b4'&b33c´7W$æfòæBb33c´7W$æfõ³EÒÒb33c¶Æ7BFVà¢f÷"b33c¶ÒFòb33c¶6÷VçBÒ¢b33c¶&WBÒFÆÄ6ÆÂgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷C´G&uVW'fÆRgV÷C²ÂgV÷C¶væBgV÷C²Âb33c·u&ÒÂgV÷C·VçBgV÷C²Âb33c¶ÂgV÷C·G"gV÷C²ÂFÆÅ7G'V7DvWEG"b33c·DG&÷ÂgV÷C¶çBgV÷C²ÂFÆÅ7G'V7DvWE6¦Rb33c·DG&÷¢´6öç6öÆUw&FRFÆÅ7G'V7DvWDFFb33c·DG&÷Âfײ5$Äb¢uT7G&Å6WDFFb33c¶Æ7BÂFÆÅ7G'V7DvWDFFb33c·DG&÷¢æW@¢VæD`¢¶fæƦP¢FÆÄ6ÆÂgV÷C·6VÆÃ3"æFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷C´G&tfæ6gV÷C²ÂgV÷C¶væBgV÷C²Âb33c·u&Ò¢&WGW&à¤VæDgVæ2³ÓÒfwCµtÕôE$õdÄU

Ini file:

[howmany];How many things to launch (0 does not work here)
  number=1
  [settings];0=ask before relaunching and closing programs, 1=automatically close and relaunch programs
  settings=1;2=always reopen without closing previous instances.
  [stufftorun];What to launch (programs, files, websites)
  1=SweepRAM.exe
;1=http://www.google.com/
;2=example.exe;launching programs in same directory as ProgramLauncher.exe
;3=C:\Example Of How\To Use\Folders To Get To\A\Program.exe
;4=Using Folders\That Are In\Same Folder\As Launcher\To Launch\Programs.exe

If you have any suggestions, please post them here! Thanks!

ProgramLauncher.rar

Edited by Flamingwolf
Link to comment
Share on other sites

Very nice start! My suggestion, add a GUI for settup to setup the applications to open...

Do you think I should do this with a separate program? Because the way this is now I don't see how I could integrate it with the main exe. Actually, if it's possible, I guess I could have it open the settings when you run it with the parameter -settings or something, but I'll have to learn how to do that.

Link to comment
Share on other sites

Do you think I should do this with a separate program? Because the way this is now I don't see how I could integrate it with the main exe. Actually, if it's possible, I guess I could have it open the settings when you run it with the parameter -settings or something, but I'll have to learn how to do that.

You could run the Setup GUI at first startup of your script. then delete the gui after the user has placed the settings, to show the GUI again you could make a traymenu with some options.

Cheers

Ashww

X)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Projects: Account Control Wii style gui Bingo Caller - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Want a website? Click here!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -I use my Blackberry Storm to browse the forum! Please be patient!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Link to comment
Share on other sites

You could run the Setup GUI at first startup of your script. then delete the gui after the user has placed the settings, to show the GUI again you could make a traymenu with some options.

Cheers

Ashww

X)

The only problem with that is that the program ends before anything can actually happen, since it just runs the programs and exits. For now I'm just going to make an external program to make the config.

Link to comment
Share on other sites

I would just make a separate configuration GUI that has to be ran individually and call it up if no INI is found as in the initial run instead of writing the INI with the google link have it call up the configuration file...

Thats kinda what i ment.

Cheers

Ashww

X)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Projects: Account Control Wii style gui Bingo Caller - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Want a website? Click here!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -I use my Blackberry Storm to browse the forum! Please be patient!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Link to comment
Share on other sites

Here's the menu editing GUI. You can drop files on the GUI, but the paths will be absolute [ex. "C:\..."]

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=PortableApps\AutoIt\Icons\filetype-blank.ico
#AutoIt3Wrapper_outfile=ProgramLauncherINIEdit.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <ListBoxConstants.au3>
#include <GuiListBox.au3>
#include <WindowsConstants.au3>
#include <File.au3>

$Form1 = GUICreate("Form1", 234, 208, 193, 125, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE, $WS_EX_ACCEPTFILES))
$appList = GUICtrlCreateList("", 8, 8, 217, 136)
$generateINI = GUICtrlCreateButton("Generate INI", 120, 148, 105, 25, 0)
$openINI = GUICtrlCreateButton("Open INI", 8, 148, 105, 25, 0)
$quit = GUICtrlCreateButton("Exit", 184, 176, 41, 25, 0)
$launchProgs = GUICtrlCreateButton("Launch!", 8, 176, 49, 25, 0)
$delSel = GUICtrlCreateButton("Delete Selected Item", 64, 176, 113, 25, 0)
GUISetState(@SW_SHOW)

Const $WM_DROPFILES = 0x233
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")

Func openINI()
    If FileExists("proglaunch.ini") Then
        $ini = IniReadSection("proglaunch.ini", "stufftorun")
        For $i = 1 To $ini[0][0]; Step +1
            GUICtrlSetData($appList, $ini[$i][1])
        Next
    EndIf
EndFunc   ;==>openINI

Func generateINI()
    $x = _GUICtrlListBox_GetCount($appList)
    IniWrite("proglaunch.ini", "howmany", "number", $x)
    IniWrite("proglaunch.ini", "settings", "settings", "1")
    For $i = 1 To $x
        IniWrite("proglaunch.ini", "stufftorun", $i, _GUICtrlListBox_GetText($appList, $i - 1))
    Next
EndFunc   ;==>generateINI

Func launchProgs()
    $howMuch2Open = IniRead("proglaunch.ini", "howmany", "number", -1)

    For $i = 1 To $howMuch2Open Step +1
        $i2 = StringSplit(IniRead("proglaunch.ini", "stufftorun", $i, -1), "\")
        If Not ProcessExists($i2[$i2[0]]) Then
            ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
        Else
            ProcessClose($i2[$i2[0]])
            ShellExecute(IniRead("proglaunch.ini", "stufftorun", $i, -1))
        EndIf
    Next
    Exit
EndFunc   ;==>launchProgs

Func delSel()
    $x = _GUICtrlListBox_GetCurSel($appList)
    _GUICtrlListBox_DeleteString($appList, $x)
    $y = _GUICtrlListBox_GetCount($appList)
    If $x < $y Then
        _GUICtrlListBox_SetCurSel($appList, $x)
    Else
        _GUICtrlListBox_SetCurSel($appList, $x - 1)
    EndIf
EndFunc   ;==>delSel

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $quit
            Exit
        Case $openINI
            openINI()
        Case $generateINI
            generateINI()
        Case $launchProgs
            launchProgs()
        Case $delSel
            delSel()
    EndSwitch
WEnd

Func WM_DROPFILES($hWnd, $Msg, $wParam, $lParam)
    Local $tDrop, $aRet, $iCount
    ;string buffer for file path
    $tDrop = DllStructCreate("char[260]")
    ;get file count
    $aRet = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "uint", -1, "ptr", DllStructGetPtr($tDrop), "int", DllStructGetSize($tDrop))
    $iCount = $aRet[0]
    ;get file paths
    Local $CurInfo = GUIGetCursorInfo($Form1)
    If IsArray($CurInfo) And $CurInfo[4] = $appList Then
        For $i = 0 To $iCount - 1
            $aRet = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "uint", $i, "ptr", DllStructGetPtr($tDrop), "int", DllStructGetSize($tDrop))
            ;ConsoleWrite(DllStructGetData($tDrop, 1) & @CRLF)
            GUICtrlSetData($appList, DllStructGetData($tDrop, 1))
        Next
    EndIf
    ;finalize
    DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam)
    Return
EndFunc   ;==>WM_DROPFILES

Once again, if you find any bugs, let me know. :)

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