ankit.tayal560 has asked for the wisdom of the Perl Monks concerning the following question:

use Win32::GuiTest qw(:ALL); use strict; system("C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Accessori +es/Calculator.lnk"); my @window=FindWindowLike(undef,"Calculator"); if(!@window) { die("cannot find window with title/caption Calculator\n"); } else { printf("window handle of Calculaotr is %x \n",$window[0]); }

I've written above code tryin gto automate a calculator operation . the problem here is when I invoke a system call to open a calculator through my script the script stucks there and the further actions of the script are not performed. Any solutions to the above problem ??

Replies are listed 'Best First'.
Re: Problem with System() command in perl?
by BrowserUk (Patriarch) on Oct 07, 2016 at 11:24 UTC

    Use this code instead:

    system 1, 'calc';

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Problem with System() command in perl?
by marto (Cardinal) on Oct 07, 2016 at 10:34 UTC

    Many modules ship with examples, take a look at calc.pl, note how these examples start applications. system

      yes I already looked into that. he's opening calculator through its main .exe file that is why it is working. but for some weird reason I have to open it from the shortcut that is why I used that path in system call. how can we do the same operation when invoking calculator through shortcut??? any suggestions???

        It'd be helpful if you didn't ignore things. It doesn't matter if you call the .exe directly or not. You seem to have a lot of "wired reasons" for doing things and making life difficult for yourself.

        use strict; use warnings; use Win32; use Win32::GuiTest qw(:ALL); my $calc = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\ +\Accessories\\Calculator.lnk"; print "nothing else will happen until you close calc.exe\n"; system($calc); print "you closed calc.exe, moving on...\n"; print "using `start` to launch calc.exe will return once calc.exe is l +oaded\n"; system('start "" "' . $calc . '"'); print "\n\nyep, still running!\n\n";