in reply to Reload Browser Tab on Windows

Instead of Win32::OLE, have you considered Win32::GuiTest -- it is a module specifically designed for remote-running Windows apps: clicking buttons, activating menus, typing keys.

Otherwise, taking a look at the code from the first answer to the SO post you linked,

Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.AppActivate("Firefox") WshShell.SendKeys "{F5}" WshShell.AppActivate("TextPad")

I think that the CreateObject would be equivalent to the Win32::OLE->new('WScript.Shell'), and that the methods should translate across... but I haven't tried.

I'll try:

perl -MWin32::OLE -e "$obj = Win32::OLE->new('WScript.Shell') or die $ +!; $obj->AppActivate('Chrome') or die $!; $obj->SendKeys('{F5}');"

Yep, that refreshed the current page in Chrome for me.

Hopefully, that gives you enough to get started with.

Replies are listed 'Best First'.
Re^2: Reload Browser Tab on Windows
by pryrt (Abbot) on Dec 21, 2020 at 21:39 UTC
    Since I recommended Win32::GuiTest, I should have given equivalent example using that module, too:

    C:\usr\local\share>perl -MWin32::GuiTest=":FUNC" -le "my ($chrome) = F +indWindowLike(0, 'Google Chrome$'); print $chrome; print GetWindowTex +t($chrome); SetForegroundWindow($chrome);SendKeys('{F5}')"

    That also refreshes the current Chrome window for me.

Re^2: Reload Browser Tab on Windows
by LanX (Saint) on Dec 21, 2020 at 21:44 UTC
    > Instead of Win32::OLE, have you considered Win32::GuiTest -- it is a module specifically designed for remote-running Windows apps: clicking buttons, activating menus, typing keys.

    Many thanks, I forgot about it, especially FindWindowLike will help me identifying the right instance of FF.

    :)

    > Otherwise, taking a look at the code from the first answer to the SO post you linked,

    I have to admit, that's what I'm using meanwhile via Powershell.

    Less dependencies! :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery