Link to home
Start Free TrialLog in
Avatar of Mike Treat
Mike TreatFlag for United States of America

asked on

Is there any way to open a Window to a specific position and size from a shortcut, or from another utility app. This would be handy.

I need this ability for settng up to open applications and documents to a specific location on the screen.  I have looked and cannot find this any where.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Treat

ASKER

I have VS.NET

Can this be done with VB.NEt

I found this program called AutoSizer that works pretty good
The following example opens Notepad and then moves it to the bottom right of the screen with a width of 500 and a height of 250:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
        (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, _
        ByVal x As Integer, ByVal y As Integer, _
        ByVal cx As Integer, ByVal cy As Integer, _
        ByVal wFlags As Integer) As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim p As Process = Process.Start("notepad.exe")
        p.WaitForInputIdle()
        Dim w As Integer = 500
        Dim h As Integer = 250
        SetWindowPos(p.MainWindowHandle.ToInt32, 0, Screen.PrimaryScreen.WorkingArea.Width - w, Screen.PrimaryScreen.WorkingArea.Height - h, w, h, 0)
    End Sub

End Class