Ejemplo n.º 1
0
 private void LaunchDiskCompaction(object sender, MouseButtonEventArgs e)
 {
     try
     {
         this.ParentWindow.mFrontendHandler.IsRestartFrontendWhenClosed = false;
         BlueStacksUIUtils.HideUnhideBlueStacks(true);
         using (Process process = new Process())
         {
             process.StartInfo.FileName  = System.IO.Path.Combine(RegistryStrings.InstallDir, "DiskCompactionTool.exe");
             process.StartInfo.Arguments = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "-vmname:{0} -relaunch", (object)this.ParentWindow.mVmName);
             process.Start();
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Exception in starting disk compaction" + ex.ToString());
     }
 }
Ejemplo n.º 2
0
        private static IntPtr KeyboardHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            try
            {
                if (GlobalKeyBoardMouseHooks.sIsEnableKeyboardHookLogging)
                {
                    Logger.Info("Keyboard hook .." + nCode.ToString() + ".." + wParam.ToString() + ".." + lParam.ToString());
                }
                MainWindow window = BlueStacksUIUtils.ActivatedWindow;
                if (nCode >= 0)
                {
                    if (!(wParam == (IntPtr)256) && !(wParam == (IntPtr)260))
                    {
                        if (!(wParam == (IntPtr)257))
                        {
                            goto label_19;
                        }
                    }
                    int virtualKey = Marshal.ReadInt32(lParam);
                    Logger.Debug("Keyboard hook .." + virtualKey.ToString() + ".." + GlobalKeyBoardMouseHooks.sKey);
                    if (!(wParam == (IntPtr)256))
                    {
                        if (!(wParam == (IntPtr)260))
                        {
                            goto label_19;
                        }
                    }
                    if (!string.IsNullOrEmpty(GlobalKeyBoardMouseHooks.sKey) && (Keys)virtualKey == (Keys)Enum.Parse(typeof(Keys), GlobalKeyBoardMouseHooks.sKey, false) && (GlobalKeyBoardMouseHooks.sIsControlUsedInBossKey ? 1 : 0) == (Keyboard.IsKeyDown(Key.LeftCtrl) ? 1 : (Keyboard.IsKeyDown(Key.RightCtrl) ? 1 : 0)) && ((GlobalKeyBoardMouseHooks.sIsAltUsedInBossKey ? 1 : 0) == (Keyboard.IsKeyDown(Key.LeftAlt) ? 1 : (Keyboard.IsKeyDown(Key.RightAlt) ? 1 : 0)) && (GlobalKeyBoardMouseHooks.sIsShiftUsedInBossKey ? 1 : 0) == (Keyboard.IsKeyDown(Key.LeftShift) ? 1 : (Keyboard.IsKeyDown(Key.RightShift) ? 1 : 0))))
                    {
                        ThreadPool.QueueUserWorkItem((WaitCallback)(obj =>
                        {
                            if (BlueStacksUIUtils.DictWindows.Values.Count <= 0)
                            {
                                return;
                            }
                            MainWindow mainWindow = BlueStacksUIUtils.DictWindows.Values.ToList <MainWindow>()[0];
                            mainWindow.Dispatcher.Invoke((Delegate)(() =>
                            {
                                try
                                {
                                    if (mainWindow.OwnedWindows.OfType <OnBoardingPopupWindow>().Any <OnBoardingPopupWindow>() || mainWindow.OwnedWindows.OfType <GameOnboardingControl>().Any <GameOnboardingControl>())
                                    {
                                        return;
                                    }
                                    GlobalKeyBoardMouseHooks.mIsHidden = !GlobalKeyBoardMouseHooks.mIsHidden;
                                    BlueStacksUIUtils.HideUnhideBlueStacks(GlobalKeyBoardMouseHooks.mIsHidden);
                                }
                                catch
                                {
                                }
                            }));
                        }));
                        return((IntPtr)1);
                    }
                    if (window != null)
                    {
                        if (!Keyboard.IsKeyDown(Key.LeftCtrl))
                        {
                            if (!Keyboard.IsKeyDown(Key.RightCtrl))
                            {
                                goto label_19;
                            }
                        }
                        if (!Keyboard.IsKeyDown(Key.LeftAlt))
                        {
                            if (!Keyboard.IsKeyDown(Key.RightAlt))
                            {
                                goto label_19;
                            }
                        }
                        if (virtualKey >= 96 && virtualKey <= 105)
                        {
                            virtualKey -= 48;
                        }
                        string vkString = IMAPKeys.GetStringForFile(KeyInterop.KeyFromVirtualKey(virtualKey));
                        if (MainWindow.sMacroMapping.Keys.Contains <string>(vkString))
                        {
                            ThreadPool.QueueUserWorkItem((WaitCallback)(obj =>
                            {
                                try
                                {
                                    window.Dispatcher.Invoke((Delegate)(() =>
                                    {
                                        if (window.mSidebar.GetElementFromTag("sidebar_macro") != null && window.mSidebar.GetElementFromTag("sidebar_macro").Visibility == Visibility.Visible && window.mSidebar.GetElementFromTag("sidebar_macro").IsEnabled)
                                        {
                                            if (window.mIsMacroRecorderActive)
                                            {
                                                window.ShowToast(LocaleStrings.GetLocalizedString("STRING_STOP_RECORDING_FIRST", ""), "", "", false);
                                            }
                                            else if (window.mIsMacroPlaying)
                                            {
                                                CustomMessageWindow customMessageWindow = new CustomMessageWindow();
                                                BlueStacksUIBinding.Bind(customMessageWindow.TitleTextBlock, "STRING_CANNOT_RUN_MACRO", "");
                                                BlueStacksUIBinding.Bind(customMessageWindow.BodyTextBlock, "STRING_STOP_MACRO_SCRIPT", "");
                                                customMessageWindow.AddButton(ButtonColors.Blue, "STRING_OK", (EventHandler)null, (string)null, false, (object)null, true);
                                                customMessageWindow.Owner = (Window)window;
                                                customMessageWindow.ShowDialog();
                                            }
                                            else
                                            {
                                                try
                                                {
                                                    string path = Path.Combine(RegistryStrings.MacroRecordingsFolderPath, MainWindow.sMacroMapping[vkString] + ".json");
                                                    if (!File.Exists(path))
                                                    {
                                                        return;
                                                    }
                                                    MacroRecording record = JsonConvert.DeserializeObject <MacroRecording>(File.ReadAllText(path), Utils.GetSerializerSettings());
                                                    record.Name = MainWindow.sMacroMapping[vkString];
                                                    window.mCommonHandler.FullMacroScriptPlayHandler(record);
                                                    ClientStats.SendMiscellaneousStatsAsync("MacroOperations", RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, "macro_play", "shortcut_keys", record.RecordingType.ToString(), string.IsNullOrEmpty(record.MacroId) ? "local" : "community", (string)null, (string)null, "Android");
                                                }
                                                catch (Exception ex)
                                                {
                                                    Logger.Error("Exception in macro play with shortcut: " + ex.ToString());
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Logger.Info("Macro not enabled for the current package: " + window.StaticComponents.mSelectedTabButton.PackageName);
                                        }
                                    }));
                                }
                                catch
                                {
                                }
                            }));
                        }
                    }
                }
            }
            catch
            {
            }
label_19:
            return(NativeMethods.CallNextHookEx(GlobalKeyBoardMouseHooks.mKeyboardHookID, nCode, wParam, lParam));
        }