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.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Need to position in the field that has the focus

by imacroNewBie96 on Thu Feb 25, 2016 1: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 11:30 am, edited 1 time in total.
imacroNewBie96
 
Posts: 4
Joined: Thu Feb 25, 2016 12:49 pm

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

by chivracq on Thu Feb 25, 2016 1: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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

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

by imacroNewBie96 on Tue Mar 01, 2016 8:35 am

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 12:49 pm

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

by imacroNewBie96 on Tue Mar 01, 2016 8:48 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:

- 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.
imacroNewBie96
 
Posts: 4
Joined: Thu Feb 25, 2016 12:49 pm

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

by chivracq on Tue Mar 01, 2016 6:01 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:

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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

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

by imacroNewBie96 on Sun Mar 06, 2016 12: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 :-)
imacroNewBie96
 
Posts: 4
Joined: Thu Feb 25, 2016 12:49 pm

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

by chivracq on Mon Mar 07, 2016 4: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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

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

by chivracq on Mon Sep 25, 2017 9:02 am

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)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 6 guests

-->