Laymanball Posted September 27, 2011 Share Posted September 27, 2011 (edited) Help me. DoubleClick on program name in listview to run program. Thanks. Edited September 27, 2011 by Laymanball My Sample Script Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html Link to comment Share on other sites More sharing options...
Beege Posted September 27, 2011 Share Posted September 27, 2011 I believe you would need to register msg WM_NOTIFY to recive a the dbclick msg. Look at GuiListView UDF in the help file. _GuiCtrlListView_SubItemHitTest() gives a good example of using WM_NOTIFY. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 27, 2011 Moderators Share Posted September 27, 2011 Laymanball, By chance I posted this yesterday. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Laymanball Posted September 27, 2011 Author Share Posted September 27, 2011 (edited) Thanks..Idea.. Beege and Melba23. But,I would choose to import all the files on the drive or folder into a ListView and can double click at a program name to run program.How to write code?----------------------------------------------------------------------------------I write new code. expandcollapse popup#NoTrayIcon #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_LV = False Global $hListView, $pid _Main() Func _Main() GUICreate("ListView DoubleClick Item", 320, 140, -1, -1) GUICtrlCreateLabel("DoubleClick Program name to Run", 75, 10, 167, 17) $hListView = GUICtrlCreateListView("", 10, 30, 300, 100) _GUICtrlListView_SetUnicodeFormat($hListView, False) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlListView_InsertColumn($hListView, 0, "Programs name", 300) _GUICtrlListView_AddItem($hListView, "Notepad.exe", 0) _GUICtrlListView_AddItem($hListView, "Calc.exe", 1) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) _DebugPrint(DllStructGetData($tInfo, "Index")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _DebugPrint($iIndex) ConsoleWrite("--> Line:Index "& $iIndex & @LF) Switch $iIndex Case 0 $pid = Run("Notepad.exe") Sleep(1500) ProcessClose($pid) Case 1 $pid = Run("Calc.exe") Sleep(1500) ProcessClose($pid) EndSwitch EndFuncORexpandcollapse popup#NoTrayIcon #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_LV = False Global $GUI, $hListView, $pid _Main() Func _Main() $GUI = GUICreate("RunApp in ListView", 320, 240, -1, -1) GUICtrlCreateLabel("DoubleClick Program name to Run", 75, 10, 167, 17) $hListView = _GUICtrlListView_Create($GUI, "", 10, 30, 300, 200) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_SetUnicodeFormat($hListView, True) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlListView_InsertColumn($hListView, 0, "Application:", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Target:", 200) _GUICtrlListView_AddItem($hListView, "Notepad.exe", 0) _GUICtrlListView_AddItem($hListView, "Calc.exe", 1) _GUICtrlListView_AddSubItem($hListView, 0, @SystemDir, 1) _GUICtrlListView_AddSubItem($hListView, 1, @SystemDir, 1) EndFunc Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) _DebugPrint(DllStructGetData($tInfo, "Index")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _DebugPrint($iIndex) ConsoleWrite("--> Line:Index "& $iIndex & @LF) Switch $iIndex Case 0 $pid = Run("Notepad.exe") Sleep(1000) ProcessClose($pid) Case 1 $pid = Run("Calc.exe") Sleep(1000) ProcessClose($pid) Case -1 MsgBox(0, "", "No, Program name.", 1, $GUI) EndSwitch EndFunc Edited September 28, 2011 by Laymanball My Sample Script Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 28, 2011 Moderators Share Posted September 28, 2011 Laymanball, Use _FileListToArray to get an array of all the *.exe files in the folder and then loop through the array to add them to the ListView. When the item is clicked, concantenate the original path the the name and use Run. If you want to list the executables in subfolders on the path then look at the RecFileListToArray UDF in my sig. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Laymanball Posted September 28, 2011 Author Share Posted September 28, 2011 Laymanball, Use _FileListToArray to get an array of all the *.exe files in the folder and then loop through the array to add them to the ListView. When the item is clicked, concantenate the original path the the name and use Run. If you want to list the executables in subfolders on the path then look at the RecFileListToArray UDF in my sig. M23 Thanks. I will try to write. My Sample Script Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html Link to comment Share on other sites More sharing options...
Laymanball Posted September 29, 2011 Author Share Posted September 29, 2011 Help me. App in List not run expandcollapse popup#NoTrayIcon #Include <Array.au3> #include <ButtonConstants.au3> #Include <File.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $GUI = GUICreate("RunApp in ListView", 545, 290, -1, -1) $Label = GUICtrlCreateLabel("Discript:Files List", 190, 10, 200, 17) $Button = GUICtrlCreateButton("Browse", 200, 250, 75, 25, $WS_GROUP) GUICtrlSetCursor(-1, 0) $hListView = _GUICtrlListView_Create($GUI, "", 10, 30, 525, 200) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_SetUnicodeFormat($hListView, True) _GUICtrlListView_InsertColumn($hListView, 0, "Application:", 225) _GUICtrlListView_InsertColumn($hListView, 1, "Target:", 300) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button $sFiles = FileSelectFolder("Choose a drive or folder", @DesktopDir, 2) If(@error)Or(Not $sFiles) Then Exit $iFlist = _FileListToArray($sFiles, "*", 0) For $i = 0 To UBound($iFlist)-1 _GUICtrlListView_AddItem($hListView, $iFlist[$i]&@CRLF) Next _GUICtrlListView_DeleteItem($hListView, 0) $iCount = _GUICtrlListView_GetItemCount($hListView) $Target = $sFiles For $x = 0 To $iCount _GUICtrlListView_AddSubItem($hListView, $x, $Target, 1) Next If $iCount Then GUICtrlSetData($Label, "Discript:BoubleClick App name to Run") EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) _DebugPrint(DllStructGetData($tInfo, "Index")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _DebugPrint($iIndex) ConsoleWrite("--> Line:Index "& $iIndex & @LF) Global $ItemText = _GUICtrlListView_GetItemText($hListView, $iIndex) Switch $iIndex Case 0 _message() Case 1 _message() Case 2 _message() Case 3 _message() Case 4 _message() Case 5 _message() Case 6 _message() Case 7 _message() Case 8 _message() Case 9 _message() Case 10 _message() Case 11 _message() Case -1 MsgBox(0, "", "No, Program name.", 1, $GUI) EndSwitch EndFunc Func _message() MsgBox(0, "ItemText", $ItemText) EndFunc My Sample Script Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2011 Moderators Share Posted September 29, 2011 Laymanball,Interesting - the returned text ends in @CRLF. So you need to remove it before you try to use that text to Run the file: expandcollapse popup;#NoTrayIcon #include <Array.au3> #include <ButtonConstants.au3> #include <File.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $sAppClicked = "" $GUI = GUICreate("RunApp in ListView", 545, 290, -1, -1) $Label = GUICtrlCreateLabel("Discript:Files List", 190, 10, 200, 17) $Button = GUICtrlCreateButton("Browse", 200, 250, 75, 25, $WS_GROUP) GUICtrlSetCursor(-1, 0) $hListView = _GUICtrlListView_Create($GUI, "", 10, 30, 525, 200) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_SetUnicodeFormat($hListView, True) _GUICtrlListView_InsertColumn($hListView, 0, "Application:", 225) _GUICtrlListView_InsertColumn($hListView, 1, "Target:", 300) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button $sFiles = FileSelectFolder("Choose a drive or folder", @DesktopDir, 2) If (@error) Or (Not $sFiles) Then Exit $iFlist = _FileListToArray($sFiles, "*", 0) For $i = 0 To UBound($iFlist) - 1 _GUICtrlListView_AddItem($hListView, $iFlist[$i] & @CRLF) Next _GUICtrlListView_DeleteItem($hListView, 0) $iCount = _GUICtrlListView_GetItemCount($hListView) $Target = $sFiles For $x = 0 To $iCount _GUICtrlListView_AddSubItem($hListView, $x, $Target, 1) Next If $iCount Then GUICtrlSetData($Label, "Discript:BoubleClick App name to Run") EndSwitch If $sAppClicked Then $sAppToRun = $sFiles & "\" & StringTrimRight($sAppClicked, 2) ; <<<<<<<< Remove the trailing @CRLF Run($sAppToRun) $sAppClicked = "" EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $sAppClicked = _GUICtrlListView_GetItemText($hWndListView, _GUICtrlListView_GetSelectedIndices($hWndListView)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFYM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Laymanball Posted September 30, 2011 Author Share Posted September 30, 2011 Melba23 I test your code by double click to App name in the ListView. But, App It no run. Must how do to next. My Sample Script Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2011 Moderators Share Posted September 30, 2011 Laymanball, It worked when I tried it! Change this bit and post the result which will be written in the SciTE console: If $sAppClicked Then ConsoleWrite($sAppClicked & " - " & StringToBinary($sAppClicked) & @CRLF) ;$sAppToRun = $sFiles & "\" & StringTrimRight($sAppClicked, 2) ; <<<<<<<< Remove the trailing @CRLF ;Run($sAppToRun) $sAppClicked = "" EndIf M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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