AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

parameters problem

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
vlcek



Joined: 19 Feb 2007
Posts: 338
Location: Czech Republic

PostPosted: Wed Aug 26, 2009 2:47 pm    Post subject: parameters problem Reply with quote

Good afternoon.
I want use parameters in my program example open and edit.
This code
Code:

if %0% = 0     ; no parameters have been passed (%0% = num of params passed)
   currentfilename = Untitled
Gosub CreatePad
if %0% <> 0  ;a file has been dropped on the exe and will be passed as a parameter
{
   selectedfilename = %1%     ;read the file that was dropped (1st param)
   gosub FileRead
}
return

createpad:
gui,show,,%currentfilename%

return

filereaD:
gui,show,,you selected %selectedfilename%
return

is good, but problem is when selectedfilename have a space example user want edifile my first text file.txt.
Can you edit this code?
I have some files with spaces and program can't show full file path.
Original code is from ahkpad version 1.6
_________________
Thanks.
Back to top
View user's profile Send private message Visit poster's website
aaffe



Joined: 17 May 2007
Posts: 1002
Location: Germany - Deutschland

PostPosted: Wed Aug 26, 2009 2:54 pm    Post subject: Reply with quote

You could perhaps loop through the parameters:
Code:


if %0% = 0     ; no parameters have been passed (%0% = num of params passed)
   currentfilename = Untitled
Gosub CreatePad
if %0% <> 0  ;a file has been dropped on the exe and will be passed as a parameter
{
   Loop %0%
    selectedfilename .=%A_INDEX%     ;read the file that was dropped (1st param)
   gosub FileRead
}
return

createpad:
gui,show,,%selectedfilename%

return

filereaD:
gui,show,,selected file %selectedfilename%
return
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 1002
Location: Germany - Deutschland

PostPosted: Wed Aug 26, 2009 2:57 pm    Post subject: Reply with quote

Or you run your parameters within "":
Run,yourprogram.exe "my file.txt"
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Wed Aug 26, 2009 3:14 pm    Post subject: Reply with quote

it's normal to require the user to put the input file in quotes.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
vlcek



Joined: 19 Feb 2007
Posts: 338
Location: Czech Republic

PostPosted: Wed Aug 26, 2009 3:39 pm    Post subject: Reply with quote

Good work your tips are very good.
Can I set my program as default for txt files?
example
menu,options,add,associate with txt files,asociatewithtxt
asociatewithtxt
;Here will function for set an association
Msgbox, 64, info, The txt files will open in this program now.
return
Can I do this?
_________________
Thanks.
Back to top
View user's profile Send private message Visit poster's website
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Wed Aug 26, 2009 3:51 pm    Post subject: Reply with quote

yes, but you need to research which registry key is needed.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group