Jump to content

Problems with shortcuts


botanic
 Share

Recommended Posts

My problem is with

$ink = FileGetShortcut($var)

if @error <> 1 then $var = $ink[0]

For some reason things like my quicktime shortcut and such make it go all screwey... and doesnt find the exe

#include <C:\Program Files\AutoIt3\Include\GUIConstants.au3>
#include <C:\Program Files\AutoIt3\Include\GuiComboBoxEx.au3>
#include <C:\Program Files\AutoIt3\Include\GuiImageList.au3>
#Include <C:\Program Files\AutoIt3\Include\String.au3>
#Include <C:\Program Files\AutoIt3\Include\WinAPI.au3>


global $1, $call, $ini, $file, $hGUI, $tmp, $iIndex
$file = "C:\Documents and Settings\Matthew\My Documents\My Games\Gamelist.ini"

func _run()
    Local $hGUI, $hImage, $hCombo, $tmm
    $tmp = ""
    
    ; Create GUI
    $hGUI = GUICreate("Games", 400, 130)
    $b1 = GUICtrlCreateButton("Run Game",5,103)
    $b2 = GUICtrlCreateButton("Add/Edit Game",70,103)
    $b3 = GUICtrlCreateButton("Remove Game",155, 103)
    $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 100, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    GUISetState()
    $ini = IniReadSectionNames($file)

if $ini <> @error then
    For $1 = 1 to $ini[0]
    _GUICtrlComboBoxex_AddString ($hCombo, $ini[$1])
Next
EndIf

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $b1
            $tmp = _GUICtrlComboBoxEx_GetCurSel($hCombo)
            $tmp = IniRead($file, $ini[$tmp+1], "Path","")
            Run($tmp)
            Exit
        Case $msg = $b2
            $tmp = _GUICtrlComboBoxEx_GetCurSel($hCombo)
    $ini = IniReadSectionNames($file)
            if $ini <> @error then
            $tmp = IniRead($file, $ini[$tmp+1], "Path","")
        Else
            $tmp = ""
            EndIf
            GUIDelete($hGUI)
            _add($tmp)
            
        Case $msg = $b3
            $tmp = _GUICtrlComboBoxEx_GetCurSel($hCombo)
            IniWriteSection($file, $ini[$tmp+1], "")
            IniDelete($file, $ini[$tmp+1])
            GUIDelete($hGUI)
            _run()
    EndSelect
Wend
    
EndFunc
func _choose($xxxxc)
    
if $xxxxc = "" Then
    $var = FileOpenDialog("Browse for the EXE", @DesktopDir, "Executable (*.exe)", 1 )
    if @error Then
    Else
    $tmp = StringSplit(_StringReverse(StringTrimRight(FileGetLongName($var,1),4)),"\")
    $tmp = InputBox("Game Name", "Please type the game name", _StringReverse($tmp[1]))
    IniWrite($file,$tmp,"Path", $var)
    EndIf

    Else
    $var = FileOpenDialog("Browse for the EXE", $xxxxc, "Executable (*.exe)", 1 )
    if @error Then
    Else
    $tmp = StringSplit(_StringReverse(StringTrimRight(FileGetLongName($var,1),4)),"\")
    $tmp = InputBox("Game Name", "Please type the game name", _StringReverse($tmp[1]))
    IniWrite($file,$tmp,"Path", $var)
    IniWriteSection($file, $ini[$tmp+1], "")
    IniDelete($file, $ini[$tmp+1])

EndIf
EndIf


            _run()
EndFunc

func _add($tmp)
local $file2, $tpm, $tmpp, $xxxxc, $ink , $ico
        
        $xxxc = GUICreate("Add a game", 300,60, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, $WS_EX_ACCEPTFILES); WS_EX_ACCEPTFILES
        $var = GUICtrlCreateInput ( $tmp, 10,  5, 220, 20)
        GUICtrlSetState(-1,$GUI_DROPACCEPTED)
        $btn = GUICtrlCreateButton ("Browse", 230,  5, 60, 20)
        $ok = GUICtrlCreateButton ("Add", 10,  35, 60, 20)
        $ccl = GUICtrlCreateButton ("Cancel", 75,  35, 60, 20)
        GUISetState () 
    
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
       Case $msg = $btn
GUIDelete($hGUI)
               _choose($tmp)
           Case $msg = $ok
               $var = GUICtrlRead($var)

                   if $var = "" or $var = " " then 
                       MsgBox(0, "Opps!", "This cannot be blank")
                       exitloop
                   Else
                    $ink =   FileGetShortcut($var)
                    if @error <> 1 then $var = $ink[0]
                    $tmpp = StringSplit(_StringReverse(StringTrimRight(FileGetLongName($var,1),4)),"\")
                    $tmpp = InputBox("Game Name", "Please type the game name", _StringReverse($tmpp[1]))
                    IniWrite($file,$tmpp,"Path", $var)
                    if $tmp <> $tmpp and $tmp <> "" Then
                    IniWriteSection($file, $ini[$tmp+1], "")
                    IniDelete($file, $ini[$tmp+1])
                    EndIf
                    exitloop
                    EndIf

           Case $msg = $ccl
               exitloop
       EndSelect
   Wend
   GUIDelete($hGUI)
    _run()
EndFunc
_run()

Solved use shellexecute and dont get the destination exe

Edited by botanic
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...