Code to insert text at the cursor location in Firefox

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

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.

Code to insert text at the cursor location in Firefox

by steveg on Fri May 26, 2017 10:47 am

I'm technically challenged on this one. I want to insert the text, "-[color=@ff0000]Red[/color]" anywhere the cursor is in Firefox. This is aimed at a message board that employs both a simple and a WYSIWYG editor. My attempts result in working in one editor only and the macro deletes all previous typed text. My idea is to have a macro that would act like a paste from the clipboard when executed.

VERSION BUILD=9030808 RECORDER=FX
Windows 7 Pro / Firefox 53.0.3(64 bit)
steveg
 
Posts: 4
Joined: Thu May 25, 2017 4:05 pm

Re: Code to insert text at the cursor location in Firefox

by chivracq on Fri May 26, 2017 7:12 pm

steveg wrote:I'm technically challenged on this one. I want to insert the text, "-[color=@ff0000]Red[/color]" anywhere the cursor is in Firefox. This is aimed at a message board that employs both a simple and a WYSIWYG editor. My attempts result in working in one editor only and the macro deletes all previous typed text. My idea is to have a macro that would act like a paste from the clipboard when executed.

Code: Select all
VERSION BUILD=9030808 RECORDER=FX
Windows 7 Pro / Firefox 53.0.3(64 bit)

OK, FCI mentioned in your "Duplicate" Thread, not need to open Duplicates, you can always edit your original Post/Thread...
Hum, and both opened in the wrong Sub-Forum, grrr...!

Can't you post the URL to your Site...?, I think I could find a working Solution for your Qt but I need to do a little bit of "Testing"...
The "Idea" is to use the 'EVENT' Mode, with 'TAB' + 'Shift_TAB' or with Arrows Left+Right, or End_of_Row, all combined with a 'Ctrl^v'..., but pfff, I need to be able to play with the Page to find a working Solution...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Code to insert text at the cursor location in Firefox

by steveg on Fri May 26, 2017 7:20 pm

I didn't know that my first post required a moderator approval. When I couldn't find it to edit it, I thought I hadn't posted it. So I did it again. -Sorry!

Here is the site of interest:
http://www.apneaboard.com/forums/index.php
steveg
 
Posts: 4
Joined: Thu May 25, 2017 4:05 pm

Re: Code to insert text at the cursor location in Firefox

by chivracq on Fri May 26, 2017 7:56 pm

steveg wrote:I didn't know that my first post required a moderator approval. When I couldn't find it to edit it, I thought I hadn't posted it. So I did it again. -Sorry!

Here is the site of interest:
http://www.apneaboard.com/forums/index.php

Yeah, don't worry about the Duplicate, happens regularly with First_Time_Posters...

OK, Thanks for the Link to your Forum, but hum, I only see some "Public" and "Private" Areas but no "place" where some "-[color=@ff0000]Red[/color]" could come in-between... :?
And if it's a Forum, I guess I will need to register, which pfff, I don't do..., especially i it's only to do some Testing on their Forum, I will get kicked out very quick, ah-ah...! :twisted: , but I guess I can probably do the same Testing on our Forum..., then I know I won't be kicked out, ah-ah...!
Never heard of 'ApneaBoard' before but it veeeery looks forked on 'phpBB' to me...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Code to insert text at the cursor location in Firefox

by steveg on Fri May 26, 2017 8:02 pm

If its of any help, I'm 99% certain it is using myBB as the base code. I'm fairly sure that if it works here it has a high probability to work there.

BTW; Thank you!
steveg
 
Posts: 4
Joined: Thu May 25, 2017 4:05 pm

Re: Code to insert text at the cursor location in Firefox

by chivracq on Fri May 26, 2017 8:39 pm

steveg wrote:If its of any help, I'm 99% certain it is using myBB as the base code. I'm fairly sure that if it works here it has a high probability to work there.

BTW; Thank you!

OK, I'll try to do some mini-Testing for on our Forum (even if WE's are always very busy for me, I'm a DJ and it's 'Hemelvaart' now (hum, "Ascension" I think...), lots of sexy Festivals this WE, ah-ah...!, even if I don't have to play myself...)

But hum, could you post a mini-Script (applied to "our" Forum) for what you want exactly, your ']color[' Meta-Tag is a "Wrap" Tag with Begin+End Select Anchors, so I'm still not sure I understood exactly what you want exactly..., and how you want to apply your Macro exactly...!?

Willing to help you and to come up with some Sol but I need to understand exactly what your "Situation" is and what you want, ah-ah...! :oops:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Code to insert text at the cursor location in Firefox

by steveg on Sat May 27, 2017 6:14 am

If it is of any help here what will insert my desired text but deletes any previous text that I've typed.
Code for the WYSIWYG Editor:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=NAME:input ATTR=TABINDEX:2&&DIR:ltr&&TXT: CONTENT=-[color=#ff0000]Red[/color]<BR>

Simple or Quick Editor:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=ID:quick_reply_form ATTR=ID:message CONTENT=-[color=#ff0000]Red[/color]<BR>]

I tried using a wildcard ("*") in the FORM and ATTR parameters but this mod only worked in the quick edit form and still deleted the previous text.
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=* ATTR=* CONTENT=-[color=#ff0000]Red[/color]<BR>

as well as:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=NAME:* ATTR=* CONTENT=-[color=#ff0000]Red[/color]<BR>


I hope this may provide some insights.
steveg
 
Posts: 4
Joined: Thu May 25, 2017 4:05 pm

Re: Code to insert text at the cursor location in Firefox

by chivracq on Sat May 27, 2017 9:17 am

steveg wrote:If it is of any help here what will insert my desired text but deletes any previous text that I've typed.
Code for the WYSIWYG Editor:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=NAME:input ATTR=TABINDEX:2&&DIR:ltr&&TXT: CONTENT=-[color=#ff0000]Red[/color]<BR>

Simple or Quick Editor:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=ID:quick_reply_form ATTR=ID:message CONTENT=-[color=#ff0000]Red[/color]<BR>]

I tried using a wildcard ("*") in the FORM and ATTR parameters but this mod only worked in the quick edit form and still deleted the previous text.
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=* ATTR=* CONTENT=-[color=#ff0000]Red[/color]<BR>

as well as:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TEXTAREA FORM=NAME:* ATTR=* CONTENT=-[color=#ff0000]Red[/color]<BR>


I hope this may provide some insights.

Okay..., but I was asking for some mini-Script that I could replay/test on this current Forum...
So, OK..., did my own Testing from Scratch, using some 'Post Reply' Input Field on this current Thread, and this Script seems to work, using like I had mentioned previously, the 'EVENT' Mode with Arrows and 'Ctrl^v' for a 'Paste' using the OS Clipboard. ('Paste' is not supported on iMacros for CR btw, at least until v8.4.4...)

By default, the 'COLOUR' Content will be placed at the end of the existing Text, but in the 3 seconds that the Script is waiting after typing the "Existing Content" part, if you click anywhere in that Text, the 'COLOUR' Content will be pasted exactly at the Cursor Position...:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
TAB T=1
'URL GOTO=http://forum.imacros.net/posting.php?mode=reply&f=11&t=27526

TAG POS=1 TYPE=TEXTAREA FORM=ID:postform ATTR=ID:message CONTENT=Existing<SP>Content...
WAIT SECONDS=3

SET !CLIPBOARD [color=#40BF40]COLOUR...![/color]
EVENT TYPE=CLICK SELECTOR="#message" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="#message" KEYS="[37,39]"

EVENT TYPE=KEYPRESS SELECTOR="#message" CHAR="v" MODIFIERS="ctrl"
(Tested on iMacros for FF v8.8.2, Pale Moon v26.3.3 (=FF47), Win10-x64.)

Warning: It uses the OS Clipboard, meaning you will loose any Content you had placed previously on the Clipboard..., ah-ah...!
But I've already posted a simple Workaround if you want to "secure" the original Content of the Clipboard...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 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: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: Bing [Bot] and 9 guests

Website Monitoring