Page 1 of 2
automate enter key press
Posted: Mon Apr 19, 2021 11:52 am
by keliko
Is there any way to automate an enter key press when "on mouseup" event.
Re: automate enter key press
Posted: Mon Apr 19, 2021 12:20 pm
by richmond62
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 (21.67 KiB) Viewed 8263 times
Re: automate enter key press
Posted: Mon Apr 19, 2021 12:37 pm
by richmond62
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
Re: automate enter key press
Posted: Mon Apr 19, 2021 1:20 pm
by richmond62
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.
Re: automate enter key press
Posted: Mon Apr 19, 2021 2:06 pm
by dunbarx
Why not just send the "enterKey" message? On a card with one button, in the button script:
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
Re: automate enter key press
Posted: Mon Apr 19, 2021 2:48 pm
by richmond62
Sorry: I went off on a tangent about faking any key press.
-

- fakeIt.jpeg (3.76 KiB) Viewed 8207 times
Re: automate enter key press
Posted: Mon Apr 19, 2021 3:46 pm
by dunbarx
Richmond.
I am always on a tangent. It is getting back onto the circle that keeps tripping me up.
Craig
Re: automate enter key press
Posted: Tue Apr 20, 2021 4:32 am
by keliko
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?
Re: automate enter key press
Posted: Tue Apr 20, 2021 5:13 am
by dunbarx
Hi.
Have you repeated your request, or have I missed your intent? Otherwise, what is missing from my post?
Craig
Re: automate enter key press
Posted: Tue Apr 20, 2021 10:26 am
by keliko
@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.
Re: automate enter key press
Posted: Tue Apr 20, 2021 1:39 pm
by dunbarx
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
Re: automate enter key press
Posted: Tue Apr 20, 2021 2:53 pm
by FourthWorld
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?
Re: automate enter key press
Posted: Wed Apr 21, 2021 12:44 am
by keliko
yes I use the websocket protocol.
Re: automate enter key press
Posted: Wed Apr 21, 2021 2:04 am
by FourthWorld
Do they also offer an API with regular Unix sockets?
Re: automate enter key press
Posted: Wed Apr 21, 2021 5:11 am
by keliko
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