SelectInput: I like to tell it the folder to use?

Hello all,

I‘d like to tell selectInput() which folder and file extension to use:

File file1= new File( sketchPath(”“) + ”*.txt“);

selectInput(”...“, ”...“, file1);

Doesn’t work. It starts with the Desktop Folder instead (and not in sketch path folder).

(Sorry for the wrong „“, my iPhone…)

What do I have to change?

Win 10.

Thank you!


1 Like

Limited research but probly these next links could help:




selectInput ( "Select a file to process:" , "fileSelected" , dataFile( "*.txt" ));

did the trick.

Remaining problem is that the load dialog is not in the foreground in Win 10 but hidden.

Any ideas?


This sounds like a bug worth reporting. Is that behind a PDE sketch window, or is it from an exported application?

1 Like

in Win 10 / processing 3.5.3. /
called from a keyPressed()
no problem

but yes usually thing like
tend to be behind the canvas window GRRR

different example:


// as started from load display image i have a sub dir /data/ with a data\moonwalk.jpg

static final String PICS_EXTS = "extensions=,png,jpg,jpeg,gif,tif,tiff,tga,bmp,wbmp";
File dir;
String[] imagePaths = {};
int imagesFound = 0;
boolean havefile = false;
PImage img;

void filedata() {   // @GoToLoop
  dir = dataFile("");
  if (dir.isDirectory()) {
    imagePaths = listPaths(dir.getPath(), "files", "recursive", PICS_EXTS);
    imagesFound = imagePaths.length;
  println("Found", imagesFound, "image(s)");

void setup() {
  println("use: key [r] for file open dlg\n  or key [0 (...x]) for load from array");

void draw() {
  if ( havefile ) image(img,0,0);  //,width,height

void keyPressed() {
  if ( key == 'r') {
    selectInput("open picture: ", "fileSelected", dataFile(PICS_EXTS));
  if ( key == '0') {
    String thefile = imagePaths[0];
    println("you selected: key ["+key+"] "+thefile);
    img = loadImage(thefile);
    havefile = true;

void fileSelected(final File sel) {
  if (sel != null) {
    String thefile = sel.getPath();
    println("you selected: "+thefile);
    img = loadImage(thefile);
    havefile = true;

1 Like

Thanks a lot everyone!

I have to say, sometimes it works. It seems to store the last directory implicitly. So often it looks like it works but it doesn’t.

It doesn’t really take the directory from the file I give to selectInput(). Seems to be a bug.

This is the core line for me :

selectInput("open picture: ", "fileSelected", dataFile(PICS_EXTS));

I understand this line:

static final String PICS_EXTS = "extensions=,png,jpg,jpeg,gif,tif,tiff,tga,bmp,wbmp";

How would I tell it the folder as well?