使用发送键在 ms Paint 中翻转图像

问题描述 投票:0回答:1

我一直在尝试制作一个bat文件来翻转MS Paint中的当前图像,(通过按int alt,i,alt,i,f,enter),但不管我做什么,它只能到达按的点替代我

 powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('%%{i}%')"
 powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('%%{i}%')"
  powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('f')"

我已经尝试过这个,它只能按相当于 alt i 的键然后停止

完整代码是这个

  @echo off
setlocal


REM Minimize the active window
powershell -c "Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class WindowState { [DllImport(\"user32.dll\")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); [DllImport(\"user32.dll\")] public static extern IntPtr GetForegroundWindow(); }'; [WindowState]::ShowWindowAsync([WindowState]::GetForegroundWindow(), 2)"



prtscreen key

powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('^{PRTSC}')"

open ms

    open cmd

explorer.exe Shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}

powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('mspaint')"                       




                



REM Simulate pressing the Enter key
powershell -c "Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class KeyPresser { [DllImport(\"user32.dll\")] public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); }'; [KeyPresser]::keybd_event(0x0D, 0, 0, [UIntPtr]::Zero); [KeyPresser]::keybd_event(0x0D, 0, 2, [UIntPtr]::Zero);"
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('')"  



 REM timeout /t <5> [/nobreak]
 powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('^v')"
 REM timeout /t <3> [/nobreak]
 powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('%%{i}%')"
 powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('%%{i}%')"
  powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('f')"

powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')"
pause
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('^s')"

powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')" 
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait(' ')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('C:\Users\olive\Pictures')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{TAB}')"
  
powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')"
 timeout /t <150> [/nobreak]
REM start %USERPROFILE%\desktop\openpicture.bat
REM start C:\Users\olive\Pictures\untitled.png
SLEEP 30

powershell -c "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('^r')"

endlocal
pause
batch-file
1个回答
0
投票

似曾相识。对我来说,效果不是那么好,但看到发生的事情很有趣。如果你想实施你的计划,祝你好运......

下面的批处理(更像是 powershell)使用了用换行符 设置变量并将其传递给 ps 的技巧。所有带有 @ 的行都会被预先过滤。

这对于您想要做的事情来说并不是很有用。我建议在批次中嵌入 Base64 编码的变体。这甚至会使其成为一句俏话。

对于测试和阅读代码来说不实用...;)

@ECHO OFF
@ENDLOCAL
@SETLOCAL EnableDelayedExpansion
@REM -> Creating a Line Feed variable (the blank lines are required!)
@SET LF=^


@REM <- The two empty lines are neccessary, spaces are not allowed!
@SET command=#
@FOR /F "tokens=*" %%A IN ('findstr -bv @ "%~f0"') DO SET command=!command!!LF!%%A
@powershell -ExecutionPolicy ByPass -noprofile -command !command! & EXIT /B


# *** POWERSHELL CODE STARTS HERE *** #
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
public class WindowState {
[DllImport(\"user32.dll\")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport(\"user32.dll\")]
public static extern IntPtr GetForegroundWindow();
[DllImport(\"user32.dll\")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport(\"user32.dll\")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}
';
Add-Type -AssemblyName System.Windows.Forms;
Add-Type -AssemblyName System.Drawing
[WindowState]::ShowWindowAsync([WindowState]::GetForegroundWindow(), 2)
Start-Sleep -MilliSeconds 200;
$Screen  = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width   = $Screen.Width
$Height  = $Screen.Height
$Left    = $Screen.Left
$Top     = $Screen.Top
$bitmap  = New-Object System.Drawing.Bitmap $Width, $Height
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
$bitmap.RotateFlip([System.Drawing.RotateFlipType]::Rotate180FlipY)
$bitmap.Save($env:TEMP + '\sc.bmp')
$setwallpapersrc = '
using System.Runtime.InteropServices;
public class Wallpaper {
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport(\"user32.dll\", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
public static void SetWallpaper(string path) {
SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange);
}
}
'
Add-Type -TypeDefinition $setwallpapersrc
[Wallpaper]::SetWallpaper($env:TEMP + '\sc.bmp')
Start-Sleep -MilliSeconds 100;
$x = New-Object -ComObject Shell.Application;
$x.minimizeall()
© www.soinside.com 2019 - 2024. All rights reserved.