KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Window Positioning Macros - SpeechStart and others - for remote apps
Topic Summary: That DO work with Citrix Receiver remote application windows
Created On: 02/10/2015 02:59 PM
Status: Post and Reply
Linear : Threading : Single : Branch
Keyword
 02/10/2015 02:59 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2180
Joined: 03/21/2007

I have the SpeechStart+ commands for moving windows to predefined locations, as well as some ahk keyboard macros that do the same (or similar) thing, but neither work with windows I have open using Citrix Receiver.  Note, these windows are not open in the remote desktop, but rather as stand-alone windows on my local desktop.

 

The ahk (AutoIt3) window spy lists these windows as:

[actual window title] - \\ Remote
ahk_class Transparent Windows Client
ahk_exe WFICA32.EXE

 

Does anyone know how to use Windows-native functionality to move these types of windows?  

 

I once wrote some Dragon Macros that literally selected the window and pressed the alt-space and move or size windows control to drag windows and resize.  Should I try to find those somewhere if they might work?

 

TIA



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.

 02/10/2015 06:49 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 39333
Joined: 10/01/2006

KnowBrainer 2014 includes a WINDOW <window position> command but it probably works the same way as SpeechStart+ and may not work in your situation. However, KnowBrainer also includes <SizeList> Window and <SizeList> Window <1to50>. We believe these commands would work for resizing your Windows and if they work for resizing Windows, it should also be easy to copy/edit these commands for moving Windows. Just food for thought.



-------------------------

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1

 02/10/2015 08:23 PM
User is offline View Users Profile Print this message


G.J. Premo
Top-Tier Member

Posts: 821
Joined: 05/12/2007

Please post an .ahk macro for sizing a window

For example, SpeechStart+  "Display 2" for moving the window to another monitor requires a parameter such as  "maximize", "left half", etc., but I would like the window to remain its same relative size on the second monitor.   So I need a voice command to quickly resixe the moved window.

 02/10/2015 10:58 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2180
Joined: 03/21/2007

AHK not in scope for this forum, but here you go, I have it adapted so win-down first restores a max'd win then pressing it again (or if the win is already not full-screen) moves it while keeping the dimensions to my other screen:



#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

#Warn  ; Enable warnings to assist with detecting common errors.

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


; Mods (C) 2014 PG Service with all rights to underlying reserved as per below:

; MsgBox Hello World



;; -----------------------------------------------------------------------

;; Fling (or shift) a window from one monitor to the next in a multi-monitor system.

;;

;; Function Parameters:

;;

;;      WinID            The window ID of the window to move. There are two special WinID

;;                     values supported:

;;

;;                     1) The value "A" means to use the Active window (default).

;;                     2) The value "M" means to use the window currently under the Mouse.

;;

;; KeepRelativeSize    If true (default), the flung window is resized so as to keep

;;    the same *relative* size with respect to its new window. If false,

;;    the original window dimensions are preserved.

;;

;;      FlingDirection      The direction of the fling, expected to be either +1 (default) or -1.

;;                    The function is not limited to just two monitors; it supports

;;                    as many monitors as are currently connected to the system and

;;                  can fling a window serially through each of them in turn.

;;

;; The flinged window will be resized to have the same *relative* size in the new monitor.

;; For example, if the window originally occupied the entire right half of the screen,

;; it will again on the new monitor (assuming the window can be resized).

;;

;; Minimized windows are not modified; they are left exactly where they were.

;;

;; The return value of the function is non-zero if the window was successfully flung.

;;

;; Example hotkeys:

   #Down::   Win__Fling("A")   ; Windows-Down arrow flings the active window, keeping scaling

;;   #LButton::       Win__Fling("M")   ; Windows-LeftClick flings the window under the mouse

;;   #RButton::       Win__Fling("M", false)   ; Windows-RightClick flings the window under the

;; ;  mouse and keeps its original dimensions

;;

;; Copyright (c) 2010 Patrick Sheppard

;; All Rights Reserved


Win__Fling(WinID, KeepRelativeSize = true, FlingDirection = 1)

{

   ; Figure out which window to move based on the "WinID" function parameter:

   ;   1) The letter "A" means to use the Active window

   ;   2) The letter "M" means to use the window under the Mouse

   ; Otherwise, the parameter value is assumed to be the AHK window ID of the window to use.


   if (WinID = "A")

   {

      ; If the user supplied an "A" as the window ID, we use the Active window

      WinID := WinExist("A")

   }

   else if (WinID = "M")

   {

      ; If the user supplied an "M" as the window ID, we use the window currently under the Mouse

      MouseGetPos, MouseX, MouseY, WinID      ; MouseX & MouseY are retrieved but, for now, not used

   }


   ; Check to make sure we are working with a valid window

   IfWinNotExist, ahk_id %WinID%

   {

      ; Make a short noise so the user knows to stop expecting something fun to happen.

      SoundPlay, *64

      

      ; Debug Support

      ;MsgBox, 16, Window Fling: Error, Specified window does not exist.`nWindow ID = %WinID%


      return 0

   }


   ; Here's where we find out just how many monitors we're dealing with

   SysGet, MonitorCount, MonitorCount


   if (MonitorCount <= 1)

   {

      ; Honestly, there's not much to do in a one-monitor system

      return 1

   }


   ; For each active monitor, we get Top, Bottom, Left, Right of the monitor's

   ;  'Work Area' (i.e., excluding taskbar, etc.). From these values we compute Width and Height.

   ;  Results get put into variables named like "Monitor1Top" and "Monitor2Width", etc.,

   ;  with the monitor number embedded in the middle of the variable name.


   Loop, %MonitorCount%

   {

      SysGet, Monitor%A_Index%, MonitorWorkArea, %A_Index%

      Monitor%A_Index%Width  := Monitor%A_Index%Right  - Monitor%A_Index%Left

      Monitor%A_Index%Height := Monitor%A_Index%Bottom - Monitor%A_Index%Top

   }


   ; Retrieve the target window's original minimized / maximized state

   WinGet, WinOriginalMinMaxState, MinMax, ahk_id %WinID%


   ; We don't do anything with minimized windows (for now... this may change)

   if (WinOriginalMinMaxState = -1)

   {

      ; Debatable as to whether or not this should be flagged as an error

      return 0

   }

   

   ; If the window started out maximized, then the plan is to:

   ;   (a) restore it,

   ;   (b) fling it, then

   ;   (c) re-maximize it on the target monitor.

   ;

   ; The reason for this is so that the usual maximize / restore windows controls

   ; work as you'd expect. You want Windows to use the dimensions of the non-maximized

   ; window when you click the little restore icon on a previously flung (maximized) window.

   

   if (WinOriginalMinMaxState = 1)

   {

      ; Restore a maximized window to its previous state / size ... before "flinging".

      ;

      ; Programming Note: It would be nice to hide the window before doing this ...

      ; the window does some visual calisthenics that the user may construe as a bug.

      ; Unfortunately, if you hide a window then you can no longer work with it.


      WinRestore, ahk_id %WinID%

      return 1  ;  I'm done -- I only want to restore a maxed win

   }


   ; Retrieve the target window's original (non-maximized) dimensions

   WinGetPos, WinX, WinY, WinW, WinH, ahk_id %WinID%


   ; Find the point at the centre of the target window then use it

   ; to determine the monitor to which the target window belongs

   ; (windows don't have to be entirely contained inside any one monitor's area).

   

   WinCentreX := WinX + WinW / 2

   WinCentreY := WinY + WinH / 2


   CurrMonitor = 0

   Loop, %MonitorCount%

   {

      if (    (WinCentreX >= Monitor%A_Index%Left) and (WinCentreX < Monitor%A_Index%Right )

          and (WinCentreY >= Monitor%A_Index%Top ) and (WinCentreY < Monitor%A_Index%Bottom))

      {

         CurrMonitor = %A_Index%

         break

      }

   }


   ; Compute the number of the next monitor in the direction of the specified fling (+1 or -1)

   ;  Valid monitor numbers are 1..MonitorCount, and we effect a circular fling.

   NextMonitor := CurrMonitor + FlingDirection

   if (NextMonitor > MonitorCount)

   {

      NextMonitor = 1

   }

   else if (NextMonitor <= 0)

   {

      NextMonitor = %MonitorCount%

   }


   ; Scale the position / dimensions of the target window by the ratio of the monitor sizes.

   ; Programming Note: Do multiplies before divides in order to maintain accuracy in the integer calculation.

   WinFlingX := (WinX - Monitor%CurrMonitor%Left) * Monitor%NextMonitor%Width  // Monitor%CurrMonitor%Width  + Monitor%NextMonitor%Left

   WinFlingY := (WinY - Monitor%CurrMonitor%Top ) * Monitor%NextMonitor%Height // Monitor%CurrMonitor%Height + Monitor%NextMonitor%Top

   

   if KeepRelativeSize

   {

  WinFlingW :=  WinW * Monitor%NextMonitor%Width  // Monitor%CurrMonitor%Width

      WinFlingH :=  WinH * Monitor%NextMonitor%Height // Monitor%CurrMonitor%Height

   }

   else

   {

      WinFlingW := WinW

  WinFlingH := WinH

   }


   ; It's time for the target window to make its big move

   WinMove, ahk_id %WinID%,, WinFlingX, WinFlingY, WinFlingW, WinFlingH


   ; If the window used to be maximized, maximize it again on its new monitor

   if (WinOriginalMinMaxState = 1)

   {

      WinMaximize, ahk_id %WinID%

   }


   return 1

}



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 02/11/2015 12:10 AM
User is offline View Users Profile Print this message


G.J. Premo
Top-Tier Member

Posts: 821
Joined: 05/12/2007

Thank you very much.

 02/11/2015 12:53 PM
User is offline View Users Profile Print this message


Bruce Tjosvold
Top-Tier Member

Posts: 353
Joined: 10/02/2006

PG,

 

Any reason you can't use the Window key shortcut:

Shift+WinKey+Right

 

In AutoHotKey the script would be:

Send {Shift Down}{LWin Down}{Right Down}{Right Up}{LWin Up}{Shift Up}

 

Bruce



-------------------------

DPI 15.00.000.076


 


1

 02/11/2015 03:01 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2180
Joined: 03/21/2007

I do!! I also use WinKey+Left and Right to move windows to half-screen positions among monitors. I love those essential native WinKey shortcuts! But, they don't work on Citrix remote application windows.

So, the difference in the above ahk macro (which I assigned to WinKey+Down) is how the window maintains the original relative size between two different sized monitors. While Shift+WinKey+Right will attempt to reduce a too-large window to scale on a smaller monitor, flinging a window from the small monitor does not expand it to a similar proportion on the larger one.

-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.

Statistics
32168 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 408 guests browsing this forum, which makes a total of 409 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.