 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 12:07 am Post subject: loop trouble |
|
|
i can run files in the listbox useing %A_LoopFileFullPath% but not with
%A_LoopFileName% and if i'm not mistaking it would be becuse there would be no path with %A_LoopFileName% would there be a way to use
%A_LoopFileName% and still be able to use the run, to open files in the listbox ? _________________ ^sleepy^ |
|
| Back to top |
|
 |
Gre
Joined: 12 Oct 2004 Posts: 77 Location: São Paulo ,Brazil
|
Posted: Mon Nov 22, 2004 12:39 am Post subject: |
|
|
I believe you are using
Loop, some dir\*.ext,...
You can do this variable = some dir ,then use %variable%%A_LoopFileName%
I am also using a listbox as a listview/treeview for my editor.  |
|
| Back to top |
|
 |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 1:19 am Post subject: |
|
|
i'm trying to use a loop to find jpeg but when i use %A_LoopFileName% then click run to open them they will not open now if i use %A_LoopFileFullPath% they will open when click'd and i'm thinking its becuse there is no path with %A_LoopFileName%
buttonfind:
Loop, %c%\*.jpg, 0, 1
{
If A_Index = 1
{
GUIControl, , ListBox1, |%A_LoopFileName%||
}
Else
{
GUIControl, , ListBox1, %A_LoopFileName%
}
}
Return _________________ ^sleepy^ |
|
| Back to top |
|
 |
Gre
Joined: 12 Oct 2004 Posts: 77 Location: São Paulo ,Brazil
|
Posted: Mon Nov 22, 2004 1:26 am Post subject: |
|
|
| Quote: | | Loop, %c%\*.jpg, 0, 1 |
File to run :
%c%\%A_LoopFileName% |
|
| Back to top |
|
 |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 1:38 am Post subject: |
|
|
i'm not sure i follow or i'm just being stupid today hahah
File to run :
%c%\%A_LoopFileName%
OH use that and not
MyListBox:
buttonfind:
Loop, %c%\*.jpg, 0, 1
{
If A_Index = 1
{
GUIControl, , ListBox1, |A_LoopFileName%||
}
Else
{
GUIControl, , ListBox1, %A_LoopFileName%
}
}
Return _________________ ^sleepy^ |
|
| Back to top |
|
 |
Gre
Joined: 12 Oct 2004 Posts: 77 Location: São Paulo ,Brazil
|
Posted: Mon Nov 22, 2004 2:05 am Post subject: |
|
|
What I want to say is:
Gui, Add, ListBox, vMyListBox x... y...
MyListBox value is one of the %A_LoopFileName%
so current folder = %c% then current folder followed by MyListBox value = full file path
file to run:
%c%\%MyListBox% |
|
| Back to top |
|
 |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 2:17 am Post subject: |
|
|
OPPS i got that and its not working lol
this is what i have
MyListBox:
GuiControlGet, MyListBox
if A_GuiControlEvent = DoubleClick
{
Run,%MyListBox%
}
return _________________ ^sleepy^ |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Mon Nov 22, 2004 3:22 am Post subject: |
|
|
If it weren't for the fact that you're gathering files from subfolders (via the recurse=yes parameter), you could just prepend the original folder when running it as Gre said:
%c%\%MyListBox%
But if any files come in from the sub-folders beneath the main folder, their paths would be wrong. One solution is to store only relative paths inside the ListBox. Another solution would be to store the full file paths in an array separate from the ListBox.
First include the AltSubmit option to make it later retrieve the position rather than the name:
Gui, Add, ListBox, AltSubmit vMyListBox x... y...
Then build the array when building the listbox:
| Code: | buttonfind:
Loop, %c%\*.jpg, 0, 1
{
Pic%A_Index% = %A_LoopFileFullPath%
If A_Index = 1
...
} |
Then retrieve the corresponding array element when launching the file: | Code: | MyListBox:
GuiControlGet, MyListBox ; retrieves the position due to AltSubmit
if A_GuiControlEvent = DoubleClick
{
StringTrimLeft, FullPath, Pic%MyListBox%, 0 ; Fetch array item.
Run,%FullPath%
}
return |
Edit: Corrected it to A_LoopFileFullPath
Last edited by Chris on Mon Nov 22, 2004 12:48 pm; edited 1 time in total |
|
| Back to top |
|
 |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 4:00 am Post subject: |
|
|
dose this look about write i can not get it to work when iclick on a file in the listbox
| Code: | Gui, Color, FFFFFF
gui, -caption ; Remove Title Bar
Gui, Add, ListBox, x76 y50 w430 h110 AltSubmit vMyListBox ,
Gui, Add, Button, x6 y50 w60 h20, copy
Gui, Add, Button, x6 y80 w60 h20, move
Gui, Add, Button, x6 y110 w60 h20, del
Gui, Add, Button, x6 y140 w60 h20,find
Gui, Add, Button, x486 y0 w20 h10,[]
Gui, Add, Button, x6 y170 w60 h20,2
Gui, Show, x164 y91 h219 w509, test
Return
buttonfind:
Loop, %c%\*.jpg, 0, 1
{
Pic%A_Index% = %A_LoopFullPath%
If A_Index = 1
{
GUIControl, , ListBox1, |%A_LoopFileName%||
}
Else
{
GUIControl, , ListBox1, %A_LoopFileName%
}
}
Return
MyListBox:
GuiControlGet, MyListBox ; retrieves the position due to AltSubmit
if A_GuiControlEvent = DoubleClick
{
StringTrimLeft, FullPath, Pic%MyListBox%, 0 ; Fetch array item.
Run,%FullPath%
}
return |
_________________ ^sleepy^ |
|
| Back to top |
|
 |
Gre
Joined: 12 Oct 2004 Posts: 77 Location: São Paulo ,Brazil
|
Posted: Mon Nov 22, 2004 6:02 am Post subject: |
|
|
Sorry,I did not read your posts with attention
I did not notice that you are recursing(recursing??is it correct??) subfolders
edit:
Just replace %LoopFullPath% with %A_LoopFileFullPath% and the script will work
edit2:
You forgot the gSub:
Gui, Add, ListBox, x76 y50 w430 h110 AltSubmit vMyListBox ,gMyListBox, |
|
| Back to top |
|
 |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 6:45 am Post subject: |
|
|
ok let me see if i can better exsplane sorry and thank you for helping me out so much i think i was not being clear
what i'm trying to do is not have the file paths in the list box just the jpg name and click to open it
but here is my code it is working but will not run when i click on the file
and yes i'm trying to recursing
| Code: | Gui, Add, ListBox, x76 y50 w430 h110 AltSubmit vMyListBox ,gMyListBox,
buttonfind:
Loop, %c%\*.jpg, 0, 1
{
Pic%A_Index% =%A_LoopFileFullPath%
If A_Index = 1
{
GUIControl, , ListBox1, |%A_LoopFileFullPath%||
}
Else
{
GUIControl, , ListBox1, %A_LoopFileFullPath%
}
}
Return
MyListBox:
GuiControlGet, OutputVar, ,MyListBox ; retrieves the position due to AltSubmit
if A_GuiControlEvent = DoubleClick
{
StringTrimLeft, FullPath, Pic%OutputVar%, 0 ; Fetch array item.
Run,%FullPath%
}
return |
_________________ ^sleepy^ |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Mon Nov 22, 2004 11:13 am Post subject: |
|
|
| Quote: | | what i'm trying to do is not have the file paths in the list box just the jpg name |
Would it make sense to use AHK's SplitPath command ? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Mon Nov 22, 2004 12:54 pm Post subject: |
|
|
| Quote: | | Just replace %LoopFullPath% with %A_LoopFileFullPath% and the script will work | Yes, that was my mistake. Sorry.
| Quote: | You forgot the gSub:
Gui, Add, ListBox, x76 y50 w430 h110 AltSubmit vMyListBox ,gMyListBox, | You shouldn't have a comma before the last item.
| Quote: | | Would it make sense to use AHK's SplitPath command ? | I think sleepyy35 is trying to avoid having the full path inside the ListBox.
The following revised example works on my system when you press the Find button then double-click a listbox item. Note: I removed %c% because it was an empty variable and seemed to serve no purpose. Perhaps you give it a value elsewhere in your script: | Code: | Gui, Add, ListBox, x76 y50 w430 h110 AltSubmit gMyListBox vMyListBox
Gui, Add, Button, x6 y140 w60 h20, Find
Gui, Show
Return
ButtonFind:
Loop, %A_ScriptDir%\*.*, 0, 1
{
Pic%A_Index% = %A_LoopFileFullPath%
If A_Index = 1
GUIControl,, ListBox1, |%A_LoopFileName%||
Else
GUIControl,, ListBox1, %A_LoopFileName%
}
Return
MyListBox:
GuiControlGet, MyListBox ; retrieves the position due to AltSubmit
if A_GuiControlEvent = DoubleClick
{
StringTrimLeft, FullPath, Pic%MyListBox%, 0 ; Fetch array item.
MsgBox %FullPath%
;Run,%FullPath%
}
return |
|
|
| Back to top |
|
 |
Guest
|
Posted: Mon Nov 22, 2004 11:22 pm Post subject: |
|
|
Yes, that is what I want to do works great thank you!
I have to look threw all the code yours and mine and learn where I was going wrong
thanx chris ,Gre,bobo  |
|
| Back to top |
|
 |
sleepyy35
Joined: 22 Jul 2004 Posts: 194 Location: cedar city UT
|
Posted: Mon Nov 22, 2004 11:26 pm Post subject: |
|
|
opps forgot to log in sorry i thought i was auto log in  _________________ ^sleepy^ |
|
| 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
|