Handle external windows using java

前端 未结 4 939
小鲜肉
小鲜肉 2020-12-06 11:35

I need to check if an external window (another java program, but not controlled by the program that I\'m working on) is open using the title, and if it open, then either max

4条回答
  •  情歌与酒
    2020-12-06 12:05

    You can use the Windows API to get a handle to the window and then resize it:

    EnumWindows:
    http://msdn.microsoft.com/en-us/library/ms633497%28v=VS.85%29.aspx
    
    GetNextWindow:
    http://msdn.microsoft.com/en-us/library/ms633509%28v=VS.85%29.aspx
    
    GetWindowText:   (to decide whether that is the window you want; if title matches)
    http://msdn.microsoft.com/en-us/library/ms633520%28v=VS.85%29.aspx
    
    FindWindow:  (for this you need the exact title beforehand, not just part of it)
    http://msdn.microsoft.com/en-us/library/ms633499%28v=vs.85%29.aspx
    
    ShowWindow:
    http://msdn.microsoft.com/en-us/library/ms633548%28v=VS.85%29.aspx
    

    Typical WinAPI interface, a little clunky to use but powerful.

提交回复
热议问题