Jump to content

Listbox items - Button execution


Ejaz
 Share

Recommended Posts

Hi,

Can anybody tell me how to create listbox of programs i.e. ".exe" files and when pressing result in its execution.

Regards,

Ejaz

$Lb_1 = GUICtrlCreateList("", 10, 10, 100, 100)

GUICtrlSetData($Lb_1,"C:\App1.exe|C:\App2.exe|C:\App3.exe")

If GUIGetMsg() = $Lb_1 Then ShellExecute(GuiCtrlRead($Lb_1))

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

$Lb_1 = GUICtrlCreateList("", 10, 10, 100, 100)

GUICtrlSetData($Lb_1,"C:\App1.exe|C:\App2.exe|C:\App3.exe")

If GUIGetMsg() = $Lb_1 Then ShellExecute(GuiCtrlRead($Lb_1))

Thank you for your reply.

I have this as follows

GuiCtrlCreateList("", 5, 190, 100, 90)

GuiCtrlSetData(-1, "C:\App1.exe|C:\App2.exe|C:\App2.exe")

GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

What I want to do is that when the item is selected in the list, and the button is pressed, it execute application via ShellExecute.

Also is it possible that, instead of showing the full path of application "C:\App1.exe" can we show only "App1" which map to "C:\App1.exe".

One more thing, instead of the file path, is it possible that the listbox item points to application in the folder where the script reside? I actually want this, this will look nice interface.

I will appreciate your help.

Regards,

Ejaz

Link to comment
Share on other sites

Thank you for your reply.

I have this as follows

GuiCtrlCreateList("", 5, 190, 100, 90)

GuiCtrlSetData(-1, "C:\App1.exe|C:\App2.exe|C:\App2.exe")

GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

What I want to do is that when the item is selected in the list, and the button is pressed, it execute application via ShellExecute.

Also is it possible that, instead of showing the full path of application "C:\App1.exe" can we show only "App1" which map to "C:\App1.exe".

One more thing, instead of the file path, is it possible that the listbox item points to application in the folder where the script reside? I actually want this, this will look nice interface.

I will appreciate your help.

Regards,

Ejaz

$List = GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData($List, "App1|App2|App")
$Btn = GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)
While 1
   Switch GUIGetMsg()
      Case -3
         Exit
      Case $Btn
         Switch GUICtrlRead($List)
                  Case "App1"
                     $App = "C:\App1.exe"
                  Case "App2"
                     $App = "C:\my path\app2.exe"
                  Case "App3"
                     $App = @ProgramFilesDir & "\Program name folder\app3.exe"
         EndSwitch
         ShellExecute($App)
   EndSwitch
Wend
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

$List = GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData($List, "App1|App2|App")
$Btn = GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)
While 1
   Switch GUIGetMsg()
      Case -3
         Exit
      Case $Btn
         Switch GUICtrlRead($List)
                  Case "App1"
                     $App = "C:\App1.exe"
                  Case "App2"
                     $App = "C:\my path\app2.exe"
                  Case "App3"
                     $App = @ProgramFilesDir & "\Program name folder\app3.exe"
         EndSwitch
         ShellExecute($App)
   EndSwitch
Wend

This is amazing help from you :mellow: so quick.

Now i have a little proble, the application is not running, following is complete code

#include <GuiConstantsEx.au3>

#include <AVIConstants.au3>

#include <TreeViewConstants.au3>

GuiCreate("Test1", 600, 600)

$List = GuiCtrlCreateList("", 5, 190, 100, 90)

GuiCtrlSetData($List, "App1|App2|App")

$Btn = GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

While 1

Switch GUIGetMsg()

Case -3

Exit

Case $Btn

Switch GUICtrlRead($List)

Case "App1"

$App = "C:\App1.exe"

Case "App2"

$App = "C:\my path\app2.exe"

Case "App3"

$App = @ProgramFilesDir & "\Program name folder\app3.exe"

EndSwitch

ShellExecute($App)

EndSwitch

Wend

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE

WEnd

Link to comment
Share on other sites

This is amazing help from you :mellow: so quick.

Now i have a little proble, the application is not running, following is complete code

#include <GuiConstantsEx.au3>

#include <AVIConstants.au3>

#include <TreeViewConstants.au3>

GuiCreate("Test1", 600, 600)

$List = GuiCtrlCreateList("", 5, 190, 100, 90)

GuiCtrlSetData($List, "App1|App2|App")

$Btn = GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

While 1

Switch GUIGetMsg()

Case -3

Exit

Case $Btn

Switch GUICtrlRead($List)

Case "App1"

$App = "C:\App1.exe"

Case "App2"

$App = "C:\my path\app2.exe"

Case "App3"

$App = @ProgramFilesDir & "\Program name folder\app3.exe"

EndSwitch

ShellExecute($App)

EndSwitch

Wend

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE

WEnd

It's the 2 While loops.

#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>

GuiCreate("Test1", 600, 600)

$List = GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData($List, "App1|App2|App")
$Btn = GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Btn
Switch GUICtrlRead($List)
Case "App1"
$App = "C:\App1.exe"
Case "App2"
$App = "C:\my path\app2.exe"
Case "App3"
$App = @ProgramFilesDir & "\Program name folder\app3.exe"
EndSwitch
ShellExecute($App)
EndSwitch
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

It's the 2 While loops.

#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>

GuiCreate("Test1", 600, 600)

$List = GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData($List, "App1|App2|App")
$Btn = GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Btn
Switch GUICtrlRead($List)
Case "App1"
$App = "C:\App1.exe"
Case "App2"
$App = "C:\my path\app2.exe"
Case "App3"
$App = @ProgramFilesDir & "\Program name folder\app3.exe"
EndSwitch
ShellExecute($App)
EndSwitch
Wend

I already tried that, but the result is the same. When trying to open, interface never comes up, but i can see icon in the taskbar. Any help

Regards,

M. A. Ijaz

Link to comment
Share on other sites

You need the

GUISetState()

statement before the While Loop begins.

I already tried that, but the result is the same. When trying to open, interface never comes up, but i can see icon in the taskbar. Any help

Regards,

M. A. Ijaz

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