SHARE
TWEET

Untitled

a guest Sep 9th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #& "C:\virtual on\player 1\m2emulator 1.0\TSStub.exe"
  2. #& "C:\virtual on\player 2\m2emulator 1.0\TSStub.exe"
  3. start-sleep -s 3
  4. get-process -name 'TSStub' | foreach-object { stop-process -name $_.name -force }
  5.  
  6. & "C:\virtual on\player 1\m2emulator 1.0\emulator_multicpu - Shortcut.lnk"
  7. $processName = "emulator_multicpu";
  8. get-process -name $processName | foreach-object { stop-process -name $_.name }
  9.  
  10. $counter = 0;
  11. do{
  12.  
  13. $counter = 0;
  14. get-process -name $processName | foreach-object { stop-process -name $_.name -force }
  15. get-process -name $processName | foreach-object {  $counter += 1; }
  16. write-host $counter
  17. }while($counter -gt 0)
  18.  
  19. & "C:\virtual on\player 1\m2emulator 1.0\emulator_multicpu - Shortcut.lnk"
  20.  
  21. start-sleep -s 3
  22. & "C:\virtual on\player 2\m2emulator 1.0\emulator_multicpu - Shortcut.lnk"
  23.  
  24.  
  25. #cd C:\virtual on\player 1\m2emulator 1.0
  26. #& "C:\virtual on\player 1\m2emulator 1.0\emulator_multicpu.exe" "C:\virtual on\player 1\m2emulator 1.0\roms\von\"
  27.  
  28. #cd C:\virtual on\player 2\m2emulator 1.0
  29. #& "C:\virtual on\player 2\m2emulator 1.0\emulator_multicpu.exe" von
  30.  
  31. start-sleep -s 5
  32.  
  33.  
  34. $counter = 0;
  35. do{
  36.  
  37. $counter = 0;
  38. get-process -name $processName | foreach-object {  $counter += 1; }
  39.  
  40. }while($counter -lt 2)
  41.  
  42. start-sleep -s 1;
  43.  
  44. ##########################################################################################################
  45. #   Set your wasp directory correctly, and process name
  46. ##########################################################################################################
  47. import-Module "c:\wasp.dll"
  48.  
  49.  
  50.  
  51.  
  52. ##########################################################################################################
  53. #   Base of code, to call api's
  54. ##########################################################################################################
  55. $script:nativeMethods = @();
  56. function Register-NativeMethod([string]$dll, [string]$methodSignature)
  57. {
  58.     $script:nativeMethods += [PSCustomObject]@{ Dll = $dll; Signature = $methodSignature; }
  59. }
  60. function Add-NativeMethods()
  61. {
  62.     $nativeMethodsCode = $script:nativeMethods | % { "
  63.         [DllImport(`"$($_.Dll)`")]
  64.         public static extern $($_.Signature);
  65.     " }
  66.  
  67.     Add-Type @"
  68.         using System;
  69.         using System.Runtime.InteropServices;
  70.         public class NativeMethods {
  71.             $nativeMethodsCode
  72.         }
  73. "@
  74. }
  75.  
  76. ##########################################################################################################
  77. #   win32api ehre
  78. ##########################################################################################################
  79. Register-NativeMethod "user32.dll" "bool SetForegroundWindow(IntPtr hWnd)"
  80. Register-NativeMethod "user32.dll" "bool ShowWindow(IntPtr hWnd, int nCmdShow)"
  81. Register-NativeMethod "user32.dll" "bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint)"
  82. Register-NativeMethod "user32.dll" "bool AnimateWindow(IntPtr hwnd, UInt32 dwTime, UInt32 dwFlags)"
  83. Register-NativeMethod "user32.dll" "IntPtr FindWindow(IntPtr ZeroOnly, string lpWindowName)"
  84. Register-NativeMethod "user32.dll" "void keybd_event(Byte bVk, Byte bScan, UInt32 dwFlags, UInt32 dwExtraInfo)"
  85. Register-NativeMethod "user32.dll" "bool InvalidateRect(IntPtr hWnd, IntPtr ZeroOnly, bool bErase)"
  86. Register-NativeMethod "user32.dll" "int GetMenuItemCount(IntPtr hMenu)"
  87. Register-NativeMethod "user32.dll" "IntPtr GetMenu(IntPtr hWnd)"
  88. Register-NativeMethod "user32.dll" "IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName)"
  89. Register-NativeMethod "user32.dll" "bool DrawMenuBar(IntPtr hWnd)"
  90. Register-NativeMethod "user32.dll" "bool RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags)"
  91. Register-NativeMethod "user32.dll" "int GetWindowLong(IntPtr hWnd, int nIndex)"
  92. Register-NativeMethod "user32.dll" "int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong)"
  93. Register-NativeMethod "user32.dll" "bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags)"
  94.  
  95. #Build class and registers them:
  96. Add-NativeMethods
  97.  
  98. ##########################################################################################################
  99. #   Constants used in APiss
  100. ##########################################################################################################
  101.     $WS_BORDER = [int]8388608;
  102.     $WS_DLGFRAME = [int]4194304;
  103.     $WS_CAPTION = $WS_BORDER -bor $WS_DLGFRAME;
  104.     $WS_SYSMENU = [int]524288;
  105.     $WS_THICKFRAME = [int]262144;
  106.     $WS_MINIMIZE = [int]536870912;
  107.     $WS_MAXIMIZEBOX = [int]65536;
  108.     $GWL_STYLE = [int]-16L;
  109.     $GWL_EXSTYLE =[int] -20L;
  110.     $WS_EX_DLGMODALFRAME = [int]0x1L;
  111.     $SWP_NOMOVE = [int]0x2;
  112.     $SWP_NOSIZE = [uint32](0x1);
  113.     $SWP_FRAMECHANGED = [uint32](0x20);
  114.     $WS_VISIBLE = [uInt32]0x10000000;
  115.     $MF_BYPOSITION =  [uint32](0x400);
  116.     $MF_REMOVE = [uint32](0x1000);
  117.     $process = ((Get-Process -name $processName)[0].MainWindowHandle);
  118.     $process2 = ((Get-Process -name $processName)[1].MainWindowHandle);
  119.  
  120.  
  121. ##########################################################################################################
  122. #   If your app doesn't have a mennu, delete this whole section
  123. ##########################################################################################################
  124.     $hmenu = [NativeMethods]::GetMenu($process);
  125.                 $count = [NativeMethods]::GetMenuItemCount($hmenu);
  126.                 for ($i = 0; $i -lt $count; $i++){
  127.                         [NativeMethods]::RemoveMenu($hmenu, 0, ($MF_BYPOSITION));
  128.                     }
  129.    
  130.     [NativeMethods]::DrawMenuBar($process);
  131.  
  132.  
  133. $hmenu = [NativeMethods]::GetMenu($process2);
  134.                 $count = [NativeMethods]::GetMenuItemCount($hmenu);
  135.                 for ($i = 0; $i -lt $count; $i++){
  136.                         [NativeMethods]::RemoveMenu($hmenu, 0, ($MF_BYPOSITION));
  137.                     }
  138.     [NativeMethods]::DrawMenuBar($process2);
  139.  
  140. ##########################################################################################################
  141.  
  142. [NativeMethods]::SetWindowLong($process, $GWL_STYLE, ($WS_VISIBLE));
  143. # InvalidateRect - Redraws window.  Needed after AnimateWindow AW_ACTIVATE
  144. [NativeMethods]::InvalidateRect($hWnd, 0, "true") | Out-Null
  145. sleep -s 1
  146.  
  147.  
  148. [NativeMethods]::SetWindowLong($process2, $GWL_STYLE, ($WS_VISIBLE));
  149. # InvalidateRect - Redraws window.  Needed after AnimateWindow AW_ACTIVATE
  150. [NativeMethods]::InvalidateRect($hWnd, 0, "true") | Out-Null
  151. sleep -s 1
  152.  
  153. ##########################################################################################################
  154. #   Position your window. Mess with top and left trim for positioning
  155. ##########################################################################################################
  156. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  157. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  158. $topTrim = 10
  159. $leftTrim = 0
  160.  
  161. $desktops = Get-WmiObject -Class Win32_DesktopMonitor
  162. #Get your monitor width/height here
  163. $sH = $desktops.ScreenHeight + $topTrim;
  164. $sW = $desktops.ScreenWidth + (($leftTrim*2));
  165.  
  166. $var = select-window $processName;
  167. $var[0].setposition( (New-Object System.Drawing.Rectangle((0),(-1 * ($topTrim)),$sW,$sH)) )
  168. $var[1].setposition( (New-Object System.Drawing.Rectangle(($sW),(-1 * ($topTrim)),$sW,$sH)) )
  169.  
  170.  
  171. $var | ForEach  { Set-WindowPosition -X (-1*$leftTrim) -Y (-1 * ($topTrim)) -Window $_ }
  172.  
  173.  
  174. $sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
  175. Add-type -MemberDefinition $sig -name NativeMethods -namespace win32
  176. $hwnd = @(get-process "emulator_multicpu")[0].MainWindowHandle
  177.  
  178. #[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)
  179. [Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)
  180.  
  181.  
  182. $hwnd = @(get-process "emulator_multicpu")[1].MainWindowHandle
  183.  
  184. #[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)
  185. [Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top