Save file on custom name

How could files saved on custom names? Chrome downloads them automatically on default filename.

If you have set the option in your Chrome browser “Ask where to save each file before downloading” to YES then you can do that.
When you click on DOWNLOAD new WINDOWS EXPLORER window will appear.
If you watch closely you will notice that your FILE NAME is colored in blue witch means if you type you will be changing file name or you could type path and file name (C:\myfolder\myNewFileName).
To type your file name you will need to import ROBOT java class into your script.

import java.awt.Robot as Robot

import java.awt.event.InputEvent as InputEvent

import java.awt.event.KeyEvent as KeyEvent

Now you can simulate keys on your keyboard and you can type any name you want.
After you are finished with typing just simulate ENTER key and it will save your file.

This is how i typed CTRL + S

Robot rb = new Robot()
rb.keyPress(KeyEvent.VK_CONTROL)
rb.keyPress(KeyEvent.VK_C)

rb.keyRelease(KeyEvent.VK_C)
rb.keyRelease(KeyEvent.VK_CONTROL)

And finally ENTER key

rb.keyPress(KeyEvent.VK_ENTER)

rb.keyRelease(KeyEvent.VK_ENTER)

2 Likes