Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

manipulating window positions on Win7

by LanX (Saint)
on May 14, 2015 at 23:54 UTC ( [id://1126716]=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I recently switched to a project where I need to hack in a Win7 environment simultaneously on my client and in a Windows Terminal Sessions.

I need a way to script different composition of window positions (editor, browser(s), SQL-tool, WTS-session, mailer, chat-tool, ...)

Under Linux I was pretty successful with calling wmctrl², what's the way to do it in Win?

I had a look into Win32::GUI , but it seemed to rather be a tool to launch TK-like applications.

Shortly phrased:

How can I query the names, positions and state of my windows with Perl and manipulate them?

I want to trigger different settings from my IDE¹ ...

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

¹) emacs of course... :)

²) compare this API X11::WMCtrl

Replies are listed 'Best First'.
Re: manipulating window postion on Win7
by BrowserUk (Patriarch) on May 14, 2015 at 23:56 UTC

    See Win32::GuiTest.


    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'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
      I was gonna say same thing. That worked great when i needed to find a window (MPC-HC) and send it commands (keyboard strokes).
Re: manipulating window positions on Win7
by dasgar (Priest) on May 15, 2015 at 05:06 UTC

    To add to BrowserUk's suggestion of using Win32::GuiTest, you might find a few other pieces of information useful.

    At times, you may need to find the ID of a window or a component of a window. Checkout Re: Win32::GuiTest control id for some information on how you can find these details. Alternatively, you should be able to find windows by their title's text and possibly some components by their label's text.

    Also, you mentioned using "Windows Terminal Sessions". I'm not sure how successful you will be running Win32::GuiTest code on one system to control GUI applications on a remote system via remote desktop connection. In fact, that's a scenario that I personally would try to avoid doing. I think you'll be more successful if you had the code running on the system whose GUI app(s) that you are trying to control. Even then, there's a few more gotchas to be aware of when trying to do this in a remote desktop session. Checkout Re: How to get handle of a window on desktop (this window is not created by perl code) for more details.

    One more thing. It's been a few years since I looked into automating a GUI application and I tried using both Win32::GuiTest and AutoIt. In both cases, I personally found it much easier to control a GUI by sending simulated keystrokes rather than trying to use simulated mouse clicks. In other words, if you can figure out how to drive the GUI app to get it to do what you want it to do using just your keyboard, you can now use that information to drive the GUI app via Win32::GuiTest.

    Just thought that I'd pass on some tips and tricks that I learned the hard way.

      Thanks for the links. :)

      Yes I plan to also run an instance on the WTS, possibly connected to a hot key such that I can trigger it from my client.

      I agree, I'll certainly try to avoid any mouse clicks, at best some scrolling.

      Most applications allow automation by hotkeys, triggering them should be sufficient for me.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Re: manipulating window positions on Win7
by Discipulus (Canon) on May 15, 2015 at 07:10 UTC
    .. i would like to see some working code about the topic, if you have the time to share it LanX.
    In fact this is the only code i 've ever done with Win32::GuiTest, a simple screen grabber, but i'm reather interested by the topic.
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Thanks that's a start. My minimal goal is to switch between snapshots of certain windows.

      I'm on holiday, gonna try it from Monday on. :)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1126716]
Approved by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found