D4rk^S0ul Posted March 11, 2006 Share Posted March 11, 2006 What i have so far is: expandcollapse popup#include <GuiConstants.au3> GuiCreate("ShortCuts", 121, 179,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List = GuiCtrlCreateList("", 10, 30, 100, 110) $Label_2 = GuiCtrlCreateLabel("Shortcuts:", 10, 10, 80, 20) $Button_Add = GuiCtrlCreateButton("Add", 10, 150, 40, 20) $Button_Delete = GuiCtrlCreateButton("Clear", 70, 150, 40, 20) GuiSetState() $Add = GuiCreate("Add:", 376, 91,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Input_Name = GuiCtrlCreateInput("", 10, 30, 110, 20) $Label_2 = GuiCtrlCreateLabel("Shortcut Name:", 10, 10, 80, 20) $Input_Location = GuiCtrlCreateInput("", 140, 30, 160, 20) $Label_4 = GuiCtrlCreateLabel("Location:", 140, 10, 70, 20) $Button_Browse = GuiCtrlCreateButton("Browse", 310, 30, 50, 20) $Button_OK = GuiCtrlCreateButton("OK", 10, 60, 40, 20) $Button_Cancel = GuiCtrlCreateButton("Cancel", 70, 60, 60, 20) GuiSetState(@SW_HIDE) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_Add GUISetState(@SW_SHOW, $Add) Case $msg = $Button_Cancel GUISetState(@SW_HIDE, $Add) Case $msg = $Button_Browse $Browse = FileOpenDialog("Browse", @MyDocumentsDir, "All(*.*)", 1) GUICtrlSetData($Input_Location, $Browse) Case $msg = $Button_OK If GUICtrlRead($Input_Name) = "" Then MsgBox(0, "Enter a Name!", "Please enter a name!") Else $Name = GUICtrlRead($Input_Name) GUICtrlSetData($List, $Name) GUISetState(@SW_HIDE, $Add) EndIf Case $msg = $Button_Delete GUICtrlSetData($List, "") EndSelect WEnd Exit Is there any way to make it so if u click the list it will exicute the shortcut? Link to comment Share on other sites More sharing options...
Valuater Posted March 11, 2006 Share Posted March 11, 2006 (edited) Case $msg = $List $info = GUICtrlRead($List) Run($Info) 8) Edited March 11, 2006 by Valuater Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted March 11, 2006 Author Share Posted March 11, 2006 Only 1 prob the list doesnt hold the location only the name of the shortcut is there anyway to put the location in without it being visible and be able to run it when the name is ran, or would i have to add a array of name and compare the name to the locations name? Link to comment Share on other sites More sharing options...
DeFuser Posted March 11, 2006 Share Posted March 11, 2006 Only 1 prob the list doesnt hold the location only the name of the shortcut is there anyway to put the location in without it being visible and be able to run it when the name is ran, or would i have to add a array of name and compare the name to the locations name?I'd probably go with the method of running a Select Case on Valuater's $info variable. Cheers,Def Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted March 11, 2006 Author Share Posted March 11, 2006 Yes but like i said the list on holds the name of the shortcut not the location. Link to comment Share on other sites More sharing options...
BigDod Posted March 11, 2006 Share Posted March 11, 2006 Try Case $msg = $List $info = GUICtrlRead($List) $prog = FileGetShortcut($info) Run($prog) Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Valuater Posted March 11, 2006 Share Posted March 11, 2006 Try Case $msg = $List $info = GUICtrlRead($List) $prog = FileGetShortcut($info) Run($prog) thats the right idea... but if the the message is from the list read the variable that has the shortcut in it 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 11, 2006 Moderators Share Posted March 11, 2006 (edited) Try Case $msg = $List $info = GUICtrlRead($List) $prog = FileGetShortcut($info) Run($prog)If he has the shortcut already... wouldn't it be something like: Case $msg = $List $info = FileGetLongName(GUICtrlRead($List)) Run($info)? Edit: Actually, I just read it quickly, I still have no idea what the creator of the script is trying to accomplish? Edit2: Ok, after running the GUI I get the idea... are you planning on using an .ini or a .dat file to store the variables? Edited March 11, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
DeFuser Posted March 11, 2006 Share Posted March 11, 2006 Exactly - Once you have returned the shortcut name via $info = GUICtrlRead($List), then run value through a Select Case. Case $info = xxxx Run(xxxx) Case $info = yyyy Run(yyyy) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 11, 2006 Moderators Share Posted March 11, 2006 Is this what you had in mind?expandcollapse popup#include <GuiConstants.au3> #include <FILE.AU3> Global Const $WM_COMMAND = 0x0111 Global Const $LBN_SELCHANGE = 1 Global Const $LBN_DBLCLK = 2 Global $ShortCutSection = 'ShortCutName', $IniLocation = @ScriptDir & '\ShortCutStore.ini' If Not FileExists($IniLocation) Then _FileCreate($IniLocation) FileWriteLine($IniLocation, '[ShortCutName]') EndIf Local $SecValue = _SectionValue() $MAINGUI = GuiCreate("ShortCuts", 121, 179,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List = GuiCtrlCreateList("", 10, 30, 100, 110) $Label_2 = GuiCtrlCreateLabel("Shortcuts:", 10, 10, 80, 20) $Button_Add = GuiCtrlCreateButton("Add", 10, 150, 40, 20) $Button_Delete = GuiCtrlCreateButton("Clear", 70, 150, 40, 20) If $SecValue <> '' Then GUICtrlSetData($List, $SecValue) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_Add GUISetState(@SW_DISABLE, $MAINGUI) _Add_To_GUI() GUISetState(@SW_ENABLE, $MAINGUI) If Not WinActive($MAINGUI) Then WinActivate($MAINGUI) Case $msg = $Button_Delete $RemoveShortCutInfo = IniReadSection($IniLocation, $ShortCutSection) For $x = 1 To $RemoveShortCutInfo[0][0] If $RemoveShortCutInfo[$x][1] = GUICtrlRead($List) Then Remove_Shortcut($RemoveShortCutInfo[$x][0] & '=' & $RemoveShortCutInfo[$x][1]) ExitLoop EndIf Next $SecValue = _SectionValue() MsgBox(0, '', $SecValue) If $SecValue <> '' Then GUICtrlSetData($List, '') GUICtrlSetData($List, $SecValue) Else GUICtrlSetData($List, '') EndIf Case _IsPressed('0D') And ControlGetFocus($MAINGUI) = 'ListBox1' TakeAction() Sleep(200) EndSelect WEnd Func _Add_To_GUI() $Add_GUI = GuiCreate("Add:", 376, 91,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Input_Name = GuiCtrlCreateInput("", 10, 30, 110, 20) $Label_2 = GuiCtrlCreateLabel("Shortcut Name:", 10, 10, 80, 20) $Input_Location = GuiCtrlCreateInput("", 140, 30, 160, 20) $Label_4 = GuiCtrlCreateLabel("Location:", 140, 10, 70, 20) $Button_Browse = GuiCtrlCreateButton("Browse", 310, 30, 50, 20) $Button_OK = GuiCtrlCreateButton("OK", 10, 60, 40, 20) $Button_Cancel = GuiCtrlCreateButton("Cancel", 70, 60, 60, 20) GuiSetState() While 1 $ADD_MSG = GUIGetMsg() Select Case $ADD_MSG = $GUI_EVENT_CLOSE Or $ADD_MSG = $Button_Cancel ExitLoop Case $ADD_MSG = $Button_Browse $Browse = FileOpenDialog("Browse", @HomeDrive, "All(*.*)", 1) GUICtrlSetData($Input_Location, FileGetShortName($Browse)) Case $ADD_MSG = $Button_OK If GUICtrlRead($Input_Name) = "" Or GUICtrlRead($Input_Location) = '' Then MsgBox(64, "Error", "Please enter a name of the shortcut or the location of the file you wish to make a shortcut of!") Else IniWrite($IniLocation, $ShortCutSection, GUICtrlRead($Input_Location), GUICtrlRead($Input_Name)) GUICtrlSetData($List, GUICtrlRead($Input_Name)) ExitLoop EndIf EndSelect WEnd GUIDelete($ADD_GUI) EndFunc Func Remove_Shortcut($RemoveShortCut) Local $nArray = '' Local $TempPath = @TempDir & '\TempShortCutInfo.txt' _FileReadToArray($IniLocation, $nArray) For $i = 1 To UBound($nArray) - 1 If Not StringInStr($nArray[$i], $RemoveShortCut) And $nArray[$i] <> '' Then FileWriteLine($TempPath, $nArray[$i]) Next Do FileDelete($IniLocation) Until Not FileExists($IniLocation) FileMove($TempPath, $IniLocation, 1) Do Sleep(10) Until FileExists($IniLocation) Do FileDelete($TempPath) Until Not FileExists($TempPath) EndFunc Func _SectionKey() Local $sArray = IniReadSection($IniLocation, $ShortCutSection) If Not @error Then Local $ReturnArray = '' For $i = 1 To $sArray[0][0] If $sArray[$i][0] <> '' Then $ReturnArray = $ReturnArray & $sArray[$i][0] & '|' Next Return StringTrimRight($ReturnArray, 1) EndIf EndFunc Func _SectionValue() Local $sArray = IniReadSection($IniLocation, $ShortCutSection) If Not @error Then Local $ReturnArray = '' For $i = 1 To $sArray[0][0] If $sArray[$i][0] <> '' Then $ReturnArray = $ReturnArray & $sArray[$i][1] & '|' Next Return StringTrimRight($ReturnArray, 1) EndIf EndFunc Func TakeAction() Local $IniReadSection = IniReadSection($IniLocation, $ShortCutSection) If Not @error Then For $i = 1 To $IniReadSection[0][0] If GUICtrlRead($List) = $IniReadSection[$i][1] Then Run($IniReadSection[$i][0]) ExitLoop EndIf Next EndIf EndFunc Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAnd($wParam, 0x0000FFFF) $hCtrl = $lParam If $nID = $List Then Switch $nNotifyCode Case $LBN_DBLCLK TakeAction() Return 0 EndSwitch EndIf EndFunc Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFuncNOTE***Needs Beta!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 11, 2006 Share Posted March 11, 2006 nice job smoke 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now