Page 1 of 1

Paste Text into Browser [accepting bids for solution]

Posted: Tue Feb 23, 2016 11:11 pm
by townsend
I've tried a few things. Nothing has worked. I'm sure there must be a way.
How about I pay someone (you) to figure this out for me? Here's the project.

Below I have a simple 5 second timer. Just drop this into any button and it works.
At the end of 5 seconds there's a beep. I need you to add to or modify this code so that;

After I click the Start button, (before the 5 seconds is over),
I move my cursor and place it in any field in any browser,
(ideally Chrome), and have LiveCode paste in some text,
"any text" to the browser field, at the end of the 5 seconds.
Is this possible? Can you do this?

Send me a personal message with a bid.
How much money would you need to do this for me?
I'd like to act on this as soon as possible.

PS: I hope this is the right place to post contract proposals.

Code: Select all

-- count-up seconds timer v3, written by me
-- just drop this code into any button and click to start

local started, cntr

on mouseUp
     if the label of me <> "Start" then set the label of me to "Start"
     if the label of me = "Start" then
          put the long seconds into started
          put (the long seconds - started) into cntr
          set the label of me to cntr
          countUp
     else if value(the label of me) >0 then
          set the label of me to "Start"
     end if
end mouseUp

on countUp
     if cntr >5 then  -------> SET TIMER VALUE in SECONDS <-------
          set the label of me to "Start"
          exit to top
     else 
          if the label of me = "Start" then
               exit to top
          else
               put (the long seconds - started) into cntr
               set the label of me to cntr
          end if
     end if
     -- breakpoint
     send "countUp" to me in 0.2 seconds
end countUp

Re: Paste Text into Browser [accepting bids for solution]

Posted: Tue Feb 23, 2016 11:30 pm
by FourthWorld
What do you want done with the text after it's in the browser? Are you submitting a form?

Sounds similar to this recent thread:
http://forums.livecode.com/viewtopic.php?f=8&t=26549

Re: Paste Text into Browser [accepting bids for solution]

Posted: Tue Feb 23, 2016 11:52 pm
by townsend
Hey Richard! Thanks for the link. This would be a lot easier if I were working with LiveCode's built in revBrowser, but I'm looking to integrate this with an external browser. No need to worry about submitting a form. This is just a small part of a larger project... but this one particular problem has me stumped.

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 12:26 am
by SparkOut
Is the project getting to paste text from the clipboard into a field in a browser, where the clipboard text was captured by LiveCode? And you will manually click a button in LiveCode to start a timer and during the timing period of 5 seconds, you will manually move the mouse and select a field in the browser that will have the clipboard text pasted into after the duration of the timer?

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 12:57 am
by townsend
SparkOut wrote:Is the project getting to paste text from the clipboard into a field in a browser, where the clipboard text was captured by LiveCode? And you will manually click a button in LiveCode to start a timer and during the timing period of 5 seconds, you will manually move the mouse and select a field in the browser that will have the clipboard text pasted into after the duration of the timer?
Yeah. That's it. The text would first need to be moved into the clipboard from LiveCode, and then from LiveCode, the text would eventually be pasted into the browser's field. The BIG problem is, once focus moves from LiveCode to the browser, the pasted test never ends up in the browser.

I've updated the code a bit. The Beep at the end of the routine was left out before. Also, I've added a set the systemWindow command... which doesn't seem to make any difference.

Code: Select all

-- count-up seconds timer v3, written by me
-- just drop this code into any button and click to start

set the systemWindow of stack "test3" to true
local started, cntr

on mouseUp
     if the label of me <> "Start" then set the label of me to "Start"
     if the label of me = "Start" then
          put the long seconds into started
          put (the long seconds - started) into cntr
          set the label of me to cntr
          countUp
     else if value(the label of me) >0 then
          set the label of me to "Start"
     end if
end mouseUp

on countUp
     if cntr >5 then  -------> SET TIMER VALUE in SECONDS <-------
          set the label of me to "Start"
          paste
          beep -----------> Here's the end of the routine
          exit to top
     else 
          if the label of me = "Start" then
               exit to top
          else
               put (the long seconds - started) into cntr
               set the label of me to cntr
          end if
     end if
     -- breakpoint
     send "countUp" to me in 0.2 seconds
end countUp

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 6:22 am
by bn
Hi,

You are trying to do some sort of Inter Application Communication. LC can not do this natively without using either shell, AppleScript or some Windows equivalent.

if you are on a Mac then you could try something like this:

it pastes the clipboard into an open TextEdit document (the frontmost) at the cursor location. Did not try this with a browser.

make a field, call it "fAS"
paste this into the field

Code: Select all

activate application "TextEdit"
delay 0.2

tell application "System Events"
	keystroke "v" using command down -- this is same as CMD-V
end tell
now use your button with this code

Code: Select all

-- count-up seconds timer v3, written by me
-- just drop this code into any button and click to start

local started, cntr

on mouseUp
     if the label of me <> "Start" then set the label of me to "Start"
     if the label of me = "Start" then
          put the long seconds into started
          put (the long seconds - started) into cntr
          set the label of me to cntr
          countUp
     else if value(the label of me) >0 then
          set the label of me to "Start"
     end if
end mouseUp

on countUp
     if cntr >5 then  -------> SET TIMER VALUE in SECONDS <-------
        set the label of me to "Start"
        put field "fAS" into tAS
        do tAS as appleScript
       -- put the result into field 1
          beep -----------> Here's the end of the routine
          exit to top
     else 
          if the label of me = "Start" then
               exit to top
          else
               put (the long seconds - started) into cntr
               set the label of me to cntr
          end if
     end if
     -- breakpoint
     send "countUp" to me in 0.2 seconds
end countUp
this is of course extremely minimalistic, just pasting. But if that is what you want then this might work for you.

If you manually choose the browser and the insertion location you can leave out the first part of the AppleScript: activate application "TextEdit" and delay 0.2

Kind regards
Bernd

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 7:06 pm
by townsend
bn wrote:You are trying to do some sort of Inter Application Communication. LC can not do this natively without using either shell, AppleScript or some Windows equivalent.
Thanks Bernd. Yes, that is now becoming very clear, as originally implied by Richards reference to the other similar post:
http://forums.livecode.com/viewtopic.php?f=8&t=26549

I'm not set up for Mac development, though with all the new LC iPhone utilities, I should seriously consider this. Anyway, using Shell or AppleScript would not be appropriate here, and since I've received no bids, I'm inclined to conclude this is not possible.

Though, I do have a budget from my client on this project, and now that I know not to waste any more time on this problem, I want you to know I appreciate you 3 chipping in with your insights. So, if each of you, Richard, SparkOut, and Bernd, would send me a private message with your email address, I'd be glad to send you some payPal tip money.

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 7:15 pm
by bn
Hi townsend,
private message with your email address, I'd be glad to send you some payPal tip money.
thank you for the offer but no tip money needed.

You should be able to do this via VBScript. Though I have no experience with this.

try a Google search with "vbscript paste from clipboard", there are many hits.

Kind regards

Bernd

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 9:02 pm
by FourthWorld
townsend wrote:Anyway, using Shell or AppleScript would not be appropriate here, and since I've received no bids, I'm inclined to conclude this is not possible.
Without knowing the goal of the system it'll be hard to advise, but if it's for emulating user behaviors you may want to explore Egglant, a tool for developing testing systems that has under its hood a rather xtalk-like scripting language:
http://www.testplant.com/eggplant/testing-tools/
Though, I do have a budget from my client on this project, and now that I know not to waste any more time on this problem, I want you to know I appreciate you 3 chipping in with your insights. So, if each of you, Richard, SparkOut, and Bernd, would send me a private message with your email address, I'd be glad to send you some payPal tip money.
I appreciate the offer, but I haven't done anything yet. If you're feeling incorrigibly generous you could let me know when you're passing through LA and we'll have a meal.

Re: Paste Text into Browser [accepting bids for solution]

Posted: Wed Feb 24, 2016 11:49 pm
by SparkOut
Given the problem as above, this is also pretty straightforward on Windows. Send me a PM with some more specific notes about what you want to be able to choose to do, and I am sure we can knock up a solution.

Re: Paste Text into Browser [accepting bids for solution]

Posted: Fri Feb 26, 2016 1:53 pm
by tetsuo29
Hi.

I took your code and put it in a button.

Then I added a field and named it "Statements"

In the "Statements" field I placed the following code:

Code: Select all

Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^v"
In your code, I made the following modification:

Code: Select all

on countUp
   if cntr >5 then  -------> SET TIMER VALUE in SECONDS <-------
       do text of field "Statements" as VBScript
When I click the "Start" button, your script will count up for 5 seconds and when it is finished, it will paste whatever is in the clipboard into whatever app is in the foreground. If this is Chrome, then it pastes the contents of the clipboard into Chrome if a field has the focus.

Hopefully this helps.