Jump to content

WinMove is not working


Recommended Posts

I'm trying to resize a window so I can reliably use mouse clicks to manipulate it. Unfortunately, I can't get winmove() to work on the thing. My code (I've changed the name of the window).

If WinExists("Blah") Then
      $oBlah = WinGetHandle("Blah")
      WinMove($oBlah, "", 0, 0, 800, 500)
   Else
      MsgBox("0", "No Blah window", "Please open Blah")
   EndIf

I've used the Window Info tool and MsgBox to verify that this code does return the correct handle. The window I'm working with is a little non-standard, it's a citrix app, but I can resize and move it manually just like any other window. Am I doing something wrong here? Are there any other ways of resizing windows? And if not, is there a way to base my mouse coordinates off the right side of the window instead of the left, in order to manipulate content that is right-justified? Thanks for your help.

Link to comment
Share on other sites

I have fought with scripting Citrix windows before and it can be a real pain.  Try adding these 2 lines to the beginning of your script and see if it makes any difference at all:

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also

If that doesn't help, can you give more info?  Are you getting the "Please Open Blah" message box when you run the script?  Is this a seamless published app that you're trying to script? Where exactly are you running the script from; your local workstation or the Citrix server?  Which version of Citrix server?

Edited by MuffinMan
one more question to ask...
Link to comment
Share on other sites

I think I have run into a situation where I needed WinActivate() before a move to make it work.

I feel even with resize and such, mouse clicks are not a reliable way to automate on more than one computer, but you can also look into WinSetState() (for maximize)

WinGetPos() to get coordinates + size and work like that.

If keyboard sends/commands work that should be better than mouse clicks.

To click the RIGHT side of a window instead of the left (I am assuming you're already using WinGetPos to get the left side) try something like this.

Run("Notepad.exe")
WinWait("[Class:Notepad]", "")
WinActivate("[Class:Notepad]", "")
$aPosition = WinGetPos("[Class:Notepad]", "")
Sleep(2000)
;Top Left Corner[0] + Width[2] = Top Right Corner
MouseClick("left", $aPosition[0]+$aPosition[2]-20, $aPosition[1]+20, 1, 10)

 

Link to comment
Share on other sites

I was thinking about this more over my lunch break, and I don't know if WinExists relies on Shell.Application Windows, but if it does, Citrix apps don't get a proper shell, so you may have to rely on hWnd for all your Win commands.  I tested the code below with a published Instance of Internet Explorer.  If I run it on the Citrix server everything works as it should.  If I run it from my local workstation, the Winactivate happens, but not the WinMove.  The WinMove is returning the same handle as the WinGethandle though.

 

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also

$WinName = "Blah"
$oBlah = WinGetHandle($WinName)
If WinExists($oBlah) Then
    WinActivate($oBlah)
    WinMove($oBlah, "", 0, 0, 1200, 500)
Else
    MsgBox("0", "No Blah window", "Please open Blah")
EndIf

 

Edited by MuffinMan
Link to comment
Share on other sites

  • 6 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...