0

I'm developing a Python program that posts files from PC to social media. I wanted to know how could I automatically press enter when someone drops a file in the command window.

I have done something similar with msvcrt and WConio2 but they only work when introducing a single char, not a whole file directory string.

Some graphic context:

(Image 1: Before dropping file, Image 2: After dropping file [where I don't want to have to press enter])

image1

image2

Thank you.

Pochi
  • 35
  • 1
  • 6
  • Does this answer your question? [What's the simplest way of detecting keyboard input in a script from the terminal?](https://stackoverflow.com/questions/13207678/whats-the-simplest-way-of-detecting-keyboard-input-in-a-script-from-the-termina) – Peter Gibson Feb 02 '21 at 23:54
  • Have you already written code such that when you drag and drop a file into the user-interface, the path name appears? If so, then you can probably change what happens. Instead of only printing the file path to the screen, you could print the file path to the screen and go execute some other code as well. Imagine if running a diner/restaurant was like writing computer software. In a well-written computer program, the chef does not know who ordered a hamburger. – Toothpick Anemone Feb 03 '21 at 03:12
  • Your program shouldn't care if the request was made by a human being typing in the path and pressing enter, or if a bot with no GUI at all executed the command, or if a space alien on planet Saturn made the request. Well-written computer programs are like shoe-box shaped machines with input USB ports and output USB ports. We don't know where the input comes from. We don't know where the output cables go. We simply process our inputs, and output our outputs. We send the output to the output cable no matter where it might lead. – Toothpick Anemone Feb 03 '21 at 03:14
  • Your computer program has a problem where the GUI (graphical user interface) is inseparable from the under-the-hood stuff. When a command is executed it should not matter if the "ENTER" key on the keyboard is pressed. Any one small sub-component should have no idea where its input came from. You should not have to press enter on a keyboard to make stuff happen. In less than two lines of code, you should be able to change what event triggers an action. Before, we had, "when the clock strikes 2:00PM, make a sandwich". Afterwards, we have "when it starts raining outside, make a sandwich." – Toothpick Anemone Feb 03 '21 at 03:18
  • You should **NOT** have to write code which presses the enter key on they keyboard to make stuff happen. If keyboard input is the only way to make your machine dance, then you wrote poor quality code. Ideally, with one brush stroke, you can make any event trigger the desired behavior, not simply keyboard events. – Toothpick Anemone Feb 03 '21 at 03:20

0 Answers0