Groups > Superbase > Superbase 2 programming > Re: Sendkeys




Sendkeys

Sendkeys
Fri, 2 Jun 2006 12:43:57 +1000
Hi again folks,

I need to send some key strokes to another application - Alt F4 to close it 
and some minor text...!

I open the text file for append using EXECUTE txtfile1$ (which holds the 
append syntax)
Followed by APPACTIVATE txtfile1$

I then try to send a text string to the application SENDKEYS data$ (data$ = 
"Sales Finalised") but the key strokes do not appear in the text
file.

The final syntax SENDKEYS "%" works fine followed by SENDKEYS
"Y" to 
save the infomation.
All of the ALT, CTRL, MENU commands seem to go to the application but for 
some reason I can not get any text to write in any file.  Is there some 
other syntax which may do the trick..?
-- 
Kind Regards
Axel H.
Life was never meant to be easy lol. 

Post Reply
Re: Sendkeys
Mon, 05 Jun 2006 07:04:18 -040
Is this text file a .txt file, such as in Notepad, or part of a more complex
application? Perhaps you could use OLE, or output strings directly to the file?

In the case of many accounting programs, there may be an XML interface that the
provider offers free to integrators. Intuit is one such provider. This allows
automation from third party apps.

Excel responds well to OLE, as do I think most Windows database sysems.

We use each of these methods regularly from a Superbase app.

Peter



On Mon, 05 Jun 2006 05:12:46 -0400, Neil Robinson <neilr@superbase.co.uk>
wrote:

> Axel H wrote:
>> Hi again folks,
>>
>> I need to send some key strokes to another application - Alt F4 to
close it
>> and some minor text...!
>>
>> I open the text file for append using EXECUTE txtfile1$ (which holds
the
>> append syntax)
>> Followed by APPACTIVATE txtfile1$
>>
>> I then try to send a text string to the application SENDKEYS data$
(data$ =
>> "Sales Finalised") but the key strokes do not appear in the
text file.
>>
>> The final syntax SENDKEYS "%" works fine followed by
SENDKEYS "Y" to
>> save the infomation.
>> All of the ALT, CTRL, MENU commands seem to go to the application but
for
>> some reason I can not get any text to write in any file.  Is there
some
>> other syntax which may do the trick..?
>
> Not easily. The problem is that in Win32 (I assume you are trying to
> send data to a Win32 program) the outer window that is receiving the
> data may not be the one that actually is presenting the place for it to
> be input. Unfortunately using SENDKEYS to fill in data in Win32 is
> extremely hit or miss.
>
> Ciao, Neil
>



-- 
Post Reply
Re: Sendkeys
Mon, 05 Jun 2006 09:55:52 -040
Axel,

This counts the lines in a text file, put a timer in and see if it is fast
enough for you on a large text file:

  OPEN texfil$ FOR INPUT
    WHILE NOT EOF ("*"):INPUT LINE z$:linum% = linum% + 1:WEND
  CLOSE INPUT

Here is a trick I use to test for MEMORY files, that may illustrate further:

  ' determine if a current file is volatile
  ' determine if a current file is volatile
FUNCTION IzMemFil%%(InFile$)
  ' SET STATUS "Retrieving information from file: " + InFile$
  OPEN "filestat.opf" FOR OUTPUT
  ? STATUS FILE FN name(InFile$)
  CLOSE OUTPUT
  OPEN "filestat.opf" FOR INPUT
  WHILE NOT (a$ LIKE "Access mode*" OR EOF ("*") OR
IzMemFil%%):INPUT LINE a$:IzMemFil%% = (a$ LIKE "File is
volatile*"):WEND
  CLOSE INPUT
  ' REQUEST InFile$,IF (IzMemFil%%,"file is volatile","file is
normal")
  IF EXISTS ("filestat.opf") THEN DELETE "filestat.opf"
  END FUNCTION

This is very fast in actual use. Of course one could also simply use EXISTS() to
look for the .SBF file, if the full path is known.


Peter




On Mon, 05 Jun 2006 08:20:39 -0400, Axel H <hahnheuser@optusnet.com.au>
wrote:

> Thankyou Neil & Peter,
>
> This explains why I can still send ALT commands to Win32 applications but
no
> text data.  I presume the menu structure of Win32 programs is contained
> within the outer window.  This still allows me to use the CALL,
APPACTIVATE
> and SENDKEYS (%) on the application albeit with limited functionality.
>
> The final process of this data entry sends information to a html file for
> end processing.  What I will do is skip the text file and have Superbase
add
> the required information directly to the .HTML file eg: VALUE="the
final
> input" prior to processing the HTML form.  Is there an easy way I can
search
> for a string in a text file, then edit or add a new string or would I have
> to INPUT the whole html file into a temp database, modify the contents and
> OUTPUT the results back to the file.  The html page is 1200+ lines yet
only
> one line needs to be changed.
>
> If I can edit a single line of text in a ASCII file I could also update
the
> bypassed txt file and this would completely solve my problem.
>
> I thankyou both for your advice and you advice is greatly appreciated.
>



-- 
Post Reply
Re: Sendkeys
Mon, 05 Jun 2006 10:12:46 +010
Axel H wrote:
> Hi again folks,
> 
> I need to send some key strokes to another application - Alt F4 to close it

> and some minor text...!
> 
> I open the text file for append using EXECUTE txtfile1$ (which holds the 
> append syntax)
> Followed by APPACTIVATE txtfile1$
> 
> I then try to send a text string to the application SENDKEYS data$ (data$ =

> "Sales Finalised") but the key strokes do not appear in the text
file.
> 
> The final syntax SENDKEYS "%" works fine followed by SENDKEYS
"Y" to 
> save the infomation.
> All of the ALT, CTRL, MENU commands seem to go to the application but for 
> some reason I can not get any text to write in any file.  Is there some 
> other syntax which may do the trick..?

Not easily. The problem is that in Win32 (I assume you are trying to
send data to a Win32 program) the outer window that is receiving the
data may not be the one that actually is presenting the place for it to
be input. Unfortunately using SENDKEYS to fill in data in Win32 is
extremely hit or miss.

Post Reply
Re: Sendkeys
Mon, 05 Jun 2006 15:33:49 -040
That's the idea.


On Mon, 05 Jun 2006 12:32:09 -0400, Axel H <hahnheuser@optusnet.com.au>
wrote:

> Thanks Peter,
>
> You sparked off some ideas I hadn't considered before.  I have come up
with
> the following which will rewrite the file on the fly (including any
modified
> data) without processing it to either memory or superbase.  The following
> modifies one line of a .htm document and then processes it for sending:
>
>  OPEN "submit.htm" FOR INPUT
>  OPEN "new.htm" FOR OUTPUT
>    sch$ = "<input type=hidden name=" + CHR$ (34) +
".t" + CHR$ (34)
>    chg$ = "<input type=hidden name=" + CHR$ (34) +
".t" + CHR$ (34) + "
> value=" + CHR$ (34) + "1234" + CHR$ (34) + ">"
>     WHILE NOT EOF ("*")
>      INPUT LINE cur$
>      IF cur$ LIKE sch$ + "?*" THEN ? chg$ ELSE ? cur$
>    WEND
>  CLOSE INPUT
>  CLOSE OUTPUT
> IF EXISTS ("submit.htm") THEN COPY
"submit.htm","submit.bak"
> IF EXISTS ("new.htm") THEN DELETE "submit.htm"
> RENAME "new.htm","submit.htm"
>
> Since the search text is variable, I should be able to use this subroutine
> to change any text i wish by simply adding to the WHILE/WEND loop.  The
CHR$
> (34) replace the " required in HTML forms.
>



-- 
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact