AutoHotkey Community

It is currently May 27th, 2012, 10:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: loop trouble
PostPosted: November 22nd, 2004, 1:07 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
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^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 1:39 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 2:19 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
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% 8)

buttonfind:
Loop, %c%\*.jpg, 0, 1
{
If A_Index = 1
{
GUIControl, , ListBox1, |%A_LoopFileName%||
}
Else
{
GUIControl, , ListBox1, %A_LoopFileName%
}
}
Return

_________________
^sleepy^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 2:26 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
Quote:
Loop, %c%\*.jpg, 0, 1

File to run :
%c%\%A_LoopFileName%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 2:38 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
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^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 3:05 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
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%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 3:17 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
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^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 4:22 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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 November 22nd, 2004, 1:48 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 5:00 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
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^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 7:02 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
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,


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 7:45 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
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^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 12:13 pm 
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 ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2004, 1:54 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2004, 12:22 am 
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 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2004, 12:26 am 
Offline

Joined: July 22nd, 2004, 6:33 am
Posts: 193
Location: cedar city UT
opps forgot to log in sorry 8) i thought i was auto log in :)

_________________
^sleepy^


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, HotkeyStick and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group