Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #& "C:\virtual on\player 1\m2emulator 1.0\TSStub.exe"
- #& "C:\virtual on\player 2\m2emulator 1.0\TSStub.exe"
- start-sleep -s 3
- get-process -name 'TSStub' | foreach-object { stop-process -name $_.name -force }
- & "C:\virtual on\player 1\m2emulator 1.0\emulator_multicpu - Shortcut.lnk"
- $processName = "emulator_multicpu";
- get-process -name $processName | foreach-object { stop-process -name $_.name }
- $counter = 0;
- do{
- $counter = 0;
- get-process -name $processName | foreach-object { stop-process -name $_.name -force }
- get-process -name $processName | foreach-object { $counter += 1; }
- write-host $counter
- }while($counter -gt 0)
- & "C:\virtual on\player 1\m2emulator 1.0\emulator_multicpu - Shortcut.lnk"
- start-sleep -s 3
- & "C:\virtual on\player 2\m2emulator 1.0\emulator_multicpu - Shortcut.lnk"
- #cd C:\virtual on\player 1\m2emulator 1.0
- #& "C:\virtual on\player 1\m2emulator 1.0\emulator_multicpu.exe" "C:\virtual on\player 1\m2emulator 1.0\roms\von\"
- #cd C:\virtual on\player 2\m2emulator 1.0
- #& "C:\virtual on\player 2\m2emulator 1.0\emulator_multicpu.exe" von
- start-sleep -s 5
- $counter = 0;
- do{
- $counter = 0;
- get-process -name $processName | foreach-object { $counter += 1; }
- }while($counter -lt 2)
- start-sleep -s 1;
- ##########################################################################################################
- # Set your wasp directory correctly, and process name
- ##########################################################################################################
- import-Module "c:\wasp.dll"
- ##########################################################################################################
- # Base of code, to call api's
- ##########################################################################################################
- $script:nativeMethods = @();
- function Register-NativeMethod([string]$dll, [string]$methodSignature)
- {
- $script:nativeMethods += [PSCustomObject]@{ Dll = $dll; Signature = $methodSignature; }
- }
- function Add-NativeMethods()
- {
- $nativeMethodsCode = $script:nativeMethods | % { "
- [DllImport(`"$($_.Dll)`")]
- public static extern $($_.Signature);
- " }
- Add-Type @"
- using System;
- using System.Runtime.InteropServices;
- public class NativeMethods {
- $nativeMethodsCode
- }
- "@
- }
- ##########################################################################################################
- # win32api ehre
- ##########################################################################################################
- Register-NativeMethod "user32.dll" "bool SetForegroundWindow(IntPtr hWnd)"
- Register-NativeMethod "user32.dll" "bool ShowWindow(IntPtr hWnd, int nCmdShow)"
- Register-NativeMethod "user32.dll" "bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint)"
- Register-NativeMethod "user32.dll" "bool AnimateWindow(IntPtr hwnd, UInt32 dwTime, UInt32 dwFlags)"
- Register-NativeMethod "user32.dll" "IntPtr FindWindow(IntPtr ZeroOnly, string lpWindowName)"
- Register-NativeMethod "user32.dll" "void keybd_event(Byte bVk, Byte bScan, UInt32 dwFlags, UInt32 dwExtraInfo)"
- Register-NativeMethod "user32.dll" "bool InvalidateRect(IntPtr hWnd, IntPtr ZeroOnly, bool bErase)"
- Register-NativeMethod "user32.dll" "int GetMenuItemCount(IntPtr hMenu)"
- Register-NativeMethod "user32.dll" "IntPtr GetMenu(IntPtr hWnd)"
- Register-NativeMethod "user32.dll" "IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName)"
- Register-NativeMethod "user32.dll" "bool DrawMenuBar(IntPtr hWnd)"
- Register-NativeMethod "user32.dll" "bool RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags)"
- Register-NativeMethod "user32.dll" "int GetWindowLong(IntPtr hWnd, int nIndex)"
- Register-NativeMethod "user32.dll" "int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong)"
- Register-NativeMethod "user32.dll" "bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags)"
- #Build class and registers them:
- Add-NativeMethods
- ##########################################################################################################
- # Constants used in APiss
- ##########################################################################################################
- $WS_BORDER = [int]8388608;
- $WS_DLGFRAME = [int]4194304;
- $WS_CAPTION = $WS_BORDER -bor $WS_DLGFRAME;
- $WS_SYSMENU = [int]524288;
- $WS_THICKFRAME = [int]262144;
- $WS_MINIMIZE = [int]536870912;
- $WS_MAXIMIZEBOX = [int]65536;
- $GWL_STYLE = [int]-16L;
- $GWL_EXSTYLE =[int] -20L;
- $WS_EX_DLGMODALFRAME = [int]0x1L;
- $SWP_NOMOVE = [int]0x2;
- $SWP_NOSIZE = [uint32](0x1);
- $SWP_FRAMECHANGED = [uint32](0x20);
- $WS_VISIBLE = [uInt32]0x10000000;
- $MF_BYPOSITION = [uint32](0x400);
- $MF_REMOVE = [uint32](0x1000);
- $process = ((Get-Process -name $processName)[0].MainWindowHandle);
- $process2 = ((Get-Process -name $processName)[1].MainWindowHandle);
- ##########################################################################################################
- # If your app doesn't have a mennu, delete this whole section
- ##########################################################################################################
- $hmenu = [NativeMethods]::GetMenu($process);
- $count = [NativeMethods]::GetMenuItemCount($hmenu);
- for ($i = 0; $i -lt $count; $i++){
- [NativeMethods]::RemoveMenu($hmenu, 0, ($MF_BYPOSITION));
- }
- [NativeMethods]::DrawMenuBar($process);
- $hmenu = [NativeMethods]::GetMenu($process2);
- $count = [NativeMethods]::GetMenuItemCount($hmenu);
- for ($i = 0; $i -lt $count; $i++){
- [NativeMethods]::RemoveMenu($hmenu, 0, ($MF_BYPOSITION));
- }
- [NativeMethods]::DrawMenuBar($process2);
- ##########################################################################################################
- [NativeMethods]::SetWindowLong($process, $GWL_STYLE, ($WS_VISIBLE));
- # InvalidateRect - Redraws window. Needed after AnimateWindow AW_ACTIVATE
- [NativeMethods]::InvalidateRect($hWnd, 0, "true") | Out-Null
- sleep -s 1
- [NativeMethods]::SetWindowLong($process2, $GWL_STYLE, ($WS_VISIBLE));
- # InvalidateRect - Redraws window. Needed after AnimateWindow AW_ACTIVATE
- [NativeMethods]::InvalidateRect($hWnd, 0, "true") | Out-Null
- sleep -s 1
- ##########################################################################################################
- # Position your window. Mess with top and left trim for positioning
- ##########################################################################################################
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- $topTrim = 10
- $leftTrim = 0
- $desktops = Get-WmiObject -Class Win32_DesktopMonitor
- #Get your monitor width/height here
- $sH = $desktops.ScreenHeight + $topTrim;
- $sW = $desktops.ScreenWidth + (($leftTrim*2));
- $var = select-window $processName;
- $var[0].setposition( (New-Object System.Drawing.Rectangle((0),(-1 * ($topTrim)),$sW,$sH)) )
- $var[1].setposition( (New-Object System.Drawing.Rectangle(($sW),(-1 * ($topTrim)),$sW,$sH)) )
- $var | ForEach { Set-WindowPosition -X (-1*$leftTrim) -Y (-1 * ($topTrim)) -Window $_ }
- $sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
- Add-type -MemberDefinition $sig -name NativeMethods -namespace win32
- $hwnd = @(get-process "emulator_multicpu")[0].MainWindowHandle
- #[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)
- [Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)
- $hwnd = @(get-process "emulator_multicpu")[1].MainWindowHandle
- #[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)
- [Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement