Sign in to follow this  
Followers 0
webmedic

App launcher gui

10 posts in this topic

Ok I'm looking for info if something like this has been done.

I want to make a little app that is just an app launcher. It will simply launch apps off of a cd. It ideally would open up a window that would give a list of apps that could be launched. Here may be the tricky part. I need it to be able to use a text file for it's entries. This is because the entries would be created dynamically at build time.

Is something like doable? is there any other code snips or apps I could look at to learn from?

I'm sorry I have been looking around these forums for a few months on and off now and I still don't see anything that really is what I'm looking for and I have yet to find something really comprehensive on how to make gui apps.

Thanks

Share this post


Link to post
Share on other sites

sorry just noticed I was in the wrong forum please feel free to move me. Thank you.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I have an AppLaunch script laying around.

Edited script.

Edited by SlimShady

Share this post


Link to post
Share on other sites

do you have an example ini file for it?

I can pick through to figure out the syntax I suppose but i think it would be easier if I had an example.

Share this post


Link to post
Share on other sites

hm never mind i see after looking at it if there are no items it asks you to add an item? I'm just looking very quickly of course and have no experience with autoit scripts really.

I have done lots of other scripting though.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Why? You need the script not the INI file.

Explain why. If the reason is not "I'm lazy", I'll attach it.

Edit:

I see you just posted again.

Edited by SlimShady

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I just renamed my INI file and ran the script and noticed it crashed.

I edited the script and I added FileZilla to test.

Here's the INI file:

[Programs]
Item1=C:\Program Files\FileZilla\FileZilla.exe
[Descriptions]
Item1=FileZilla
[Icons]
Item1=C:\Program Files\FileZilla\FileZilla.exe,0
[Settings]
Count=1

See previous post for the updated script.

Edited by SlimShady

Share this post


Link to post
Share on other sites

lol no I'm not lazy to be honest this is the first time I have really started looking at auto it scripts and it's still a little new to me. Thats all. Newbee on the loose and all that.

I do understand enough of it to understand that you do have a create function I did not look at it long enough to see how that function gets called I would imagine its in the while loop though.

Share this post


Link to post
Share on other sites

I have taken SlimShady's (thx's Slim) AppLaunch program & enhanced it a little bit

if anybody is interested in having it, here is the code:

We have just lost Admin Access with our every day user accounts and I got sick of running programs with the RunAs Option so here's my solution.

Added - UserID & Password so you can RunAs on your Apps

Added/fixed - when you Add your App the Icon selection now takes you back to the directory of the selected App, was taking you to C:\Program Files

Added - can now run "filename.msc" programs

If no password entered then will just Launch the App as standed

Enjoy :)

and again Thanks SlimShady

Opt ("TrayIconHide", 1)

If WinExists("DSS RunAs", "") Then
   WinMove("DSS RunAs", "", 0, 0)
   WinActivate("DSS RunAs", "")
   Exit
EndIf
Dim $UserID, $Password, $FullPath
$BS_ICON = 0x00000040
$BS_BITMAP = 0x00000080
$SS_SUNKEN = 0x1000
$Reset = "N"
$Style1 = BitOR(0x00080000, 0x00C00000, 0x00020000)
$Domain = "AN"; *********** need to changed this for your Domain ***********
$IniFile = @ScriptDir & "\DSSRunAs.ini"
$Count = IniRead($IniFile, "Settings", "Count", "0")

If $Count = "0" Then
    GUICreate("DSS RunAs", 225, 175, (@DesktopWidth-225)/2, (@DesktopHeight-175)/2, $Style1)
    AutoItSetOption("GUIResizeMode", 1)
    GUICtrlCreateLabel ("UserID:",  10, 15, 40, 0x11, $SS_SUNKEN)
    GUICtrlCreateLabel ("Password:", 100, 15, 55, 0x11, $SS_SUNKEN)
    $UserID = GUICtrlCreateInput ("", 10,  35, 65, 20)
    $Password = GUICtrlCreateInput ("", 100,  35, 65, 20, 0x0020)
    GUICtrlCreateButton ("Add Item", 150, 60, 75, 20)
    GUICtrlSetData($UserID, @UserName & "_adm"); *********** need to change this for your Admin Account ***********
    GUISetState (@SW_SHOW)
Else
    Init()
EndIf

While 1
   Do
      $msg = GUIGetMsg ()
      Sleep(10)
   Until $msg <> 0
   
   If $msg >= 8 Then
      
      If IsInt($msg / 2) Then
         $num = $msg / 2 - 3
      Else
         $num = ($msg - 1) / 2 - 3
      EndIf
      
      $Program = IniRead($IniFile, "Programs", "Item" & $num, "")
      $Program = StringReplace($Program, "#WinDir#", @WindowsDir)
      
      If $Program <> "" Then
        If GUICtrlRead($Password) <> "" Then
            RunAsSet(GUICtrlRead($UserID), $Domain, GUICtrlRead($Password), 0)
        EndIf
        If StringRight($Program, 4) = ".msc" Then
            Run(@SystemDir & "\mmc.exe " & $Program)
        Else
            Run($Program)
        EndIf
      Else
         MsgBox(0, "Error", "msg: " & $msg & @CRLF & "num: " & $num)
      EndIf
      
   ElseIf $msg = 7 Then
      AddItem()
      
   ElseIf $msg = -3 Then
      GUIDelete()
      Exit
      
   EndIf
Wend
GUIDelete()

Exit

Func AddItem()
    Local $i
    $Count = IniRead($IniFile, "Settings", "Count", "0")

    $NewItemNum = Number($Count) + 1

    $Program = FileOpenDialog("Choose a file...", "C:\", "App (*.exe;*.dll;*.msc)")
    If @error = 1 Then Return

    $Info = ParseFilename($Program)
    $Filename = $Info[2]
    
    $Description = InputBox("Description", "Enter a description for " & $Filename, $Filename, "", 300, 150)
    If @error = 1 Then Return

    $Icon = FileOpenDialog("Choose an icon file...", $FullPath, "Icon files (*.exe;*.dll;*.ico)")
    If @error = 1 Then Return

    $IconIndex = InputBox("IconIndex", "Enter the location (iconindex) of " & $Filename, "0", "", 300, 150)
    If @error = 1 Then Return

    IniWrite($IniFile, "Programs", "Item" & $NewItemNum, $Program)
    IniWrite($IniFile, "Descriptions", "Item" & $NewItemNum, $Description)
    IniWrite($IniFile, "Icons", "Item" & $NewItemNum, $Icon & "," & $IconIndex)
    IniWrite($IniFile, "Settings", "Count", Number($Count) + 1)
    $Reset = "Y"
    Init()
EndFunc  ;==>AddItem 

Func Init()
    $Count = IniRead($IniFile, "Settings", "Count", "0")
    If $Reset = "Y" Then
       $sUserID = GUICtrlRead($UserID)
       $sPassword = GUICtrlRead($Password)
    EndIf

    GUIDelete()
    GUICreate("DSS RunAs", 225, Number($Count) * 30 + 60, (@DesktopWidth-225)/2, (@DesktopHeight-Number($Count) * 30 + 60)/2, $Style1)
    GUICtrlCreateLabel ("UserID:",  10, 15, 40, 0x11, $SS_SUNKEN)
    GUICtrlCreateLabel ("Password:", 150, 15, 55, 0x11, $SS_SUNKEN)
    $UserID = GUICtrlCreateInput ("", 10,  35, 65, 20)
    $Password = GUICtrlCreateInput ("", 150,  35, 65, 20, 0x0020)
    GUICtrlSetData($UserID, @UserName & "_adm"); *********** need to change this for your Admin Account ***********

    GUICtrlCreateButton ("Add Item", 150, 60, 75, 20)
   
    $height = 60
    For $i = 1 To Number($Count)
        $ReadIcon = IniRead($IniFile, "Icons", "Item" & $i, "")
        $ReadIcon = StringReplace($ReadIcon, "#WinDir#", @WindowsDir)

        $SplitIcon = StringSplit($ReadIcon, ",")
        $Icon = $SplitIcon[1]
        $IconIndex = $SplitIcon[2]

        $Program = IniRead($IniFile, "Programs", "Item" & $i, "")
        $Program = StringReplace($Program, "#WinDir#", @WindowsDir)

        $Description = IniRead($IniFile, "Descriptions", "Item" & $i, "")
        If $i <> 1 Then $height = $height + 30

        $btn = GUICtrlCreateButton ("", 10, $height, 25, 25, $BS_ICON)
        GUICtrlSetImage ($btn, $Icon, $IconIndex, 0)
        GUICtrlSetTip ($btn, $Program)
        GUICtrlCreateLabel ($Description, 40, $height + 10, 100, 25)
    Next
    If $Reset = "Y" Then
        GUICtrlSetData($UserID, $sUserID)
        GUICtrlSetData($Password, $sPassword)
    EndIf
    GUISetState (@SW_SHOW)
    $Reset = "N"
EndFunc  ;==>Init 

Func ParseFilename($File)
    Local $i
    If StringLeft($File, 4) = "http" Or StringLeft($File, 3) = "ftp" Then
        $TempSplit = StringSplit($File, "/")
        Local $num = $TempSplit[0]
        $Parent = $TempSplit[$num - 1]
        $TempName = $TempSplit[$num]
        $length = StringLen($TempName)

        $x = $length
        Do
            $x = $x - 1
            $Match = StringMid($TempName, $x, 1)
            If $Match = "=" Then ExitLoop
        Until $x = 0
      
        $Filename = StringTrimLeft($File, $x)
    Else
        $TempSplit = StringSplit($File, "\")
        $num = $TempSplit[0]
        $Parent = $TempSplit[$num - 1]
        $Filename = $TempSplit[$num]
    EndIf
    For $i = 1 To $num - 1
        $FullPath = $FullPath & "" & $TempSplit[$i] & "\"
    Next
    Dim $Info[4]
    $Info[0] = StringLeft(@WindowsDir, 3)
    $Info[1] = $Parent
    $Info[2] = $Filename
    $Info[3] = StringRight($Filename, 3)
    Return $Info
EndFunc  ;==>ParseFilename

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