 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
vlcek
Joined: 19 Feb 2007 Posts: 338 Location: Czech Republic
|
Posted: Thu Jul 16, 2009 6:04 pm Post subject: problem with run program button |
|
|
Helo.
I have problem with run application button.
I write small utility, which shows all my programs from ini files.
In programs directory are my programs, example calculator and player and ini files player.ini and calculator.ini.
In this ini files are:
name=player
fullpath=programs\player\player.exe
and in calculator.ini is:
name=calculator
fullpath=programs\calculator\calc.exe
But my program can't read fullpath after run application button.
My code:
| Code: |
;
; AutoHotkey Version: 1.x
; Language: Czech, English
; Platform: Win9x/NT
; Author: Pavel Vlček <vlcekp1@gmail.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
gui,show,,startup
sleep 2500
gui,add,tab,,programs|options
gui,tab,programs
Loop, programs\*.ini
{
IniRead, name, %A_LoopFileFullPath%, program, name
programsList = %programslist%%name%||
StringTrimRight, programsList, programsList, 1
}
Gui,Add, dropdownList, vprograms xp+80 yp-3 r5 w250, %programsList%
gui,add,button,gopenprogram,run program
gui,tab,options
gui,add,button,gexit,exit
gui,show,,test program
return
exit:
gui,show,,shutdown screen
sleep 2500
exitapp
return
guiclose:
return
openprogram:
gui,submit,nohide
GuiControl,, ChooseString, programs, %name%
iniread, fullpath, %A_Loopfilename%, program, fullpath
msgbox, 0, info, %fullpath%
;run, %fullpath%
return
|
Can you help?
I want run selected application from dropdownlist. _________________ Thanks. |
|
| Back to top |
|
 |
vlcek
Joined: 19 Feb 2007 Posts: 338 Location: Czech Republic
|
Posted: Thu Jul 16, 2009 6:06 pm Post subject: |
|
|
The messagebox with %fullpath% show one word only (error) _________________ Thanks. |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Thu Jul 16, 2009 8:30 pm Post subject: |
|
|
Looks to me like it could be because you are using %A_LoopFileName% when in fact, you are not in a loop. You may want to find out what is in that variable because I'm assuming it's blank.
There is some other stuff with your code that looks off but I think that may get you something more than the ERROR value
EDIT:
Here are just some pointers I thought of doing, you can do what you want but it makes it a little more readable to use indentation and line breaks and grouping like commands. Just some thoughts in case you want to expand, I don't want to intrude.
| Code: | ;
; AutoHotkey Version: 1.x
; Language: Czech, English
; Platform: Win9x/NT
; Author: Pavel Vlcek <vlcekp1@gmail.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
;Create list of programs
Loop, programs\*.ini
{
IniRead, name, %A_LoopFileFullPath%, program, name
programsList .= name |
}
programsList := SubStr(programsList, 1, (StrLen(programsList) - 1)) ;Remove the trailing | after the list is complete
Gui,add,tab,,programs|options
Gui,tab,programs
Gui,Add, dropdownList, vprograms xp+80 yp-3 r5 w250, %programsList%
Gui,add,button,gopenprogram,run program
Gui,tab,options
Gui,add,button,gexit,exit
gui,show,,test program
Gui,show,,startup ;You usually don't want to show the GUI until it's done loading, this way if you have
;a lot of components the user won't see all of the components being added
return
exit:
gui,show,,shutdown screen
sleep 2500
exitapp
return
;You realize that this means the user can't close using the red X? If you add ExitApp it will allow it to close
;Or you could put GoSub, exit so that it will show your shutdown screen and then exit
guiclose:
return
openprogram:
gui,submit,nohide
GuiControl,, ChooseString, programs, %name%
iniread, fullpath, %A_Loopfilename%, program, fullpath
msgbox, 0, info, %fullpath%
;run, %fullpath%
return |
|
|
| Back to top |
|
 |
vlcek
Joined: 19 Feb 2007 Posts: 338 Location: Czech Republic
|
Posted: Fri Jul 17, 2009 7:27 am Post subject: |
|
|
The code shows only blank dropdownlist.
When I do this:
programsList .= name
all programs are in one line. _________________ Thanks. |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jul 17, 2009 8:10 pm Post subject: |
|
|
Oh, sorry, there should be quotes around the |
Like this: | Code: | | variable .= newVariable "|" |
Just so you know what this does is it adds the contents already on variable. It's the equivelant of doing this: | Code: | | variable = %variable%%newVariable%| |
or this | Code: | | variable := variable newVariable "|" |
You can also use periods in between to give you a better understanding of what is being joined together. The periods are optional though
| Code: | | variable .= newVariable . "|" |
|
|
| Back to top |
|
 |
vlcek
Joined: 19 Feb 2007 Posts: 338 Location: Czech Republic
|
Posted: Sat Jul 18, 2009 8:39 am Post subject: |
|
|
I use this:
programsList .= name "|"
programs are show, but when I select one program and click run program, the message box shows error.
I want show fullpath from selected program.
Why program shows error? _________________ Thanks. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|