bballjoe12

If double click Tree Item, opens a program. How to do that?

3 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("I'm Too Lazy to Type", 317, 205, 266, 137, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("Options")
$MenuItem4 = GUICtrlCreateMenuItem("Always on Top", $MenuItem2)
GUICtrlSetState(-1, $GUI_CHECKED)
GUISetBkColor(0xC8C8C8)
$TreeView1 = GUICtrlCreateTreeView(10, 12, 297, 161, BitOR($GUI_SS_DEFAULT_TREEVIEW,$WS_BORDER))
$TreeView1_0 = GUICtrlCreateTreeViewItem("CHI", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Hardware", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("Broken desktop/WOW", $TreeView1_1)
$TreeView1_3 = GUICtrlCreateTreeViewItem("Citrix", $TreeView1_0)
$TreeView1_4 = GUICtrlCreateTreeViewItem("Launching errors", $TreeView1_3)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Internet/Websites", $TreeView1_0)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Website workflow", $TreeView1_5)
$TreeView1_7 = GUICtrlCreateTreeViewItem("TRUM", $TreeView1)
$TreeView1_8 = GUICtrlCreateTreeViewItem("Hardware", $TreeView1_7)
$TreeView1_9 = GUICtrlCreateTreeViewItem("Internet/Websites", $TreeView1_7)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

How would I insert a code where if the "Broken desktop/WOW" item is double clicked, then it will open an external program?  Would I use an "If, Then" statement there?

Edited by bballjoe12

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Global $TreeView1

$Form1 = GUICreate("I'm Too Lazy to Type", 317, 205, 266, 137, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("Options")
$MenuItem4 = GUICtrlCreateMenuItem("Always on Top", $MenuItem2)
GUICtrlSetState(-1, $GUI_CHECKED)
GUISetBkColor(0xC8C8C8)
$TreeView1 = GUICtrlCreateTreeView(10, 12, 297, 161, BitOR($GUI_SS_DEFAULT_TREEVIEW,$WS_BORDER))
$TreeView1_0 = GUICtrlCreateTreeViewItem("CHI", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Hardware", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("Broken desktop/WOW", $TreeView1_1)
$TreeView1_3 = GUICtrlCreateTreeViewItem("Citrix", $TreeView1_0)
$TreeView1_4 = GUICtrlCreateTreeViewItem("Launching errors", $TreeView1_3)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Internet/Websites", $TreeView1_0)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Website workflow", $TreeView1_5)
$TreeView1_7 = GUICtrlCreateTreeViewItem("TRUM", $TreeView1)
$TreeView1_8 = GUICtrlCreateTreeViewItem("Hardware", $TreeView1_7)
$TreeView1_9 = GUICtrlCreateTreeViewItem("Internet/Websites", $TreeView1_7)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
 WEnd

 Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
   #forceref $hWnd, $iMsg, $wParam
   Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
   $hWndTreeview = GUICtrlGetHandle($TreeView1)
   $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
   $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
   $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
   $iCode = DllStructGetData($tNMHDR, "Code")
   Switch $hWndFrom
      Case $hWndTreeview
         Switch $iCode
            Case $NM_DBLCLK
               RunSomeApp()
               Return 0
      EndSwitch
   EndSwitch
   Return $GUI_RUNDEFMSG
EndFunc

Func RunSomeApp()
   Local $CtrlID = GUICtrlRead($TreeView1)
   If _GUICtrlTreeView_GetChildCount($TreeView1,$CtrlID) = -1 Then
      MsgBox(0,'Run app',_GUICtrlTreeView_GetText($TreeView1,$CtrlID))
   EndIf
EndFunc

 


When the words fail... music speaks

Share this post


Link to post
Share on other sites

This topic is very similar to the other topic you created, thought you got your answers there.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

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