在坐标处打开文件资源管理器

DCOPTimDowd

当我启动计算机时,我打开几个文件浏览器并在屏幕上对它们进行排序,以帮助加快工作流程。它不耗时,仅乏味,我想要一个小程序为我做。我知道如何打开浏览器,但是看不到任何位置参数。

有没有一种方法可以在一组屏幕坐标处生成文件浏览器,或者在打开文件后以编程方式移动它?最好是python 3+,但批处理也可以。

黑暗的东西

同时,这比我想象的要容易和困难。一切都已评论,如果您还有其他问题,请通知我。这是PowerShell /批处理混合脚本(因此将其另存为.bat文件),因为默认情况下或某些系统上禁用了PowerShell。

<# :
:: Based on https://gist.github.com/coldnebo/1148334
:: Converted to a batch/powershell hybrid via http://www.dostips.com/forum/viewtopic.php?p=37780#p37780
:: Array comparison from http://stackoverflow.com/a/6368667/4158862
@echo off
setlocal
set "POWERSHELL_BAT_ARGS=%*"
if defined POWERSHELL_BAT_ARGS set "POWERSHELL_BAT_ARGS=%POWERSHELL_BAT_ARGS:"=\"%"
endlocal & powershell -NoLogo -NoProfile -Command "$_ = $input; Invoke-Expression $( '$input = $_; $_ = \"\"; $args = @( &{ $args } %POWERSHELL_BAT_ARGS% );' + [String]::Join( [char]10, $( Get-Content \"%~f0\" ) ) )"
goto :EOF
#>

# Create an instance of the Win32 API object to handle and manipulate windows
Add-Type @"
  using System;
  using System.Runtime.InteropServices;

  public class Win32 {
    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
  }
"@

# Get a list of existing Explorer Windows
$previous_array = @()
$shell_object = New-Object -COM 'Shell.Application'

foreach($old_window in $shell_object.Windows())
{
    $previous_array += $old_window.HWND
}

# Open four more Explorer Windows in the current directory
explorer
explorer
explorer
explorer

# Pause for 1 second so that the windows have time to finish opening
sleep 1

# Get the list of new Explorer Windows
$new_array = @()
foreach($new_window in $shell_object.Windows())
{
    $new_array += $new_window.HWND
}

# Compare the two arrays and only process the new windows
$only_new = Compare-Object -ReferenceObject $previous_array -DifferenceObject $new_array -PassThru

# MoveWindow takes HWND value, X-position on screen, Y-position on screen, window width, and window height
# I've just hard-coded the values, adjust them to suit your needs
[Win32]::MoveWindow($only_new[0],0,0,960,540,$true)
[Win32]::MoveWindow($only_new[1],960,0,960,540,$true)
[Win32]::MoveWindow($only_new[2],0,540,960,540,$true)
[Win32]::MoveWindow($only_new[3],960,540,960,540,$true)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

文件资源管理器如何打开文件?

在文件资源管理器中打开目录

在文件上打开资源管理器

如何从Qt打开文件资源管理器?

打开资源管理器并选择文件(如果尚未打开)

如何打开Pydev包资源管理器

Win + E无法打开资源管理器

Process.Start 打开资源管理器

Windows 7或10:资源管理器排序顺序-区分常规资源管理器窗口与打开文件/浏览器窗口

Windows 10 文件资源管理器无法打开任何驱动器

如何在同一窗口中从VSCode文件资源管理器打开文件

双击文件资源管理器,如何用windbg打开转储文件?

在文件资源管理器中打开的文件夹的历史记录

无法直接从文件资源管理器中打开 vscode 中的 json 文件?

文件资源管理器无法打开上传文件

如何从文件资源管理器的“打开方式”选项中读取文件?

我可以在资源管理器中打开Windows重命名的zip文件吗?

每次从文件资源管理器打开终端时,如何获取 PowerShell 当前位置

从wsl2 debian打开文件资源管理器

无法直接从文件资源管理器打开 Delphi 项目

从Cmd在Windows资源管理器中打开文件夹

如何更改 .vhd 文件关联以使用 Windows 资源管理器打开?

右键单击Windows 10无法打开新的文件资源管理器窗口

如何在Shell中打开默认的文件资源管理器?

VS Code:禁用打开的文件和资源管理器之间的链接

android studio 3.0设备文件资源管理器“打开方式”

初学者打开资源管理器以显示文件夹内容

vbscript在同一资源管理器窗口中打开文件夹

如何直接从Windows资源管理器中使Spyder打开python脚本(.py文件)