A downloadable extension

Download NowName your own price

File Dropper

Quick links: documentation · source code
Versions: GameMaker: Studio, GameMaker Studio 2, GM2022+
Platforms: Windows, Windows (YYC) (see this extension for HTML5)

This extension allows the user to drag-and-drop files and directories onto the game window!

Featuring a few functions now! Check out the docs.

Originally made available for free thanks to Follow The Fun (see more).

File Dragger

Quick links: source code
Versions: GM2022+..?
Platforms: Windows, Windows (YYC)

Company for above, this extension allows you to drag files out of the game window.

Featuring a total of 2 (two!) functions:

file_drag_drop(path, ...paths)➜

Starts a drag-and-drop operation for one or more files with the given (absolute!) paths.

Returns whether successful.

Should be called when the primary mouse button is pressed (e.g. mouse_check_button_pressed(mb_left)).

file_drag_drop_array(paths)➜

Like above, but takes an array of paths instead.

I'm providing the GM:S files for file_dragger, but it doesn't seem to work in GM:S for whatever reason. Feel free to figure it out if you know what you're doing.

Made available for free thanks to JamPaktGames

Updated 25 days ago
StatusReleased
CategoryAssets
AuthorYellowAfterlife
TagsGameMaker

Download

Download NowName your own price

Click download now to get access to the following files:

file_dropper (for GMS2.3 and GM2022+).yymps 134 kB
Version 1.1.1
file_dropper (for GMS2.2).yymp 71 kB
Version 1.1.1
file_dropper (for GMS1.4).gmez 60 kB
Version 1.1.1
file_dropper demo (for GMS2.3 and GM2022+).zip 165 kB
Version 1.1.1
file_dropper demo (for GMS1.4).zip 85 kB
Version 1.1.1
file_dragger-for-GMS1.gmez 46 kB
Version 1.0.0
file_dragger-for-GMS2.yymp 12 kB
Version 1.0.0
file_dragger-for-GMS2.3+.yymps 14 kB
Version 1.0.0

Development log

Comments

Log in with itch.io to leave a comment.

Is there a way to force window focus when dragging a file over the game window? This way the game can react to mouse position while holding the file.

It’s a Sunday afternoon and I have electricity this time, so you can even have a more proper solution.

Oh my god. Thank you!

I always get this error when trying to build, even on a blank project:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'path1')    at System.IO.Path.Combine(String path1, String path2)    at GMAssetCompiler.WADSaver`1.WriteExtensions(IList`1 _data, Stream _s, IFF _iff)    at GMAssetCompiler.IFFChunkHandler`1.Save(Stream _stream, IFF _iff)    at GMAssetCompiler.IFF.WriteChunks(Stream _stream, TextWriter _out)    at GMAssetCompiler.WADSaver`1.Save(GMAssets _assets, Stream _stream, List`1 _extraFilenames, Dictionary`2 _extraAttributes)    at GMAssetCompiler.IFFSaver.Save(GMAssets _assets, String _name)    at GMAssetCompiler.Program.CompileProject(GMAssets _file)    at GMAssetCompiler.Program.Reentry(String[] _args)    --- End of inner exception stack trace ---    at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)    at Igor.Program.ExecuteAssetCompiler(String _args)    at Igor.WindowsBuilder.Compile(Boolean _exe)    at Igor.WindowsBuilder.Deploy(Boolean _exe)    at Igor.WindowsBuilder.Run()
(+1)

That’s a GameMaker bug - it corrupts most of my extensions on load now. I recommend rolling back the IDE to 2023.8 for now

(2 edits)

just as a head-up : The extension started not working for me all of a sudden, the function file_dropper_init() returning 0. I have no idea why, it worked fine until now, but now I can’t seem to get it to work on my computer anymore, except very rarely. I didn’t change any of the code, even old itch builds of my game that used to work do not now, so this is probably a change on my computer rather that on gamemaker, but I can’t figure out what change caused that to happen. Sometimes it will in fact work randomly but that’s like once every 20 tries. This is probably not helpful at all to debug but this is all I have :/

EDIT : I fixed it by disabling the option : Start fullscreen and running windo_set_fullscreen(true) at startup instead.

(5 edits) (+1)

Helper script:


///File_Dropper_Async_System_Event()
/*
To use this extension, simply call this once at launch: 
file_dropper_init();
Then, put the following code in an async -> System event
Object -> Click "Add event"
"Asynchronous" (bottom right)
"System event" (last on the list).
*/
// Check to see what kind of event happened
var eventType = ds_map_find_value(async_load,"event_type");
// If a file was dropped over the window
if eventType == "file_drop"
    {
    // This is the absolute path
    var filePath = ds_map_find_value(async_load,"filename");
    
    // Print it 
    show_debug_message(filePath);
    
    // Will return the full path, e.g. "C:\Users\user\Documents\Test.txt"
    // When multiple files are included, this event will be called
    // once per file. 
    }
(+1)

Nice! Very easy to use.