Need to position in the field that has the focus

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
imacroNewBie96
Posts: 4
Joined: Thu Feb 25, 2016 7:49 pm

Need to position in the field that has the focus

Post by imacroNewBie96 » Thu Feb 25, 2016 8:09 pm

Hi all,

I have searched a lot, but did not found or understand how this works.

I want to paste my input starting in the actual field that is active. not just in the first field. My script does exactly what I want, but starting with the first field on the screen.

I do not use goto URL, but the actual HTML-Site.

Any hint would be great

Newbie96
Last edited by imacroNewBie96 on Sun Mar 06, 2016 6:30 pm, edited 1 time in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Need to position in the field that has the focus

Post by chivracq » Thu Feb 25, 2016 8:50 pm

imacroNewBie96 wrote:Hi all,

I have searched a lot, but did not found or understand how this works.

I want to paste my input starting in the actual field that is active. not just in the first field. My script does exactly what I want, but starting eith thre first field on the screen.

I do not use goto URL, but the actual HTML-Site.

Any hint would be great

Newbie96
Hum..., "I have searched a lot...', Yep, sounds promising for (Advanced) Users on the Forum willing to help you, pity you didn't find the Forum Rules for Required Tech Info to include in your OP..., at least for me for to Reply...
=> CIM...! :mrgreen: for me to read... Read my Sig... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
imacroNewBie96
Posts: 4
Joined: Thu Feb 25, 2016 7:49 pm

Re: Need to position in the field that has the focus

Post by imacroNewBie96 » Tue Mar 01, 2016 3:35 pm

Yes I read the rules, but thought that knowing on which field the focus is does not need this much CI. Did hope I need just an undocumented TAG parameter. OK then:

- Firefox ESR 38.5.2
- iMacros for Firefox 8.9.6
- Windows 7

Hope this information is sufficient to get your hints. Thanks, NewBie96
imacroNewBie96
Posts: 4
Joined: Thu Feb 25, 2016 7:49 pm

Re: Need to position in the field that has the focus

Post by imacroNewBie96 » Tue Mar 01, 2016 3:48 pm

imacroNewBie96 wrote:Yes I read the rules, but thought that knowing on which field the focus is does not need this much CI. Did hope I need just an undocumented TAG parameter. OK then:

- Firefox ESR 38.5.2
- iMacros for Firefox 8.9.6
- Windows 7

Hope this information is sufficient to get your hints. Thanks, NewBie96
I cannot post the URL as it is internal. But you can think of a table of fields and I want to paste information e.g. in the third line row 3,4,5 and 6. This is a clipboard paste captured out of the same table residing in Excel. Splitting up into 4 fields is done. Missing is only the positioning. For this I hope I can just use placing the focus in the starting field, before I start the imacro.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Need to position in the field that has the focus

Post by chivracq » Wed Mar 02, 2016 1:01 am

imacroNewBie96 wrote:Yes I read the rules, but thought that knowing on which field the focus is does not need this much CI. Did hope I need just an undocumented TAG parameter. OK then:

Code: Select all

- Firefox  ESR 38.5.2
- iMacros for Firefox 8.9.6
- Windows 7
Hope this information is sufficient to get your hints. Thanks, NewBie96
OK, we finally have your FCI, Required Info like stated in the Forum Rules, even if indeed not always everything is needed, but many Commands are not implemented for all Browsers, or get broken in some Version for iMacros or the Browser, and 8 out of 10 times I end up wasting my time because of missing Info from FCI while this should always be mentioned...
So now, I only read (and certainly answer) Threads where FCI is mentioned..., period...!

=> So, I read your OP, but hum, I don't understand your "... but starting eith thre first field on the screen.", especially the "eith thre first" part... => "eight three first"...? Doesn't really makes sense to me... :?

Your FCI is btw interesting for me because sbd asked me a few days ago which iMacros for FF Version to install on FF38, and I said that I thought that v8.9.6 (+v8.9.4) should probably work on FF38, but I wasn't completely sure as I'm already at FF41-42-43-44 on different Machines...

I don't know of any "Undocumented" TAG Parameter, so we'll have to do with the "Documented" ones that I know...

If you want a specific Field on your Page to have the Focus, you can use the Standard TAG Mode to tag it (and eventually Relative Positioning with Wildcards for some kind of "Navigation") or the EVENT Mode with a 'CLICK' on that Field and then some EVENT Mode Statements with Keyboard Tab/Arrow + Ctrl^p for a Paste where the Focus will have landed.
But both cases are Workarounds when nothing else works and they are not the normal way to use iMacros which uses the HTML Structure of a Page to identify exactly and directly which Element on that Page needs to receive which Action (Click, Extract, Fill, Mouseover, etc...), so I'm not sure at all this is the correct Approach...
imacroNewBie96 wrote:I cannot post the URL as it is internal. But you can think of a table of fields and I want to paste information e.g. in the third line row 3,4,5 and 6. This is a clipboard paste captured out of the same table residing in Excel. Splitting up into 4 fields is done. Missing is only the positioning. For this I hope I can just use placing the focus in the starting field, before I start the imacro.
Hum, same Reaction like above, yep, you can use both ways I mentioned, but there will probably be some more reliable way to identify your Cell, either directly by some Attribute(s) or using Relative Positioning (only available for the TAG Mode).
If you need to use Ctrl^p in the EVENT Mode after some kind of Relative Navigation with Tab or Arrows and don't know exactly where you've landed, search my Posts on "EVENT Mode Modifiers" for the Syntax and Examples, as... oops!, it is not Documented...! (Hum, you were a bit right after all...! :oops: )

And even if your Page/Site is behind L&P, you can always attach a (zipped, Max 256Kb) HTML Saveas of your Page if you don't come out by yourself and I'm pretty sure I will find a (better) Solution (than the one you seem to be heading to)... :cry:
Good luck anyway... And post your Results / Final Script...

(And next time you open a Thread, I won't even react if you don't mention your FCI directly...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
imacroNewBie96
Posts: 4
Joined: Thu Feb 25, 2016 7:49 pm

Re: Need to position in the field that has the focus

Post by imacroNewBie96 » Sun Mar 06, 2016 7:32 pm

chivracq wrote: => So, I read your OP, but hum, I don't understand your "... but starting eith thre first field on the screen.", especially the "eith thre first" part... => "eight three first"...? Doesn't really makes sense to me... :?
Sorry. mistyping. Correct is: "works correctly with the first field"
chivracq wrote: ... so I'm not sure at all this is the correct Approach...
That's what I thought myself already, bu tI found nothing better yet. Everything else works fine in imacros and I did hope the rest could also be built in imacros. That relying on HTML structure is the problem I think, as i do not know where the focus is. So I even cannot search the structure. The focus could be in any field the user has decided by clicking in that one. I want imacros to find where the users has clicked *before* the macro starts. I already thought of typing a nonsense input-text like "ABCZYX" in the field I want to use as starting point and then start the imacro with first statement to position on that string ... So if you have an idea what could help me better to do a copy&paste but with some modifications (like splitting the text, tabbing to the next field)-> your idea would be much appreciated. I attach my actual macro to show what I mean with this modifications:

Code: Select all

	
var myMacro, myvar, myname;
var data;
	
// get CLIPBOARD 
myMacro ="CODE:";
myMacro +="Set !EXTRACT {{!CLIPBOARD}}"+"\n";
iimPlay(myMacro);
data = iimGetLastExtract();
var cell;

// Split Clipboard as it is from Excel and includes many fields
var cells =data.split("\t");
var cell =cells[0];

// paste Clipboard-fields into HTML fields
myMacro ="CODE:";
myMacro +="SET !EXTRACT_TEST_POPUP YES "+"\n";

//  --------------------------------------------------------
//  THIS ONE SHOULD POSITION ON THE FIELD WHERE THE ACTUAL FOCUS IS, BUT
//  to make it even work I positioned just on the first field in the HTML
myMacro +="TAG POS=1 TYPE=INPUT:TEXT FORM=* ATTR=NAME:* "+"\n";
//  --------------------------------------------------------

// Starting here the fields gets posted
for(var x  in cells) {
    cell =cells[x];
    myMacro +="TAG POS=R1 TYPE=INPUT:TEXT FORM=* ATTR=NAME:* CONTENT="+cell+" "+"\
}

iimPlay(myMacro)
chivracq wrote: (And next time you open a Thread, I won't even react if you don't mention your FCI directly...)
You can be sure, I will include my FCI right at the beginning next time :-)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Need to position in the field that has the focus

Post by chivracq » Mon Mar 07, 2016 11:03 am

imacroNewBie96 wrote:
chivracq wrote: => So, I read your OP, but hum, I don't understand your "... but starting eith thre first field on the screen.", especially the "eith thre first" part... => "eight three first"...? Doesn't really makes sense to me... :?
Sorry. mistyping. Correct is: "works correctly with the first field"
chivracq wrote: ... so I'm not sure at all this is the correct Approach...
That's what I thought myself already, bu tI found nothing better yet. Everything else works fine in imacros and I did hope the rest could also be built in imacros. That relying on HTML structure is the problem I think, as i do not know where the focus is. So I even cannot search the structure. The focus could be in any field the user has decided by clicking in that one. I want imacros to find where the users has clicked *before* the macro starts. I already thought of typing a nonsense input-text like "ABCZYX" in the field I want to use as starting point and then start the imacro with first statement to position on that string ... So if you have an idea what could help me better to do a copy&paste but with some modifications (like splitting the text, tabbing to the next field)-> your idea would be much appreciated. I attach my actual macro to show what I mean with this modifications:

Code: Select all

	
var myMacro, myvar, myname;
var data;
	
// get CLIPBOARD 
myMacro ="CODE:";
myMacro +="Set !EXTRACT {{!CLIPBOARD}}"+"\n";
iimPlay(myMacro);
data = iimGetLastExtract();
var cell;

// Split Clipboard as it is from Excel and includes many fields
var cells =data.split("\t");
var cell =cells[0];

// paste Clipboard-fields into HTML fields
myMacro ="CODE:";
myMacro +="SET !EXTRACT_TEST_POPUP YES "+"\n";

//  --------------------------------------------------------
//  THIS ONE SHOULD POSITION ON THE FIELD WHERE THE ACTUAL FOCUS IS, BUT
//  to make it even work I positioned just on the first field in the HTML
myMacro +="TAG POS=1 TYPE=INPUT:TEXT FORM=* ATTR=NAME:* "+"\n";
//  --------------------------------------------------------

// Starting here the fields gets posted
for(var x  in cells) {
    cell =cells[x];
    myMacro +="TAG POS=R1 TYPE=INPUT:TEXT FORM=* ATTR=NAME:* CONTENT="+cell+" "+"\
}

iimPlay(myMacro)
chivracq wrote: (And next time you open a Thread, I won't even react if you don't mention your FCI directly...)
You can be sure, I will include my FCI right at the beginning next time :-)
Okay..., I had a look again at your Case and thanks to your Script, I understand now a bit better what you want, even if your Site/Page is still missing to understand a bit how it looks like, but I see that you use Relative Positioning and iMacros needs an Anchor when using the TAG Mode, that's why the first "Field" is hard-coded in your Script as a Starting Point.

I did some Testing with the JavaScript 'document.activeElement.tagName' Function:

Code: Select all

URL GOTO=javascript:document.activeElement.tagName
It is able to identify the HTML Element that has the Focus and returns 'BODY' / 'TEXTAREA' / 'INPUT' / etc that you then can extract to use in a Var for 'TYPE={{Field_Focus}}' but it doesn't tell you which "Cell" exactly has the Focus if there are for example several 'INPUT' Fields, which seems to be your case...
Running that Function in 'URL GOTO' is quite intrusive as it will display the Result in the original TAB and you'll have to reload the Original Page (with 'URL GOTO' or 'BACK'), I didn't try to run it in 'EVAL()' and try to grab the Result from within the 'EVAL()', or maybe you can run it directly from your '.js' Script...
But if you search a bit, there might be a better Function as well than 'document.activeElement.tagName', I am no JavaScript Guru... :oops:

What you could do is prompt the User on which Cell they want to start the Paste, with Cell "1" or "A1" as Default, and using 'EVAL()' if necessary, you compute the 'POS=n' from the Input in the 'PROMPT'...

And otherwise, use the Method I gave you using the EVENT Mode with Tab and Arrows to navigate and 'Ctrl^p' for the Paste for which you can issue EVENT Mode Statements that can be made not dependent on a specific HTML Element on the Page...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Need to position in the field that has the focus

Post by chivracq » Mon Sep 25, 2017 4:02 pm

Hum..., pity @OP didn't follow up anymore...

But for Users searching the Forum, here is a similar Thread, 1.5 years later, and with again different new Solutions...:
- Getting the Textfield with Focus
8)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply