"save as" possibl?

Hi,

In win32 app, when i save a screenshot of an object is it possible to ask for the folder where i want to save the picture or i’m stuck with the images/<project name>/screenshot.png? if not can i change the location to the desktop? mac version already sends to desktop.

Regards,

Carlos

You cannot change the default directory location unfortunately.  And defaulting to the desktop is considered “rude” on Windows and the standard is to default to the user’s Documents, Pictures, etc. directories.

Corona currently does not support a “Save As” dialog either.  But another Corona developer has done this by writing a plugin in C/C++.  Have a look here…

   https://forums.coronalabs.com/topic/58266-camera

Also, as a simpler alternative, what you can do instead is after saving the image to the user’s “Pictures” directory, you can show them that directory in Windows Explorer by doing the following in Lua…

if (system.getInfo("platformName") == "Win") then local appName = "Corona Simulator" if (system.getInfo("environment") == "device") then appName = tostring(system.getInfo("appName")) end system.openURL("shell:My Pictures\\" .. appName) end

Just note that the above will only work on Windows for both the Corona Simulator and your Win32 app.  It uses Microsoft’s “shell:” URL scheme to display their Pictures directory in Windows Explorer.

Thanks Joshua.

where can i download the plugin and how to install it? in the link you sent i only read about doing the code for it.

For now the second option (open the explorer) will do great. thanks again  :)

Basically your plugin will be a .dll file (Dynamically Loaded Library). You just have to drop this in the same folder as your main.lua.  If you followed the post, there was a link to a post on native text fields where Josh goes into a lot of details about building plugins. He had this note at the end of that post:

Edit:  Final note.  Your compiled plugin DLL and all of its DLL dependencies (if any) will need to be copied to your app’s root directory, where your *.exe all of Corona’s DLLs are located.

Rob

That guy made his own private Win32 plugin for himself.  It’s not public.  And I’m pretty sure he tailored made it for his own purposes.  You can attempt to ask him for his source code, but up to him if he wants to share it.  Or you can write your own plugin from scratch as he did… and he even shown a brief example on that forum thread, but watch out because that code has unicode issues which I was helping him with.

thanks Rob and Joshua for the expanation. Even if my prime language was C back in the days before WWW even exists…i never programmed in c++ or VB.net, Only pure C on Unix machines. i’ve learned Java also but never dont a real program with it so its same saying i don’t know it only the theory. I then got away from programming for about 20 years…and got back learning Lua from scratch 3 years ago to make some apps. i’m to old to learn another one :wink: i will stick with Lua for a while now.

Regards,

Carlos.

Hey Joshua,

maybe you can help me then - how to write a spell command to open a system.DocumentsDirectory ?

if (system.getInfo("platformName") == "Win) then system.openURL(system.pathForFile(nil, system.DocumentsDirectory)) end

The above will open your “system.DocumentsDirectory” in Windows Explorer.

The native Win32 function that system.openURL() calls is happy to accept URLs and file/directory paths.  That’s why the above works.  Just note that the above won’t work on OS X which only accepts URLs.

Also note that your “system.DocumentsDirectory” is under the user’s hidden Windows AppData directory.  It’s not their “My Documents” directory equivalent.

Tnx!

I have just added it my game - http://steamcommunity.com/app/439920/discussions/0/385428943462944182/

I`ll test how it will work on MacOS later.

The following will work for both OS X and Windows…

local platformName = system.getInfo("platformName") if (platformName == "Win") then system.openURL(system.pathForFile(nil, system.DocumentsDirectory)) elseif (platformName == "Mac OS X") then system.openURL("file://" .. system.pathForFile(nil, system.DocumentsDirectory)) end

You cannot change the default directory location unfortunately.  And defaulting to the desktop is considered “rude” on Windows and the standard is to default to the user’s Documents, Pictures, etc. directories.

Corona currently does not support a “Save As” dialog either.  But another Corona developer has done this by writing a plugin in C/C++.  Have a look here…

   https://forums.coronalabs.com/topic/58266-camera

Also, as a simpler alternative, what you can do instead is after saving the image to the user’s “Pictures” directory, you can show them that directory in Windows Explorer by doing the following in Lua…

if (system.getInfo("platformName") == "Win") then local appName = "Corona Simulator" if (system.getInfo("environment") == "device") then appName = tostring(system.getInfo("appName")) end system.openURL("shell:My Pictures\\" .. appName) end

Just note that the above will only work on Windows for both the Corona Simulator and your Win32 app.  It uses Microsoft’s “shell:” URL scheme to display their Pictures directory in Windows Explorer.

Thanks Joshua.

where can i download the plugin and how to install it? in the link you sent i only read about doing the code for it.

For now the second option (open the explorer) will do great. thanks again  :)

Basically your plugin will be a .dll file (Dynamically Loaded Library). You just have to drop this in the same folder as your main.lua.  If you followed the post, there was a link to a post on native text fields where Josh goes into a lot of details about building plugins. He had this note at the end of that post:

Edit:  Final note.  Your compiled plugin DLL and all of its DLL dependencies (if any) will need to be copied to your app’s root directory, where your *.exe all of Corona’s DLLs are located.

Rob

That guy made his own private Win32 plugin for himself.  It’s not public.  And I’m pretty sure he tailored made it for his own purposes.  You can attempt to ask him for his source code, but up to him if he wants to share it.  Or you can write your own plugin from scratch as he did… and he even shown a brief example on that forum thread, but watch out because that code has unicode issues which I was helping him with.

thanks Rob and Joshua for the expanation. Even if my prime language was C back in the days before WWW even exists…i never programmed in c++ or VB.net, Only pure C on Unix machines. i’ve learned Java also but never dont a real program with it so its same saying i don’t know it only the theory. I then got away from programming for about 20 years…and got back learning Lua from scratch 3 years ago to make some apps. i’m to old to learn another one :wink: i will stick with Lua for a while now.

Regards,

Carlos.

Hey Joshua,

maybe you can help me then - how to write a spell command to open a system.DocumentsDirectory ?

if (system.getInfo("platformName") == "Win) then system.openURL(system.pathForFile(nil, system.DocumentsDirectory)) end

The above will open your “system.DocumentsDirectory” in Windows Explorer.

The native Win32 function that system.openURL() calls is happy to accept URLs and file/directory paths.  That’s why the above works.  Just note that the above won’t work on OS X which only accepts URLs.

Also note that your “system.DocumentsDirectory” is under the user’s hidden Windows AppData directory.  It’s not their “My Documents” directory equivalent.

Tnx!

I have just added it my game - http://steamcommunity.com/app/439920/discussions/0/385428943462944182/

I`ll test how it will work on MacOS later.