Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Executing external programs

by haukex (Canon)
on Feb 18, 2019 at 22:02 UTC ( #1230126=note: print w/replies, xml ) Need Help??


in reply to Executing external programs

I want the perl code to write into the text box (I do not want to write a file and open it then)

If you want to display text to a user in a GUI with live updates, then attempting to use notepad.exe to do so is probably not the best way to do this. You probably want to look into UI toolkits like Tk or maybe Prima.

Update: See also Perl GUI (2013).

Replies are listed 'Best First'.
Re^2: Executing external programs
by Silt (Novice) on Feb 18, 2019 at 22:33 UTC
    I don't mind how it is displayed. I just want to have a code that can change things in another program, i.e. write text in a text box and use tools inside that program.
    The goal is the execute a program with inputs that enters one in the field and then does sth with it. All automated.

      Well, there are e.g. GUI testing toolkits that can do things like that, but what the best method is also depends very much on which program you're trying to control?

        Also, you cannot expect that any program can be controlled. Some programs are made in such a manner that they can be controlled with OLE/COM and notepad is not one of them

        There are some ways to program around that and there are many 'tools' around that are made for UI Automation.

        Someone did however create a OLE module in Perl which would allow you to do something like this:

        use strict ; use warnings ; use Win32::OLE ; use Time::HiRes qw( sleep ) ; my $ex = Win32::OLE->new('WScript.Shell') or die "oops\n"; $ex->run('Notepad') ; sleep(0.1) ; $ex->sendkeys("Hello World!") ;

        Which is equivalent to the vbscript:

        Set wshshell = wscript.CreateObject("WScript.Shell") Wshshell.run "Notepad" wscript.sleep 100 wshshell.sendkeys "Hello World!"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1230126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2019-03-19 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How do you Carpe diem?





    Results (92 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!