Jump to content

help with lists...


Recommended Posts

  • Moderators

Sorry, I was asleep, but to be honest... it's all screwed up. Take a look at what I did and study very carefully:

#include<GUIconstants.au3>
;===BETA
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2
Dim $GCCList[4]
;////SNIPPED////
$Form2 = GUICreate("PROGRAMS", 390, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(8, 8, 375, 280)
;////SNIPPED////
;////SNIPPED////
$TabSheet6 = GUICtrlCreateTabItem("PROGRAMS")
;beta
$GCCList[1] = GUICtrlCreateList("", 20, 70, 160, 120)
GUICtrlSetData(-1, "_|Notepad|Regedit|Control|MSpaint|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$GCCList[2] = GUICtrlCreateList("", 180, 70, 190, 120)
GUICtrlSetData(-1, "_|Notepad|Regedit|Control|MSpaint|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$GCCList[3] = GUICtrlCreateList("", 20, 180, 160, 115)
GUICtrlSetData(-1, "_|Notepad|Regedit|Control|MSpaint|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
;////SNIPPED////
;////SNIPPED////
;////SNIPPED////
;////SNIPPED////
;////SNIPPED////
;////SNIPPED////
;=============================BETA>
    EndSelect
    For $i = 1 To 3
;ToolTip(ControlGetFocus($Form2)) << Use this to find out what the Control Ref ID is if you add more list boxes or controls
        If _IsPressed ('0D') And ControlGetFocus($Form2) = 'ListBox' & $i Then; Every list box is not ListBox"1"
            If StringInStr(GUICtrlRead($GCCList[$i]), 'notepad') Then Run('Notepad.exe'); you have things capitalized up top, and they were lowercased here
            If StringInStr(GUICtrlRead($GCCList[$i]), 'mspaint') Then Run('mspaint.exe'); so I replaced "=" with a StringInStrin() not case sensitive command
            If StringInStr(GUICtrlRead($GCCList[$i]), 'regedit') Then Run('regedit.exe')
            Sleep(100); Delay not to run multiple copies
;ECT
;========================
        EndIf
    Next
WEnd

;===================>
Func MY_WM_COMMAND ($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAND($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
;==================>
    For $x = 1 To 3; Replace 3 with however many list boxes you have
        If $nID = $GCCList[$x] Then
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    If GUICtrlRead($GCCList[$x]) = 'notepad' Then Run('Notepad.exe')
                    If GUICtrlRead($GCCList[$x]) = 'mspaint' Then Run('mspaint.exe')
                    If GUICtrlRead($GCCList[$x]) = 'regedit' Then Run('regedit.exe')
    ;ECT
                    Return 0
            EndSwitch
        EndIf
    Next
EndFunc;==>MY_WM_COMMAND

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
EndFunc;==>_IsPressed
;=====================END BETA>

Edit:

Edited a comment.

Edit2:

You only need one GUISetState() before your While 1 / Wend Loop - not 6 or 7, and one GUIRegisterMsg().

Edited 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

  • Moderators

and i thought i was a "Glutton" for punishment.... :o

lol

8)

Hey... I didn't write his whole program for him (cuz he don't want to show it :geek:) but as bored as I've been, I'm sure I would have!! I just happened to know how to do the double clicks in the list boxes... and poof instant sucker.

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

  • Moderators

Gratitude is over whelming :o

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

  • Moderators

Truly overwhelming :o

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

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...