Exemplo n.º 1
0
        public void Main()
        {
            //AutoItApi._HotKey_Disable(HK_FLAG_D2STATS);

            //var hTimerUpdateDelay = AutoItApi.TimerInit();

            int timer = 0;

            bool bIsIngame = false;

            while (true)
            {
                timer++;

                var hWnd = AutoItApi.WinGetHandle("Diablo II");
                if (hWnd == (IntPtr)0)
                {
                    Thread.Sleep(500);
                    ErrorMsg = "Couldn't find Diablo II window";
                    continue;
                }

                try {
                    UpdateHandle(hWnd);
                    ErrorMsg = "";
                } catch (Exception ex) {
                    ErrorMsg = ex.Message;
                }


                if (IsIngame())
                {
                    if (!bIsIngame)
                    {
                        // Reset the notify-cache
                        Notifier.ItemCache = null;
                    }

                    InjectFunctions();

                    mouseFix.Do();
                    showItems.Do();
                    noPickup.Do(bIsIngame);
                    configAlwaysRun.Do();

                    if (timer % 5 == 0)
                    {
                        // Throttle update. This is only a workaround to get the load on the cpu from ~3% to ~1%
                        // Maybe implemente a proper wpf-implementation for the stats to fix that completle
                        statsControl.UpdateStats();
                    }

                    if (Settings.Default.notifyEnabled)
                    {
                        notifier.Do();

                        // The following implementation is not pretty but it should work good enough for now
                        NotifierLinesClearError();
                        foreach (var errorLineNumber in notifier.MatchErrorLines)
                        {
                            NotifierLineAsError(errorLineNumber);
                        }
                    }

                    bIsIngame = true;
                }
                else
                {
                    if (bIsIngame)
                    {
                        //AutoItApi.GUICtrlSetState(g_idnotifyTest, GUI_DISABLE);
                    }

                    bIsIngame        = false;
                    g_hTimerCopyName = 0;
                }

                //if (g_hTimerCopyName && AutoItApi.TimerDiff(g_hTimerCopyName) > 10000) {
                //	g_hTimerCopyName = 0;

                //	if (bIsIngame) { PrintString("Item name multi-copy expired."); }
                //}

                Thread.Sleep(200);
            }
        }