Page 1 of 1

Auto insert data

Posted: Wed May 31, 2006 5:09 pm
by Jeff Barnes
Hi Everybody,

I am trying to find a way to create a macro for the end user of my application.

I would like to have them do someting like press F5 and have the text "HELLO" inserted into a get.

Any Ideas?

Thanks,
Jeff

Re: Auto insert data

Posted: Wed May 31, 2006 7:33 pm
by Enrico Maria Giordano
Try something like this

POSTSTRING( oGet:hWnd, "HELLO" )

where POSTSTRING() is:

Code: Select all

FUNCTION POSTSTRING( hWnd, cString )

    LOCAL i, c

    DEFAULT hWnd := GETACTIVEWINDOW()

    FOR i = 1 TO LEN( cString )
        c = SUBSTR( cString, i, 1 )

        IF c > " "
            POSTMESSAGE( hWnd, WM_CHAR, ASC( c ) )
        ELSE
            POSTMESSAGE( hWnd, WM_KEYDOWN, ASC( c ) )
        ENDIF

        SYSREFRESH()
    NEXT

    RETURN NIL
EMG

Posted: Wed May 31, 2006 8:09 pm
by James Bott
Or, you can try oGet:paste("Hello")

Posted: Wed May 31, 2006 8:44 pm
by Enrico Maria Giordano
Much simpler. The only drawback is that it alters the clipboard, if I'm not wrong.

EMG

Posted: Wed May 31, 2006 11:04 pm
by James Bott
Enrico,

>Much simpler. The only drawback is that it alters the clipboard, if I'm not wrong.

I don't believe so. If cText is NOT passed then it pastes from the clipboard, but if cText is passed, then cText is used instead. Either way the clipboard is left as is.

It also handles numeric and date types in addition to string.

James

Posted: Wed May 31, 2006 11:07 pm
by Enrico Maria Giordano
Ops, you are right!

EMG

Posted: Thu Jun 01, 2006 2:13 am
by Jeff Barnes
Thanks James and Enrico.