Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 当从Android Studio运行我的应用程序时,我可以强制将模拟器置于顶部吗?_Windows_Android Studio_Android Emulator - Fatal编程技术网

Windows 当从Android Studio运行我的应用程序时,我可以强制将模拟器置于顶部吗?

Windows 当从Android Studio运行我的应用程序时,我可以强制将模拟器置于顶部吗?,windows,android-studio,android-emulator,Windows,Android Studio,Android Emulator,这是一个相当小的不便,但我希望当我开始从Android Studio运行我的应用程序时,Android Emulator会出现在最前面 我知道emulator中的“始终在顶部”设置,但在编写代码时,我必须最小化emulator。运行我的应用程序不会还原模拟器。我已经尝试了一段时间了。。。我想这是办不到的 我通过购买另一台显示器并将模拟器推到另一台显示器上解决了这个问题。为我的问题创建了一个解决方案-我正在Windows 10上开发。 创建PowerShell批处理文件BringProcessTo

这是一个相当小的不便,但我希望当我开始从Android Studio运行我的应用程序时,Android Emulator会出现在最前面


我知道emulator中的“始终在顶部”设置,但在编写代码时,我必须最小化emulator。运行我的应用程序不会还原模拟器。

我已经尝试了一段时间了。。。我想这是办不到的


我通过购买另一台显示器并将模拟器推到另一台显示器上解决了这个问题。

为我的问题创建了一个解决方案-我正在Windows 10上开发。

  • 创建PowerShell批处理文件BringProcessToFront.ps1(*注意,您的仿真器可能有不同的名称,如qemu-system-x86_64*)

  • 确保您可以从命令行实际运行此脚本。默认安全性不允许您运行脚本,作为管理员,您需要允许它们使用 如果一切正常(模拟器正在运行),它将弹出到前端

    powershell -command C:\users\username\BringProcessToFront.ps1
    
  • 在Android Studio中创建一个新的外部工具“Bringemulatorofront”

  • 运行你的应用程序,并观看模拟器弹出到前面


  • 下面的@Ves accepted answer确实有效,但更改了批处理文件,因为它不适合我,下面是我如何根据另一个答案编辑批处理文件BringProcessToFront.ps1

    然后,我按照已接受答案中的其余步骤进行操作,结果成功了。

    我使用了一个非常简单的脚本:

    #IfWinActive, ahk_class SunAwtFrame
    $+F10::
    Send, +{F10}
    WinActivate, Android Emulator
    return
    
    这将运行应用程序,并在您按F10时激活上次使用的仿真器


    您也可以编译此文件并让其在未安装AutoHotkey的情况下运行。

    请参阅我的答案-了解如何在windows上执行此操作。必须能够在所有平台上执行类似操作。
    Run>Edit Configuraions
    Expand Android App and select app
    Before launch:  (Hit the green + sign to add a new external tool)
       In the "External Tools Dialog" hit the green + to create a new tool)
           Name: BringEmulatorToFront
           Description: Launch PowerShell to make sure Emulator is visible
           Program: powershell
           Arguments: -command C:\users\username\BringProcessToFront.ps1
           Working directory: C:\users\username
           *IMPORTANT*
            Uncheck the Advanced options Synchronize files and Open console
            (If you leave Open console checked your run will not terminate cleanly)           
    
    if ( $args ){
       $processName = $args[0]
    }
    else{
       $processName = "qemu-system-i386"
    }
    
    Add-Type @"
      using System;
      using System.Runtime.InteropServices;
      public class Tricks {
         [DllImport("user32.dll")]
         [return: MarshalAs(UnmanagedType.Bool)]
         public static extern bool SetForegroundWindow(IntPtr hWnd);
      }
    "@
    sleep -sec 1
    $h = (Get-Process $processName).MainWindowHandle
    [void] [Tricks]::SetForegroundWindow($h)
    
    #IfWinActive, ahk_class SunAwtFrame
    $+F10::
    Send, +{F10}
    WinActivate, Android Emulator
    return