Jump to content

help with lists...


Recommended Posts

I'm new at this.. I figured the very basics but some stuff just leave me stumped, how do i get it so when i click a thing on there it will open/run whatever specified?

#include <GUIConstants.au3>
#NoTrayIcon
Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUISetState(@SW_SHOW)
GuiSetState()

GuiSetState ()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    ;If n.notepad Then
    ;   run("notepad.exe")
    ;EndIf
    ;If m.mspaint Then
    ;   run("mspaint.exe")
    ;EndIf
    ;ect..
        
        EndSelect
        WEnd
Link to comment
Share on other sites

This is a little hard to read, is their an easier way? I'm making an app, and was using not beta, i just wanted to create a list that would open a folder or program.

if you search scripts and scraps, i made a little script to create/modify context menus for any file type. if nothing else, you could check out the code and see what keys are accessed to create the context menus
Link to comment
Share on other sites

if you search scripts and scraps, i made a little script to create/modify context menus for any file type. if nothing else, you could check out the code and see what keys are accessed to create the context menus

:o hi there cameron.. i dont know if were on the same page. I'll rephrase my question.

I have made a list that haves names for example Notepad, if I click Notepad which is in the list, it will run Notepad, and so on, How can I get it to do that? :geek:

Oh and I'm interested in your scripts. can you give me a link.. but for I need help with my ordeel first

Edited by slightly_abnormal
Link to comment
Share on other sites

:o hi there cameron.. i dont know if were on the same page. I'll rephrase my question.

I have made a list that haves names for example Notepad, if I click Notepad which is in the list, it will run Notepad, and so on, How can I get it to do that? :geek:

OH, i was thinking you wanted to right click on a file and see 'notepad' and have it go to notepad or something... the thing you want to do would just be like....

arg. sorry real work came up... there was a similar question like this about a month ago where a user was making a launcher for online games, and you would pick the name of the game and it would run internet explorer blah blah blah... let me see if i can find you the link...

***edit***

found IT

Edited by cameronsdad
Link to comment
Share on other sites

#include <GUIConstants.au3>
#NoTrayIcon
Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$List = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
$Button = GUICtrlCreateButton("Select", 80, 270, 80, 25)
GuiSetState()


While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button
        $Info = GUICtrlRead($List)
    If $Info = "n.notepad" Then
        run("notepad.exe")
    EndIf
    If $Info = "m.mspaint" Then
        run("mspaint.exe")
    EndIf
  ;ect..
        
        EndSelect
        WEnd

8)

want to learn alot quickly???

http://www.autoitscript.com/forum/index.php?showtopic=21048#

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

#include <GUIConstants.au3>
#NoTrayIcon
Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GCCList
            If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
    EndSelect
WEnd

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

#include <GUIConstants.au3>
#NoTrayIcon
Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GCCList
            If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
    EndSelect
WEnd
Thanks guys!!!! :o

SmOke, how can i change it to double click, because if i key for example "n" notepad will popup automatically

Edited by slightly_abnormal
Link to comment
Share on other sites

  • Moderators

#include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2

Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
                Return 0
        EndSwitch
    EndIf
EndFunc
You'll have to edit down below where you see the 'n.notepad', to add your others... you can thank Holger for this option.

Edit:

You'll need beta for this...

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

#include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2

Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
                Return 0
        EndSwitch
    EndIf
EndFunc
You'll have to edit down below where you see the 'n.notepad', to add your others... you can thank Holger for this option.

Edit:

You'll need beta for this...

k, thanks

how do i get the "enter" to function as well? :o

Edited by slightly_abnormal
Link to comment
Share on other sites

you could use part of the script i wrote above with the button and set it as the default for when you press ENTER

thats

GUICtrlSetState()

or

you could use

HotKeySet()

8)

HotKeySet("{ENTER}", "Select")
Func Select()
    GUICtrlRead($list)
EndFunc

GUICtrlSetState()

{ENTER} select

val, how??

Edited by slightly_abnormal
Link to comment
Share on other sites

#include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2

Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
$Button = GUICtrlCreateButton("Select", 80, 270, 80, 25)
GUICtrlSetState( -1, $GUI_DEFBUTTON )
GuiSetState()


While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button
        $Info = GUICtrlRead($GCCList)
    If $Info = "n.notepad" Then
        run("notepad.exe")
    EndIf
    If $Info = "m.mspaint" Then
        run("mspaint.exe")
    EndIf
        
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
                Return 0
        EndSwitch
    EndIf
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Ok, Vals idea of your concept is a bit different than mine... what exactly are you looking for, I was under the impression that you weren't looking for a button to activate? The 'Enter' issue could be solved I'm sure... but to know what YOU want is most important, not just for yourself but future readers of this thread.

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

appreciate the help..

Ok, Vals idea of your concept is a bit different than mine... what exactly are you looking for, I was under the impression that you weren't looking for a button to activate? The 'Enter' issue could be solved I'm sure... but to know what YOU want is most important, not just for yourself but future readers of this thread.

if there's another way to fix the new issue with double click and enter? i'm all ears.. i would prefer to have the button as optional and not dependant, u never know.. also if possible can this be done without using beta?

:o

Link to comment
Share on other sites

  • Moderators

appreciate the help..

if there's another way to fix the new issue with double click and enter? i'm all ears.. i would prefer to have the button as optional and not dependant, u never know.. also if possible can this be done without using beta?

:o

What's wrong with Beta? If that's what you want, there is NO way to do it with double click, you'll need to stick with Valuater's code...

P.S. - Beta is actually more stable than the Release.

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

What's wrong with Beta? If that's what you want, there is NO way to do it with double click, you'll need to stick with Valuater's code...

P.S. - Beta is actually more stable than the Release.

sorry for moving off track.. i kept the last codes that were posted, they are being used in a seperate project right now..

back to business, what about just using mouse to select that part and "enter" would run them?

heres your first code..

#include <GUIConstants.au3>
#NoTrayIcon
Opt ("RunErrorsFatal", 0 )
$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GCCList
            If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
    EndSelect
WEnd

i'm making seperate with the one by val, and right now i'm trying wokring on this issue.. see :o

Edited by slightly_abnormal
Link to comment
Share on other sites

  • Moderators

You still need beta for this (You really should have it anyway), it's rather crude, but effective, I couldn't find any information on the enter button using the WM_COMMAND(s).

#include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2

$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
GUISetIcon("D:\005.ico")
$GCCList = GuiCtrlCreateList("", 20, 70, 200, 200)
GuiCtrlSetData(-1, "n.notepad|b.List|c.Control|d.Here|g.Sample|f.List|h.Control|j.Here|h.here|", "a.menu")
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)


While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
            Sleep(10); Delay not to run multiple copies
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'n.notepad' Then Run('Notepad.exe')
                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
EndFunc

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

Thanks!! one problem though.. I duplicated this fuction for my app, and i'm getting weird side affects.. like if i have focus on bottom or the left one, it opens what i had on the first one, or they just dont work immediatly..

btw my app i'm working is massively huge way over 1thou so i had to slim it down to the core problem.. appreciate the help..

;[code]
#include<GUIconstants.au3>
;////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
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2
;beta

$GCCList = GuiCtrlCreateList("", 20, 70, 160, 120)
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(@SW_SHOW)
GuiSetState()

$GCCList2 = GuiCtrlCreateList("", 180, 70, 190, 120)
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(@SW_SHOW)
GuiSetState()

$GCCList3 = 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(@SW_SHOW)
GuiSetState()


GuiSetState ()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop


;////SNIPPED////
;////SNIPPED//// 
;////SNIPPED////
;////SNIPPED////
;////SNIPPED//// 
;////SNIPPED////

;===========================================
Case $msg = $TabSheet6  
Case $msg = $GCCList
    
    
    
;=============================BETA>         
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList) = 'notepad' Then Run('Notepad.exe')
            Sleep(10); Delay not to run multiple copies
            
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList) = 'mspaint' Then Run('mspaint.exe')
            Sleep(10); Delay not to run multiple copies
            
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList) = 'regedit' Then Run('regedit.exe')
            Sleep(10); Delay not to run multiple copies
;ECT    
            
            
            
;========================           
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList2) = 'notepad' Then Run('Notepad.exe')
            Sleep(10); Delay not to run multiple copies
            
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList2) = 'mspaint' Then Run('mspaint.exe')
            Sleep(10); Delay not to run multiple copies
            
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList2) = 'regedit' Then Run('regedit.exe')
            Sleep(10); Delay not to run multiple copies 
;ECT    
            
            
;=======================            
Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList3) = 'notepad' Then Run('Notepad.exe')
            Sleep(10); Delay not to run multiple copies
            
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList3) = 'mspaint' Then Run('mspaint.exe')
            Sleep(10); Delay not to run multiple copies
            
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
            If GUICtrlRead($GCCList3) = 'regedit' Then Run('regedit.exe')
            Sleep(10); Delay not to run multiple copies         
;ECT  
           
    EndSelect
WEnd

;===================>
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    
;==================>
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'notepad' Then Run('Notepad.exe')
                If GUICtrlRead($GCCList) = 'mspaint' Then Run('mspaint.exe')
                If GUICtrlRead($GCCList) = 'regedit' Then Run('regedit.exe')
;ECT    
                              Return 0
        EndSwitch
    EndIf   
        
        
;=================> 
     If $nID = $GCCList2 Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'notepad' Then Run('Notepad.exe')
                If GUICtrlRead($GCCList) = 'mspaint' Then Run('mspaint.exe')
                If GUICtrlRead($GCCList) = 'regedit' Then Run('regedit.exe')
;ECT    
                               Return 0
        EndSwitch   
    EndIf
    
    
;================>
     If $nID = $GCCList3 Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
                If GUICtrlRead($GCCList) = 'notepad' Then Run('Notepad.exe')
                If GUICtrlRead($GCCList) = 'mspaint' Then Run('mspaint.exe')
                If GUICtrlRead($GCCList) = 'regedit' Then Run('regedit.exe')
;ECT
                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
EndFunc
;=====================END BETA>
Edited by slightly_abnormal
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...