January 22, 2020, 12:32:50 PM

Author Topic: Getting File URL MaxGUI  (Read 152 times)

Offline Hardcoal

  • Sr. Member
  • ****
  • Posts: 369
Getting File URL MaxGUI
« on: January 06, 2020, 03:00:30 AM »
Hi,
I told Windows To open my Note Editor when I Press a Text File, But I want My Note Editor To know the URL of the Pressed Text File.
how can i get it?

Thanks
Happy New Year

Offline TomToad

  • Sr. Member
  • ****
  • Posts: 454
Re: Getting File URL MaxGUI
« Reply #1 on: January 06, 2020, 11:37:48 AM »
you should be able to use AppArgs[] to get the file path and name.
Code: [Select]
' appargs.bmx
' print the command line arguments passed to the program at runtime

SuperStrict

Print "Number of arguments = "+AppArgs.length

For Local a:String = EachIn AppArgs
Print a
Next

------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Hardcoal

  • Sr. Member
  • ****
  • Posts: 369
Re: Getting File URL MaxGUI
« Reply #2 on: January 06, 2020, 09:27:30 PM »
This is no good for me because the apparg doesnt work for what I asked..
only if you drag a file onto your app the apparg will return info..

what im trying to do is that when i press a text file when then ill get the info
Happy New Year

Online Derron

  • Hero Member
  • *****
  • Posts: 2673
Re: Getting File URL MaxGUI
« Reply #3 on: January 07, 2020, 08:59:15 AM »
This is for sure in the appargs (if it is to find with default functions).

If you double click on a file in the explorer it will start it according to your setup - something like "myapp.exe thefile.ext".


bye
Ron

Offline fielder

  • Jr. Member
  • **
  • Posts: 84
Re: Getting File URL MaxGUI
« Reply #4 on: January 07, 2020, 09:19:56 AM »
Yep, i'm usign it in a lot of applications.. i take appargs, if there is a (valid) file name on one of these... i use it as a filename. (i have to add my application to the windows list using OPEN WITH on the icon.. and selecting the Blitzmax application one time)

automatically associate your application to the file type can be done ONLY with registry changes, replacing the current association. (this make that in future when you remove your app.. the association will broke... and wil be necessary to select anotehr defualt software to open the specific file-type)

Code: [Select]
name="dummy.txt"
If AppArgs.length=2 name=AppArgs[1]
' do some checks '
Global file:TStream=ReadFile(name)

this make dummy.txt the default choice (for testing porpouses) but if the applications will be associated to ".txt" make the name can be changed to location and name of the file.

Online Derron

  • Hero Member
  • *****
  • Posts: 2673
Re: Getting File URL MaxGUI
« Reply #5 on: January 07, 2020, 09:31:07 AM »
I would at least change
Code: [Select]
If AppArgs.length=2 name=AppArgs[1]to
Code: [Select]
If AppArgs.length>=2 name=AppArgs[1]
bye
Ron

Offline Hardcoal

  • Sr. Member
  • ****
  • Posts: 369
Re: Getting File URL MaxGUI
« Reply #6 on: January 07, 2020, 03:36:10 PM »
Ok thanks .. Ive managed to Get the File url from the second apparg cell.. so it seems to work.
Great Thanks..
I dont understand why first time it didnt..
I probably did something wrong
Happy New Year

Offline fielder

  • Jr. Member
  • **
  • Posts: 84
Re: Getting File URL MaxGUI
« Reply #7 on: January 08, 2020, 08:11:34 AM »

Code: [Select]
If AppArgs.length>=2 name=AppArgs[1]Ron

Right :)