Hello Guest it is April 16, 2024, 06:22:12 PM

Author Topic: Basic script to send enter key  (Read 5242 times)

0 Members and 1 Guest are viewing this topic.

Basic script to send enter key
« on: June 02, 2011, 12:05:07 PM »
Hi

I know it can be done via VB but how can one "send" the enter key with a button when using basic script in screen designer?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Basic script to send enter key
« Reply #1 on: June 02, 2011, 06:07:35 PM »
Have you tried SENDKEYS ??

Just a thought, (;-) TP
Re: Basic script to send enter key
« Reply #2 on: June 03, 2011, 04:35:57 AM »
Can't get it to work, tried:

SendKeys " {ENTER} "

Which then turns into SendKeys " ENTER "

And it doesn't work...

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Basic script to send enter key
« Reply #3 on: June 03, 2011, 11:08:25 AM »
HUM seems MachCB has a problem with FOCUS. It can't send to an application that does not have focus AND if you are in VB then only mach has focus (catch22)

SO Ian had a solution as it is::

SendKeys works just fine - but remember that sendKeys targets the application that has focus. If you're running sendKeys from the VB editor in Mach or from a button, then Mach has the focus... so it's sending keystrokes to itself.

Enter this into the VB editor in Mach.

sleep 10000
sendKeys("abc")

before you run it, open a copy of notepad. Then run the script - you then have 10 seconds to give notepad focus. Personally I dislike SendKeys, it can have nasty effects if you focus the wrong app.


Ian

Just a thought, (;-) TP
Re: Basic script to send enter key
« Reply #4 on: June 03, 2011, 11:35:38 AM »
Thanks Ian

What I basically want to do is send enter to the screen to enable MDI. When selecting the MDI button on my screen, it goes to the MDI screen fine, however before MDI would focus you need to press the enter key, I'm trying to get around that by sending enter after the MDI screen loads. Is there an alternative way?

Re: Basic script to send enter key
« Reply #5 on: June 06, 2011, 06:55:56 AM »
Thank Ian

I got this working by:
Sleep 500
SendKeys"ENTER"

Without the () it works :)