Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 10:44:05 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  Mach Screens
| | |-+  Basic script to send enter key
Pages: 1   Go Down
Print
Author Topic: Basic script to send enter key  (Read 663 times)
0 Members and 2 Guests are viewing this topic.
jrobson
Active Member

Offline Offline

Posts: 78


View Profile
« on: June 02, 2011, 11:05:07 AM »

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?
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #1 on: June 02, 2011, 05:07:35 PM »

Have you tried SENDKEYS ??

Just a thought, (;-) TP
Logged
jrobson
Active Member

Offline Offline

Posts: 78


View Profile
« Reply #2 on: June 03, 2011, 03:35:57 AM »

Can't get it to work, tried:

SendKeys " {ENTER} "

Which then turns into SendKeys " ENTER "

And it doesn't work...
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #3 on: June 03, 2011, 10: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
Logged
jrobson
Active Member

Offline Offline

Posts: 78


View Profile
« Reply #4 on: June 03, 2011, 10: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?

Logged
jrobson
Active Member

Offline Offline

Posts: 78


View Profile
« Reply #5 on: June 06, 2011, 05:55:56 AM »

Thank Ian

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

Without the () it works Smiley
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!