Sunday, November 13, 2016

BlueStacks Quick App Launcher

BlueStacks Quick App Launcher

For those that aren't familiar with BlueStacks (BS) it is an Android emulator for the Windows OS. BS allows you to use Android apps on your Windows computer allowing you to free up your mobile devices and also allows developers to test and create their applications while at their computers.

There are many things that can be done with BS and different ways it can be used and one feature I like is being able to run user installed apps from shortcuts in a folder. This makes it possible to run specific apps without starting BS first.

To make running apps even quicker I have created:

BlueStacks Quick App Launcher!

Usage

BlueStacks Quick App Launcher quickly lists any shortcut found in the BS App Folder and allows you to run any app in the list by selecting the app and either hitting Enter or by clicking the 'Start App' button. You can select an app by using the mouse or the directional keys.

Images & Screens

Downloads

Script - Source

; List and lauch Android apps in Bluestacks emulator.

; Init
OnMessage(0x200,"WM_MOUSEHOVER")
OnMessage(0x2a3,"WM_MOUSELEAVE")
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
RegRead,dataDir,HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks,DataDir
RegRead,installDir,HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks,InstallDir
exeLoc:=installDir "Bluestacks.exe"
If !dataDir
 {
  MsgBox,20,BlueStacks Launcher Error, % ""
   . "BlueStacks has not been found or is not installed properly.`n"
   . "Please install BlueStacks and try again.`n`n"
   . "Would you like to download the official BlueStacks from`n"
   . "their website?"
  IfMsgBox, Yes
   Gosub, Download
  ExitApp
 }
appDir:=dataDir "UserData\Library\My Apps\"
Gosub, GetAppList
If (comboList == "No User Apps")
 {
  MsgBox,20,BlueStacks Launcher Info, % ""
   . "You have not installed any user apps in BlueStacks.`n"
   . "Would you like to open BlueStacks to install some?"
  IfMsgBox, Yes
   Run, % exeLoc
 }
FileInstall,\bs-launcher-button.png, % A_Temp "\bs-launcher-button.png"
FileInstall,,\bs-launcher-button-start.png, % A_Temp "\bs-launcher-button-start.png"
; Vars
bsExe:=FileExist(installDir "HD-StartLauncher.exe")
?installDir "HD-StartLauncher.exe"
:installDir "Bluestacks.exe"
lastList:=GetAppList()
gtitle:="BlueStacks Quick App Launcher"
buttonL:=A_Temp "\bs-launcher-button.png"
buttonS:=A_Temp "\bs-launcher-button-start.png"
minW:=300

; Build menus, intial loops and guis here
Menu, Tray, NoStandard
Menu, Tray, Add, &Download BlueStacks,Download
Menu, Tray, Add
Menu, Tray, Add, E&xit BlueStacks QAL,GuiClose

Gui, Color, 0xFFFFFF, 0xFEFEFA
Gui, Font, c0x3B5297 s13 , Segoe UI
Gui, Add, Text, w%minW%, Installed user apps in BlueStacks.
Gui, Font, c0x1D1D1D s11
Gui, Add, Combobox, xp y+8 vChoice Choose1 w%minW% 0x401, % GetAppList()
Gui, Show, AutoSize, % gtitle
ControlGetPos,,,cb1w,,Combobox1, % gtitle
Gui, Hide
bWidth:=cb1w
Gui, Add, Picture, w%bWidth% h-1 gButtonStartApp +BackgroundTrans, % buttonL
Gui, Add, Picture, w%bWidth% h-1 y+0 gButtonStartBS +BackgroundTrans, % buttonS
Gui, Show, AutoSize, % gtitle
Gui, +LastFound +HwndMainHwnd
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(MainHwnd,tme,8)
GetControls(gtitle)
SetTimer, ReCheck, 3000
Send, {Right}
; End auto execute
Return

; Hotkeys
;!r::Reload
#IfWinActive, BlueStacks Quick App Launcher
~Down::Send, {Down}{Right}
~Up::Send, {Up}{Right}
Enter::Gosub, ButtonStartApp
#IfWinActive
; Functions
#Include, ,\WinGuiLib.ahk
WM_MOUSELEAVE(){
 ToolTip
}
WM_MOUSEHOVER(){
 Global
 Local over
 over:=MouseOver(CB1X,CB1Y,CB1X2,CB1Y2)?1
 :0
 If (over == 1){
  ComboMsg()
 }
 If !over {
  ToolTip
  DllCall( "TrackMouseEvent","uint",&tme )
 }
}
GetAppList(){
 fcounter=0
 Global appDir,lnkList
 lnkList:=""
 Loop, % appDir "*.lnk"
  { 
   If (A_LoopFileExt == "lnk")
    {
     fcounter++
     If !lnkList
      lnkList:=Object()
     lnkList.Push(A_LoopFileName)
     shortName:=SubStr(lnkList[A_Index],1,StrLen(lnkList[A_Index])-4)
     comboList.=fcounter " - " shortName "|"
    }
  }
 If (comboList != lastList && comboList)
  comboList:=SubStr(comboList,1,StrLen(comboList)-1)
 Else
  comboList:="No User Apps"
 Return comboList
}
ComboMsg(){
 Static counter
 counter++
 If mod(counter,2)
  {
   Sleep, 3000
   SetTimer, KillTT, -4500
   ToolTip % "You can press [Enter] to start an app...`n"
      . "This list auto-updates..."
  }
}
; Classes


; Subs
KillTT:
 ToolTip
Return
ButtonStartApp:
 Gui, Submit, NoHide
 index:=SubStr(Choice,1,1)
 Run, % appDir lnkList[index]
 TrayTip, % gtitle " Info", % "Starting " SubStr(Choice,5)
Return
ButtonStartBS:
 Run, % bsExe
 TrayTip, % gtitle " Info", Starting BlueStacks...
Return
ReCheck:
 thisList:=GetAppList()
 If (lastList != thisList)
  {
   GuiControl, ,Combobox1,% "|" GetAppList()
   IfWinActive, % gtitle
    {
     ControlFocus,Combobox1, % gtitle
     Sleep, 150
     Send, {Down}{Right}
    }
   Else
    {
     WinActivate,  % gtitle
     ControlFocus,Combobox1, % gtitle
     Sleep, 150
     Send, {Down}{Right}
    }
  }
 lastList:=GetAppList()
Return
GetAppList:
fcounter=0
Loop, % appDir "*.lnk"
 { 
  If (A_LoopFileExt == "lnk")
   {
    fcounter++
    If !lnkList
     lnkList:=Object()
    lnkList.Push(A_LoopFileName)
    shortName:=SubStr(lnkList[A_Index],1,StrLen(lnkList[A_Index])-4)
    comboList.=fcounter " - " shortName "|"
   }
 }
If comboList
 comboList:=SubStr(comboList,1,StrLen(comboList)-1)
Else
 comboList:="No User Apps"
Return
Download:
 Run, http://www.bluestacks.com/download.html
Return
GuiClose:
 ExitApp

No comments: