How to save pictures when using SAVEITEM to new folder - imacros

Using this IMacros code
TAG POS=1 TYPE=IMG ATTR=ID:"pagecontent_imgProduct" CONTENT=EVENT:SAVEITEM
How can i specify other folder for saving images, by default its saving to Imacros/Downloads

Before your line try to use the 'ONDOWNLOAD' command:
ONDOWNLOAD FOLDER=* FILE=* ...

Related

Clicking almost 2 identical urls with imacro

I am working on a imacro script and i am just stuck with it and can't figure out what i am doing wrong.
It is a macro thát visits a certain forum part and it needs to click 2 links.
They are almost identical except for 1 part.
It is used to download attachments.
Code i got at the moment:
TAG POS=1 TYPE=A ATTR=ID:aid* EXTRACT=href
tab open
tab t=2
url goto={{!EXTRACT}}
TAB CLOSE
TAG POS=2 TYPE=A ATTR=ID:aid* EXTRACT=href
tab open
tab t=2
url goto={{!EXTRACT}}
I also tried it like this:
TAG POS=1 TYPE=A ATTR=HREF:*linkhere*/forum.php?mod=attachment&aid=* EXTRACT=href
tab open
tab t=2
url goto={{!EXTRACT}}
SET !EXTRACT NULL
TAB CLOSE
TAG POS=2 TYPE=A ATTR=TXT:*.pdf EXTRACT=HREF
SET link EVAL("'{{!EXTRACT}}'.match(/(http.*)\./)[1];")
URL GOTO={{link}}
but still no luck.
As you see 1 file is a image, but the 2nd file can be a pdf or zip/rar file.
Most of them are pdf tough.
Hopefully can point me in the right direction with this as i got no clue anymore...
Why don't you simply save the files directly?
Do you need to open them in a different tab?
TAG POS=1 TYPE=IMG ATTR=HREF:http://*.jpg CONTENT=EVENT:SAVEITEM
TAG XPATH="/html/body/div[1]/form/div[3]/div/h2/span[2]/a[1]" CONTENT=EVENT:SAVETARGETAS
or something like that depending on what you have there.
I prefer to refer items by XPATH, but that's just me

How can i close popup box when selecting image from folder with imacros

I need tot take picture from folder and upload to website, but how do i close popup box after upload image. Here is my code
URL GOTO=https://www.kijiji.ca/p-post-ad.html?categoryId=168
TAG POS=1 TYPE=BUTTON FORM=ACTION:/p-submit-ad.html ATTR=TXT:Select<SP>Images
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:/p-submit-ad.html ATTR=* CONTENT=D:\images\download.jpg
WAIT SECONDS=1
try this....
URL GOTO=https://www.kijiji.ca/p-post-ad.html?categoryId=168
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:/p-submit-ad.html ATTR=* CONTENT=D:\images\download.jpg
wait seconds=5

iMacros / Select random photo from PC

I need to make iMacros to automatically choose random photo from a folder on my PC. How do I arrange it?
This is the line from iMacros for adding some file manually:
TAG POS=1 TYPE=INPUT:FILE FORM=ID:insta-add-image-form-all ATTR=ID:edit-insta-image-upload CONTENT=/path/to/the/specific/file
Thanks.
For Shugar
Here’s how my script looks like:
asd.iim
VERSION BUILD=8920312 RECORDER=FX
TAB T=1
URL GOTO=https://onlypult.com/dashboard
TAG POS=1 TYPE=A ATTR=TXT:Calendar
TAG POS=1 TYPE=A ATTR=TXT:+
TAG POS=1 TYPE=INPUT:FILE FORM=ID:insta-add-image-form-all ATTR=ID:edit-insta-image-upload CONTENT={{rndFilePath}}
TAG POS=1 TYPE=BUTTON FORM=ID:insta-add-image-form-all ATTR=ID:edit-nextsubmit--2
TAG POS=1 TYPE=BUTTON FORM=ID:insta-add-image-form-all ATTR=ID:edit-nextsubmit--3
TAG POS=1 TYPE=BUTTON FORM=ID:insta-add-image-form-all ATTR=ID:edit-saveimaage
asd.js
SET folderPath /path/to/folder/
SET rndFilePath EVAL("var arrFile = []; var file = Components.classes['#mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); file.initWithPath('{{folderPath}}'); var filesEnum = file.directoryEntries; while (filesEnum.hasMoreElements()) {arrFile.push(filesEnum.getNext().QueryInterface(Components.interfaces.nsILocalFile).path);} arrFile[Math.floor(Math.random()*(arrFile.length))];")
PROMPT {{rndFilePath}}
Both files are in folder /iMacros/Macros.
When it comes to line with CONTENT={{rndFilePath}}, nothing happens.
Normally that line looks like this
TAG POS=1 TYPE=INPUT:FILE FORM=ID:insta-add-image-form-all ATTR=ID:edit-insta-image-upload CONTENT=/path/to/content.jpg
The thing is, I need to click and choose some file because there appears dropdown menu when I click on «upload from PC», I cannot just write copy-paste the path to the file. Is it possible?
If you’re using Firefox, the code below returns the full path to a random file from the folder ‘D:\Temp\img’ (specified with the ‘folderPath’ variable).
SET folderPath D:\\\Temp\\\img
SET rndFilePath EVAL("var arrFile = []; var file = Components.classes['#mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); file.initWithPath('{{folderPath}}'); var filesEnum = file.directoryEntries; while (filesEnum.hasMoreElements()) {arrFile.push(filesEnum.getNext().QueryInterface(Components.interfaces.nsILocalFile).path);} arrFile[Math.floor(Math.random()*(arrFile.length))];")
PROMPT {{rndFilePath}}

Imacros get downloaded image file name in firefox

I am using imacros in firefox and saving some images and I want to be able to store the saved images names in a variable, but it seems that the code at the end of my code below
SET !EXTRACT {{!DOWNLOADED_FILE_NAME}}
PROMPT {{!DOWNLOADED_FILE_NAME}}
does not work in firefox, only in ie, does anyone no how I can save the filename of the image into a variable for latter use in my imacros script in firefox browser, I prefer not to use ie browser if at all possible
thanks
VERSION BUILD=8881205 RECORDER=FX
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 10
SET !TIMEOUT_TAG 0
SET !WAITPAGECOMPLETE YES
SET !EXTRACT_TEST_POPUP NO
TAB T=1
URL GOTO=http://www.somerandomsite.com
TAG POS=5 TYPE=INPUT:SUBMIT ATTR=*
TAG POS=1 TYPE=IMG ATTR=SRC:http://*.jpg
ONDOWNLOAD FOLDER=C:\Users\pb\Pictures\produts FILE=* WAIT=YES
'Download the picture
TAG POS=1 TYPE=IMG ATTR=SRC:http://*.jpg CONTENT=EVENT:SAVEITEM
TAG POS=2 TYPE=DIV ATTR=CLASS:iv_thumb_image&&TXT:
ONDOWNLOAD FOLDER=C:\Users\pb\Pictures\produts FILE=* WAIT=YES
'Download the picture
TAG POS=1 TYPE=IMG ATTR=SRC:http://*.jpg CONTENT=EVENT:SAVEITEM
SET !EXTRACT {{!DOWNLOADED_FILE_NAME}}
PROMPT {{!DOWNLOADED_FILE_NAME}}

use a webbased datafile with SET !DATASOURCE

How can i use a webbased file ie csv file like csv file link with the SET !DATASOURCE command in imacros,the reason is that i want to use the webbased file?
SET !DATASOURCE profile1.csv
SET !DATASOURCE_COLUMNS 4
SET !DATASOURCE_LINE {{!LOOOP}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox1 CONTENT={{!COL0}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox2 CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox3 CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox4 CONTENT={{!COL3}}
This example reads CSV file from Hard Drive placed in Datasource folder. As for webased file the only idea I have right now is if you had something like a sheet in the web browser window. From it iMacros can read the whole table and use those data . But without JS scripting it can't be done easily.
Make an iMacros code that downloads that file from a webserver to your hard drive/datasource folder.