application start running at login, with specified positions for windows

d.remoussenard@act-cs.fr 0 Reputation points
2023-08-19T10:11:57.4666667+00:00

Hello,

Il would like to start some applications when I am logging, and positionning the windows at some specifics places (defined with powertoys if possible).

Is that possible?

Didier

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-08-21T06:56:57.8066667+00:00

    Hi,

    You can open task scheduler from start menu and create a task to run the application when the user is logged in. I didn't find a way set the window position in powertoys, however the MoveWindow function could be helpful. You can create a PowerShell script to invoke the function and add the script to the login task.

    https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-movewindow

    As MoveWindow is a Win32 function it can be used like this

    $MethodDefinition = @'
    [DllImport("user32.dll", CharSet = CharSet.Unicode)]
    public static extern bool MoveWindow(int hWnd, int  X,int  Y, int  nWidth, int  nHeight, bool bRepaint);
    '@
    $user32 = Add-Type -MemberDefinition $MethodDefinition -Name 'user32' -Namespace 'Win32' -PassThru
    $WindowHandle = (Get-Process notepad | Get-ChildWindow).MainWindowHandle | Select-Object -Unique
    $user32::MoveWindow($WindowHandle,300,300,1000,1000, $true) 
    

    I used the Get-ChildWindow funtion from the below link to get the window handle.

    https://stackoverflow.com/questions/25369285/how-can-i-get-all-window-handles-by-a-process-in-powershell

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.