Auto insert data

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Auto insert data

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Auto insert data

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Or, you can try oGet:paste("Hello")
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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

EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

Thanks James and Enrico.
Post Reply