Simulating Enter/Tab key with a twist

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

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.

Simulating Enter/Tab key with a twist

by nchhajed on Tue Oct 15, 2013 7:31 pm

Hello,

Before you jump the gun and refer me to other threads, please read through my objective and challenge at least once.

What is my aim? - I am trying to upload 1 column csv file into PeopleSoft ERP page. Unfortunately, I cannot share the screen but will attempt to describe my challenge in detail.

What have I accomplished? - I can input the file successfully. No problems there

My challenge - After every row of upload, I need to have a tab or enter key to activate another hyperlink on the same row on the page. I have the code working on what I need to do post activating that hyperlink but being able to simulate the tab or enter key is the main challenge. Somehow I am not able to find the element ID of the field where the file rows are being uploaded.

My code looks like this:
Code: Select all
SET !DATASOURCE C:\myMenus.csv
SET !DATASOURCE_COLUMNS 1

SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}

SET !VAR2 {{!LOOP}}
ADD !VAR2 1

FRAME NAME="TargetContent"

TAG POS={{!LOOP}} TYPE=IMG ATTR=SRC:http://11.25.32.175/cs/finsnd91/cache/PT_ADD_1.gif

wait seconds=0.5

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:PSACLMENU_VW2_MENUNAME${{!LOOP}} CONTENT={{!COL1}}
wait seconds=0.5

'Simulating enter or tab key code here. Following line does not work but just opens in a new window
'URL GOTO=javascript:var<SP>e=document.createEvent("KeyboardEvent");e.initKeyEvent("keypress",1,1,window,0,0,0,0,13,13);document.body.dispatchEvent(e);


TAG POS=1 TYPE=A ATTR=ID:DERIVED_MENU2_SELECT_FLAG${{!LOOP}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:win0 ATTR=ID:SELECT_ALL_BTN$0
wait seconds=0.5
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:win0 ATTR=ID:#ICSave
wait seconds=0.5
TAG POS={{!VAR2}} TYPE=IMG ATTR=SRC:http://11.25.32.175/cs/finsnd91/cache/PT_ADD_1.gif
wait seconds=0.5


I am a noob in javacscript but tried every possible combination to make the above commented code work. I have referred to following posts but couldnt get exactly what I wanted.
http://forum.iopus.com/viewtopic.php?f=6&p=53355
http://www.webdeveloper.com/forum/showt ... Simulation

Details of my machine and setup:
1. What version of iMacros are you using? - 6060703
2.What operating system are you using? - Windows 7 English
3. Which browser(s) are you using? IE 9, Firefox 17 and Chrome 30.0.1599.69 m
4. Do the included demo macros work ok? - Yes
5. If reporting a problem with the Scripting Interface, please also test if the included VBS sample scripts run ok. - Yes. these work fine
6. If recording or replay fails on a specific website:- Not applicable
7. Do you encounter the same problem with the iMacros Browser, iMacros for Internet Explorer and iMacros for Firefox? - Well, technically not applicable as the code hasnt been figured out.

Thank you in advance.
nchhajed
 
Posts: 2
Joined: Tue Oct 15, 2013 7:09 pm

Re: Simulating Enter/Tab key with a twist

by Tom, Tech Support on Wed Oct 16, 2013 4:37 am

Hi nchhajed,

Have you considered using DirectScreen to send the Enter key to the target element?

Code: Select all
DS CMD=KEY X={{!TAGX}} Y={{!TAGY}} CONTENT={ENTER}
Regards,

Tom, iMacros Support
Tom, Tech Support
 
Posts: 3298
Joined: Mon May 31, 2010 9:59 am

Re: Simulating Enter/Tab key with a twist

by nchhajed on Wed Oct 16, 2013 11:37 am

Thanks Tom,

I wasnt looking into DirectScreen as it was not available in free version.

I tried it for 3 rows (with the dialog box notification that DS is available in business versions) and it worked perfectly.

Thank you.
nchhajed
 
Posts: 2
Joined: Tue Oct 15, 2013 7:09 pm

Re: Simulating Enter/Tab key with a twist

by jcauthorn on Sun Dec 06, 2015 1:07 am

Ok, this is for an old post but I finally figured out how to send a Tab Character and it works. I haven't tried an Enter character yet, but I'd bet is similar.
I don't know if they are purposely trying to hide this information or what, I spent several hours looking for this exact function because the page is re-written when you hit TAB but not when you try to use the TAG to find a page element.
Really? Does it have to be this hard to discover how to send a TAB characer with iMacros? And I read somewhere this only works with FireFox. I didn't check Chrome or IE, but it does work with FireFox.

By using the EVENT keyword you can send a TAB character to the web page with iMacros like this example:
EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY>DIV:nth-of-type(5)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>INPUT" KEY=9

I discovered this by recording with the "Experimental event recording mode". Most of the time you may not want to use that because the code seems to be much uglier, and TAG, when it works, gets the job done well.
That's my $0.02 worth.

Yes you can send a TAB character 9 to a web page from iMacros with FireFox this way - I verified that works.
+JCauthorn
jcauthorn
 
Posts: 1
Joined: Sun Dec 06, 2015 12:58 am

Re: Simulating Enter/Tab key with a twist

by chivracq on Sun Dec 06, 2015 2:16 am

jcauthorn wrote:Ok, this is for an old post but I finally figured out how to send a Tab Character and it works. I haven't tried an Enter character yet, but I'd bet is similar.
I don't know if they are purposely trying to hide this information or what, I spent several hours looking for this exact function because the page is re-written when you hit TAB but not when you try to use the TAG to find a page element.
Really? Does it have to be this hard to discover how to send a TAB characer with iMacros? And I read somewhere this only works with FireFox. I didn't check Chrome or IE, but it does work with FireFox.

By using the EVENT keyword you can send a TAB character to the web page with iMacros like this example:
EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY>DIV:nth-of-type(5)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>INPUT" KEY=9

I discovered this by recording with the "Experimental event recording mode". Most of the time you may not want to use that because the code seems to be much uglier, and TAG, when it works, gets the job done well.
That's my $0.02 worth.

Yes you can send a TAB character 9 to a web page from iMacros with FireFox this way - I verified that works.
+JCauthorn

Yep, Thanks for sharing, but I'm a bit curious about the timeline of your "finally"...
What you post is just standard Functionality since the EVENT Mode Exists (on FF) (= since about 2 years...!?) and now on IE as well since a few weeks (check the Date of my current Post), so there is not much new..., hum, I say 2 years, but the OP was from 2013, and the OP at that time was still using iMacros for FF 6.0.6, but the EVENT Mode only came in the v8.24 Version, which is about at least 2 years old, v6.0.6 is much older, at least 4 years old, I would think..., I would need to check the Version History Page and a few older Posts on the Forum where Users mentioned their FCI to be sure...

Check my Posts on the EVENT Mode if you want to learn more about the EVENT Mode..., especially with "Feedback EVENT Mode" (as a Search), I maintain a Post in that Threads with all interesting other Threads pertaining to the EVENT Mode... (with interesting Solutions...)
- (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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 2 guests

-->