automate enter key press

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

keliko
Posts: 87
Joined: Thu Aug 01, 2019 8:15 am

automate enter key press

Post by keliko » Mon Apr 19, 2021 11:52 am

Is there any way to automate an enter key press when "on mouseup" event.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: automate enter key press

Post by richmond62 » Mon Apr 19, 2021 12:20 pm

Here's thought:

Code: Select all

on mouseUp
   send "keyUp 104"
end mouseUp
But not a very good one:
-
SShot 2021-04-19 at 14.20.32.png
SShot 2021-04-19 at 14.20.32.png (21.67 KiB) Viewed 5705 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: automate enter key press

Post by richmond62 » Mon Apr 19, 2021 12:37 pm

You CAN send a simulated key press to a button:

Code: Select all

on mouseUp
   send "rawKeyUp 108" to btn "xx"
end mouseUp
Download my stack that demonstrates this here:

viewtopic.php?t=27644

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: automate enter key press

Post by richmond62 » Mon Apr 19, 2021 1:20 pm

You can also do this sort of thing:
-

Code: Select all

on mouseUp
   send "rawKeyUp 108" to fld "ff"
end mouseUp
BUT it will NOT type into the field.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: automate enter key press

Post by dunbarx » Mon Apr 19, 2021 2:06 pm

Why not just send the "enterKey" message? On a card with one button, in the button script:

Code: Select all

on mouseUp
   enterkey
end mouseUp
And in the card script:

Code: Select all

on enterkey
   answer random(99)
end enterkey
Click the button or press the enter key, you get a random number.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: automate enter key press

Post by richmond62 » Mon Apr 19, 2021 2:48 pm

Sorry: I went off on a tangent about faking any key press. 8)
-
fakeIt.jpeg
fakeIt.jpeg (3.76 KiB) Viewed 5649 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: automate enter key press

Post by dunbarx » Mon Apr 19, 2021 3:46 pm

Richmond.

I am always on a tangent. It is getting back onto the circle that keeps tripping me up.

Craig

keliko
Posts: 87
Joined: Thu Aug 01, 2019 8:15 am

Re: automate enter key press

Post by keliko » Tue Apr 20, 2021 4:32 am

thank you for responding in this thread.
I'm building an app using a "browser" widget with a live chat app.
usually when I write a chat and to send it I press the "enter" key on the computer keyboard.
I want to change the function that usually uses the "enter" key to send messages. replaced by just a click of the mouse.

is this possible?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: automate enter key press

Post by dunbarx » Tue Apr 20, 2021 5:13 am

Hi.

Have you repeated your request, or have I missed your intent? Otherwise, what is missing from my post?

Craig

keliko
Posts: 87
Joined: Thu Aug 01, 2019 8:15 am

Re: automate enter key press

Post by keliko » Tue Apr 20, 2021 10:26 am

@dunbarx

your script in the previous post, can be applied if within the scope of the livecode object. but for the browser widget as in my case it can't be applied.
I haven't found a way. I want to make the application run the command "enter" key press every 10 seconds with the widget browser.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: automate enter key press

Post by dunbarx » Tue Apr 20, 2021 1:39 pm

I want to make the application run the command "enter" key press every 10 seconds with the widget browser.
I have never used a widget in any project, so I am no expert on those gadgets. If we were purely inside LC, I might suggest a timer that sent the "enterKey" message to the card, or wherever, every 10 seconds. This is simple.

So, everyone, is there any access to a widget in the sense that one can write a handler attached to that widget? Or is the fact that the widget is "visible" a property that can be exploited in the same way?

craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9824
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: automate enter key press

Post by FourthWorld » Tue Apr 20, 2021 2:53 pm

I don't know if "click at <loc>" works in the Browser widget, but maybe worth trying.

Does the chat app use websockets or polling?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

keliko
Posts: 87
Joined: Thu Aug 01, 2019 8:15 am

Re: automate enter key press

Post by keliko » Wed Apr 21, 2021 12:44 am

yes I use the websocket protocol.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9824
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: automate enter key press

Post by FourthWorld » Wed Apr 21, 2021 2:04 am

Do they also offer an API with regular Unix sockets?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

keliko
Posts: 87
Joined: Thu Aug 01, 2019 8:15 am

Re: automate enter key press

Post by keliko » Wed Apr 21, 2021 5:11 am

FourthWorld wrote:
Wed Apr 21, 2021 2:04 am
Do they also offer an API with regular Unix sockets?
as i know they only use tcp/ip socket
by using socket.io

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”