Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Open app with a file (file viewer)

Author
Message
jakubkwiatkowski
4
Years of Service
User Offline
Joined: 10th Mar 2017
Location:
Posted: 10th Jun 2021 11:03
Hi,
I was wondering is it possible to for example create an image viewer, where you can choose on windows "open file with..." and open an image with my viewer.
how to get the path in code? and is it even possible?

ps: I'm using tier 1 agk classic
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 10th Jun 2021 13:30
Yes
the built in file handling commands https://www.appgamekit.com/documentation/Reference/File.htm
the built in image handling commands https://www.appgamekit.com/documentation/Reference/Image.htm

and if your still after more file handling commands https://forum.thegamecreators.com/thread/219478

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
jakubkwiatkowski
4
Years of Service
User Offline
Joined: 10th Mar 2017
Location:
Posted: 10th Jun 2021 15:12
Thank you. But I didn't found any function that would return file path string from "open file with" command. Maybe I'm missing something.
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Jun 2021 15:37 Edited at: 10th Jun 2021 15:44
using FileExplore as suggested, see: FileExplore.GetCL() - (aka, "GetCommandLine" arguments )

when the image is sent to your App via "Open with", that command will return the absolute path of the image, among other things, separated by pipes "|".

1) Parse the string returned by GetCL (see Token commands), 2) find the path, 3) load the image/sprite

i have similar on another machine but i stuck it in the "Send To" queue vs "Open With".
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
jakubkwiatkowski
4
Years of Service
User Offline
Joined: 10th Mar 2017
Location:
Posted: 10th Jun 2021 16:36
Thank you, it works
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Jun 2021 17:01 Edited at: 10th Jun 2021 17:02
care to share the code? i meant to do an image viewer myself. the other project handles txt files/is more convoluted.
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
jakubkwiatkowski
4
Years of Service
User Offline
Joined: 10th Mar 2017
Location:
Posted: 10th Jun 2021 18:10
sure, I'll post it when it's done
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 10th Jun 2021 20:36 Edited at: 10th Jun 2021 20:39
It sure is allot easier with file explorer as it makes allot of things easier but not impossible without
for example

in the above snippet the ret$ holds the full path of the file it just also includes the file itself so its a matter of just removing whats not needed from the right of the string
ps ret$ may need to be global or passed by reference to use the code above

for example


it could also be done much more efficiently with https://www.appgamekit.com/documentation/Reference/Core/GetStringToken.htm

As much as i love the use of plugins i refrain from them when i dont have to use them but there are some great ones around and madbit certainly has produced some great plugins
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Jun 2021 20:45 Edited at: 10th Jun 2021 20:46
@fubarpk, how are you getting the path wtihout a dll? the parsing is raltively easy after that.
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 10th Jun 2021 20:51
from memory it was just a matter of the above and then loadImage("raw:"+ret$+img)
let me make a test proggy or find one of ,one of my examples i used that in, ive since replaced the code with file explorer just because it was cleaner and already was using Nuklear
so seemed no point avoiding dlls
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 10th Jun 2021 21:02 Edited at: 10th Jun 2021 21:10
the bare bones placement editor on this thread https://forum.thegamecreators.com/thread/222027?page=3 used that approach
a bit of string handling but yes doable not very clean code as such

certainly allot cleaner with madbits fileexplorer a snippet example from krazy grandprix editor
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Jun 2021 21:12 Edited at: 10th Jun 2021 21:16
i'm only seeing selecting/choosing a file in your code. that's not the issue.

we want to right-click on an image in any folder (via windows native), and use Open With (an AppGameKit app) to view it.

OP wrote: "create an image viewer, where you can choose on windows "open file with..." and open an image with my viewer."


somewhere i have a proggy that i wrote that would load .txt files this way. up to 10 at a time, i believe (i think that was a limit madbit set).
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 10th Jun 2021 21:28
Apologies i misunderstood

I understand we have this command RunApp( szFilename, szParameters ) so the parameters of an app should be able to be read
but no idea how as they would have to be passed from windows when you chose open with ide have to do tests on that myself
I always thought that was more of a tier2 thing in the past.
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
jakubkwiatkowski
4
Years of Service
User Offline
Joined: 10th Mar 2017
Location:
Posted: 10th Jun 2021 21:43 Edited at: 10th Jun 2021 22:49
I've managed to do it with the GetCL() function



this code will print the path of the file you "open with" or you can even drag a file on an exe
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Jun 2021 00:30 Edited at: 11th Jun 2021 00:40
weird. are you loading the image at all? im getting an error trying to load the image with what you have (it shows the correct path in the error...).
this:

...will send it to the browser but won't load it as a sprite.

i tried multiple variations of directory settings (AGK & FileExplore), even tried reading it byte by byte.

edit: not the browser, to the Photos app (default image viewer) which, to me, says its just launching the file and letting windows decide how to open it. but, it obviously knows where the file it but can't load it as an image or otherwise (will launch just about any fiietype).
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 11th Jun 2021 02:56
@Virtualnomad have you tried string SimplifyPath( szPath ) it may not be the issue but a command i have learnt helps with compatability
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
MadBit
Valued Member
Gold Codemaster
11
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Jun 2021 04:56 Edited at: 11th Jun 2021 05:03
I have been asked to provide assistance here.
As I understand it, you want to open and display the image by dragging an image file onto the AppGameKit executable app.
Is that correct?

If it is, then I have taken the code from 'jakubkwiatkowski' as a basis. Didn't miss much more to reach the goal.

I hope this helps.



EDIT:
@Virtual Nomad
Your code works for me too.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Jun 2021 05:52 Edited at: 12th Jun 2021 02:31
Quote: "Your code works for me too."

but, it doesn't work.

we're trying to open an image via the Open With windows dialogue.

the app has the path but LoadSprite "can't find" it.

using your code:
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
MadBit
Valued Member
Gold Codemaster
11
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Jun 2021 06:23
I have tested it by dragging the image to the exe.
The way you do it does not work because the path is in quotes ' " '.
Remove these then it should work.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
fubarpk
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 11th Jun 2021 06:54 Edited at: 11th Jun 2021 06:55
I tested what madbit suggested and got it working like this by right clicking an image the opening the browser failed for me with classic
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Jun 2021 08:25 Edited at: 11th Jun 2021 08:43
ok this was driving me crazy. i tried it with and without the quotes but i tested it with Open With and Send To (preference. saves a step).

using Open With and the CL contains Quotes. Send To does not. So, it was failing 1/2 the time and i couldn't see why. (If i would have paid attention, i would have noticed that the errors were different.. "couldn't find" vs "couldn't load").

meanwhile, this accounts for either one:

what it doesn't do is account for more than 1 image at a time which i'll save for another day...

thanks, all!
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
PartTimeCoder
AGK Tool Maker
6
Years of Service
Recently Online
Joined: 9th Mar 2015
Location: Suffolk UK
Posted: 11th Jun 2021 20:05 Edited at: 11th Jun 2021 20:08
I built a plugin to handle this for one of my many editors, it handles cmd, open with, drop on exe and drop on window both with multiple file support.

this small example will load images from CL or DnD

Attachments

Login to view attachments

Login to post a reply

Server time is: 2021-06-24 20:15:09
Your offset time is: 2021-06-24 20:15:09