コード例 #1
0
ファイル: ViewPort.cs プロジェクト: johnsewell/APE
        protected override void WndProc(ref Message msg)
        {
            if (msg.Msg == NM.WM_HOTKEY)
            {
                if (!Processing)
                {
                    Processing = true;
                    if (msg.WParam.ToInt32() == 1)
                    {
                        if (Foreground != IntPtr.Zero)
                        {
                            if (!NM.SetForegroundWindow(Foreground))
                            {
                                //Foreground = IntPtr.Zero;
                                throw new Exception("SetForegroundWindow failed");
                            }
                        }
                        else
                        {
                            Break();
                        }
                    }
                    Processing = false;
                }
            }

            base.WndProc(ref msg);
        }
コード例 #2
0
ファイル: FormHelper.cs プロジェクト: robguyoncourt/APE
        private bool EnumWindowsToGetToolTips(IntPtr hWnd, IntPtr lParam)
        {
            uint pid;

            NM.GetWindowThreadProcessId(hWnd, out pid);

            uint currentProcessId = (uint)AUTProcess.Id;

            if (pid == currentProcessId)
            {
                if (NM.IsWindowVisible(hWnd))
                {
                    NM.tagRect WindowSize;
                    NM.GetClientRect(hWnd, out WindowSize);
                    if (WindowSize.right > 0)   //If the window has 0 width then ignore it
                    {
                        string className = NM.GetClassName(hWnd);
                        if (className.Contains("tooltips_class"))
                        {
                            m_ToolTipWindows.Add(hWnd);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: VfW.cs プロジェクト: johnsewell/APE
        public static void Close()
        {
            // Free unmanaged memory
            if (m_FlippedFrameBuffer != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(m_FlippedFrameBuffer);
                m_FlippedFrameBuffer = IntPtr.Zero;
            }

            // Release the compressed stream
            if (m_StreamCompressed != IntPtr.Zero)
            {
                NM.AVIStreamRelease(m_StreamCompressed);
                m_StreamCompressed = IntPtr.Zero;
            }

            // Release the stream
            if (m_Stream != IntPtr.Zero)
            {
                NM.AVIStreamRelease(m_Stream);
                m_Stream = IntPtr.Zero;
            }

            // Release the file
            if (m_File != IntPtr.Zero)
            {
                NM.AVIFileRelease(m_File);
                m_File = IntPtr.Zero;
            }
        }
コード例 #4
0
ファイル: VfW.cs プロジェクト: johnsewell/APE
        public static void AddFrame(Bitmap frameImage)
        {
            // Lock the bitmap
            BitmapData imageData = frameImage.LockBits(new Rectangle(0, 0, m_Width, m_Height), ImageLockMode.ReadOnly, frameImage.PixelFormat);

            // Copy and flip the frame
            IntPtr pSourceScanline      = imageData.Scan0 + m_Stride * (m_Height - 1);
            IntPtr pDestinationScanline = m_FlippedFrameBuffer;
            IntPtr pStride = new IntPtr(m_Stride);

            for (int y = 0; y < m_Height; y++)
            {
                NM.memcpy(pDestinationScanline, pSourceScanline, pStride);
                pDestinationScanline += m_Stride;
                pSourceScanline      -= m_Stride;
            }

            // Unlock the bitmap
            frameImage.UnlockBits(imageData);;

            // Write the frame to the stream
            if (NM.AVIStreamWrite(m_StreamCompressed, m_CurrentFrame, 1, m_FlippedFrameBuffer, m_Stride * m_Height, 0, IntPtr.Zero, IntPtr.Zero) != 0)
            {
                throw new Exception("Failed to add frame");
            }

            m_CurrentFrame++;
        }
コード例 #5
0
ファイル: APE.Spy.cs プロジェクト: johnsewell/APE
        private bool EnumProc(IntPtr hWnd, IntPtr lParam)
        {
            uint Pid;

            NM.GetWindowThreadProcessId(hWnd, out Pid);

            if (new IntPtr(Pid) == lParam)
            {
                if (NM.IsWindowVisible(hWnd))
                {
                    NM.tagRect WindowSize;
                    NM.GetClientRect(hWnd, out WindowSize);

                    if (WindowSize.right > 0)   //If the window has 0 width then ignore it
                    {
                        TreeNode ParentNode;
                        GetIdentity(IntPtr.Zero, hWnd);
                        string APEType = GetAPEType(m_Identity);
                        ListOfTopLevelWindows.Add(hWnd, m_Identity.Name);
                        if (m_Identity.TechnologyType == "Windows Native")
                        {
                            ParentNode = WindowTree.Nodes.Add("0:" + hWnd.ToString(), APEType + " (Windows Native) [" + hWnd.ToString() + "]");
                        }
                        else
                        {
                            ParentNode = WindowTree.Nodes.Add("0:" + hWnd.ToString(), APEType + " " + m_Identity.Name + " [" + hWnd.ToString() + "]");
                        }
                        AddChildNode(hWnd, ParentNode, hWnd);
                    }
                }
            }
            return(true);
        }
コード例 #6
0
        public static bool UnsetTimerResolution()
        {
            bool Succeed = false;

            lock (m_ResolutionLock)
            {
                if (m_ResolutionSet)
                {
                    uint currentResolution;
                    uint result = NM.NtSetTimerResolution(m_TimerResolution, false, out currentResolution);

                    switch (result)
                    {
                    case NM.STATUS_SUCCESS:
                        m_ResolutionSet = false;
                        Succeed         = true;
                        break;

                    default:
                        break;
                    }
                }
            }

            return(Succeed);
        }
コード例 #7
0
ファイル: ComboBox.cs プロジェクト: robguyoncourt/APE
        /// <summary>
        /// Returns the number of items in the combo box
        /// </summary>
        /// <returns>The number of items</returns>
        public int ItemCount()
        {
            IntPtr messageResult;
            IntPtr sendResult;
            int    itemCount = -1;

            Stopwatch timer = Stopwatch.StartNew();

            while (true)
            {
                sendResult = NM.SendMessageTimeout(Identity.Handle, NM.ComboBoxMessages.CB_GETCOUNT, IntPtr.Zero, IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, GUI.m_APE.TimeOut, out messageResult);
                itemCount  = unchecked ((int)messageResult.ToInt64());
                if (sendResult == IntPtr.Zero)
                {
                    throw GUI.ApeException("Failed to access the " + Description);
                }

                if (itemCount != NM.CB_ERR)
                {
                    break;
                }

                if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                {
                    throw GUI.ApeException("Failed to get the number of items in the " + Description);
                }

                Thread.Sleep(50);
            }

            return(itemCount);
        }
コード例 #8
0
ファイル: APE.Spy.cs プロジェクト: johnsewell/APE
        private void WindowTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            m_ControlKey         = true;
            LocateButton.Enabled = true;

            string[] SplitCharacters = { ":" };
            string[] Handles         = WindowTree.SelectedNode.Name.Split(SplitCharacters, StringSplitOptions.None);

            IntPtr Parent = new IntPtr(int.Parse(Handles[0]));
            IntPtr Handle = new IntPtr(int.Parse(Handles[1]));

            if (NM.IsWindow(Handle))
            {
                PopulatePropertyListbox(Parent, Handle);
            }
            else
            {
                PropertyListbox.Items.Clear();
                if (m_CurrentAttached.Key.HasExited)
                {
                    WinformsProcessesCombobox.SelectedIndex = 0;
                    Populate();
                }
                else
                {
                    BuildTree();
                }
            }
        }
コード例 #9
0
ファイル: Form.cs プロジェクト: johnsewell/APE
 /// <summary>
 /// Get the forms window state
 /// </summary>
 /// <returns>The window state</returns>
 private string FormWindowState()
 {
     if (NM.IsWindow(Identity.Handle))
     {
         if (NM.IsWindowVisible(Identity.Handle))
         {
             // Get the windows current state
             GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
             GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "WindowState", MemberTypes.Property);
             GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "ToString", MemberTypes.Method);
             GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
             GUI.m_APE.SendMessages(EventSet.APE);
             GUI.m_APE.WaitForMessages(EventSet.APE);
             //Get the value(s) returned MUST be done straight after the WaitForMessages call
             string windowState = GUI.m_APE.GetValueFromMessage();
             return(windowState);
         }
         else
         {
             throw new Exception("Form is not visible");
         }
     }
     else
     {
         throw new Exception("Form does not exist");
     }
 }
コード例 #10
0
ファイル: CheckBox.cs プロジェクト: robguyoncourt/APE
        private bool GetState()
        {
            //Get the state of the checkbox
            switch (Identity.TechnologyType)
            {
            case "Windows Forms (WinForms)":
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "Checked", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store1);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                //Get the value(s) returned MUST be done straight after the WaitForMessages call
                return(GUI.m_APE.GetValueFromMessage());

            default:
                IntPtr messageResult;
                IntPtr sendResult;
                sendResult = NM.SendMessageTimeout(Identity.Handle, NM.BM_GETCHECK, IntPtr.Zero, IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, (uint)GUI.GetTimeOut(), out messageResult);
                if (sendResult != IntPtr.Zero)      //Succeeded
                {
                    if (messageResult == new IntPtr(NM.BST_CHECKED))
                    {
                        return(true);
                    }
                    return(false);
                }
                throw GUI.ApeException("Failed to query the " + Description);
            }
        }
コード例 #11
0
        public void AppbarNew(AppBarEdges Edge)
        {
            if (!m_IsAppbarDocked)
            {
                if (m_CallbackMessageID == 0)
                {
                    throw new Exception("CallbackMessageID is 0");
                }

                m_Edge = Edge;

                m_OriginalSize     = this.Size;
                m_OriginalLocation = this.Location;
                m_PrevBorderStyle  = this.FormBorderStyle;

                this.FormBorderStyle = FormBorderStyle.None;

                // prepare data structure of message
                NM.APPBARDATA msgData = new NM.APPBARDATA();
                msgData.cbSize           = (UInt32)Marshal.SizeOf(msgData);
                msgData.hWnd             = this.Handle;
                msgData.uCallbackMessage = m_CallbackMessageID;

                // install new appbar
                UIntPtr Return = NM.SHAppBarMessage(NM.AppBarMessages.New, ref msgData);
                if (Return == UIntPtr.Zero)
                {
                    throw new Exception("Failed to add AppBar");
                }
                m_IsAppbarDocked = true;

                SizeAppBar();
            }
        }
コード例 #12
0
ファイル: Parameter.cs プロジェクト: robguyoncourt/APE
        public Parameter(APEIPC instance, string param)
        {
            Message *PtrMessage = instance.GetPointerToNextMessage();

            if (param != null)
            {
                int length = param.Length * 2;  //UTF16 charcter: For a 4 byte surrogate pair, length actually returns 2 somewhat confusingly although its convenient for us here, so we can just use length * 2
                CheckSize(instance, length);
                fixed(void *PtrString = param)
                {
                    NM.CopyMemory(instance.m_IntPtrMemoryMappedFileViewStringStore + instance.m_StringStoreOffset, (IntPtr)PtrString, (UIntPtr)(length));
                }

                PtrMessage->Parameter.StringOffset[PtrMessage->NumberOfParameters] = instance.m_StringStoreOffset;
                PtrMessage->Parameter.StringLength[PtrMessage->NumberOfParameters] = param.Length;
                instance.m_StringStoreOffset = instance.m_StringStoreOffset + (param.Length * 2);
            }
            else
            {
                PtrMessage->Parameter.StringOffset[PtrMessage->NumberOfParameters] = -1;
                PtrMessage->Parameter.StringLength[PtrMessage->NumberOfParameters] = -1;
            }

            PtrMessage->Parameter.TypeCode[PtrMessage->NumberOfParameters]      = (int)ApeTypeCode.String;
            PtrMessage->Parameter.ParameterType[PtrMessage->NumberOfParameters] = (int)ParameterType.In;
            PtrMessage->TypeCodeKey += ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + (int)ApeTypeCode.String) + ((PtrMessage->NumberOfParameters * OneLargerThanApeTypeCodeEnumMax * 2) + OneLargerThanApeTypeCodeEnumMax + (int)ParameterType.In);
            PtrMessage->NumberOfParameters++;
        }
コード例 #13
0
        private void AppbarQueryPos(ref NM.tagRect appRect)
        {
            float ScreenScalingFactor;

            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                IntPtr desktop              = g.GetHdc();
                int    LogicalScreenHeight  = NM.GetDeviceCaps(desktop, NM.DeviceCap.VERTRES);
                int    PhysicalScreenHeight = NM.GetDeviceCaps(desktop, NM.DeviceCap.DESKTOPVERTRES);
                g.ReleaseHdc();
                ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;
            }

            // prepare data structure of message
            NM.APPBARDATA msgData = new NM.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd   = Handle;
            msgData.uEdge  = (UInt32)m_Edge;
            msgData.rc     = appRect;

            // query postion for the appbar
            msgData.rc.left   = (int)(Math.Round((float)msgData.rc.left * ScreenScalingFactor));
            msgData.rc.right  = (int)(Math.Round((float)msgData.rc.right * ScreenScalingFactor));
            msgData.rc.top    = (int)(Math.Round((float)msgData.rc.top * ScreenScalingFactor));
            msgData.rc.bottom = (int)(Math.Round((float)msgData.rc.bottom * ScreenScalingFactor));

            NM.SHAppBarMessage(NM.AppBarMessages.QueryPos, ref msgData);

            msgData.rc.left   = (int)(Math.Round((float)msgData.rc.left / ScreenScalingFactor));
            msgData.rc.right  = (int)(Math.Round((float)msgData.rc.right / ScreenScalingFactor));
            msgData.rc.top    = (int)(Math.Round((float)msgData.rc.top / ScreenScalingFactor));
            msgData.rc.bottom = (int)(Math.Round((float)msgData.rc.bottom / ScreenScalingFactor));

            appRect = msgData.rc;
        }
コード例 #14
0
ファイル: ComboBoxExHelper.cs プロジェクト: robguyoncourt/APE
        private unsafe void GetComboBoxExItemText(Message *ptrMessage, int messageNumber)
        {
            //must be first message
            if (messageNumber != 1)
            {
                throw new Exception("GetComboBoxExItemText must be first message");
            }

            IntPtr handle      = GetParameterIntPtr(ptrMessage, 0);
            int    index       = GetParameterInt32(ptrMessage, 1);
            string description = GetParameterString(ptrMessage, 2);

            CleanUpMessage(ptrMessage);

            IntPtr sendResult;
            IntPtr messageResult;

            //Work out if the control is unicode or not
            bool ASCII = false;

            sendResult = NM.SendMessageTimeout(handle, NM.CBEM_GETUNICODEFORMAT, IntPtr.Zero, IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, this.TimeOut, out messageResult);
            if (sendResult == IntPtr.Zero) //Failed
            {
                throw new Exception("Failed to get the character format of the " + description);
            }
            if (messageResult == IntPtr.Zero)
            {
                ASCII = true;
            }

            //Get the item text
            NM.ComboBoxExItem item = new NM.ComboBoxExItem();
            item.iItem      = new IntPtr(index);
            item.mask       = NM.CBEIF_TEXT;
            item.pszText    = new string(' ', 1001);
            item.cchTextMax = 1000;

            if (ASCII)
            {
                sendResult = NM.SendMessageTimeout(handle, NM.CBEM_GETITEMA, IntPtr.Zero, ref item, NM.SendMessageTimeoutFlags.SMTO_NORMAL, this.TimeOut, out messageResult);
                if (sendResult == IntPtr.Zero || messageResult == IntPtr.Zero) //Failed
                {
                    throw new Exception("Failed to get the text of the item in the " + description);
                }

                byte[] bytes = Encoding.Unicode.GetBytes(item.pszText);
                string ascii = Encoding.ASCII.GetString(bytes);
                AddReturnValue(new Parameter(this, ascii.Substring(0, ascii.IndexOf('\0'))));
            }
            else
            {
                sendResult = NM.SendMessageTimeout(handle, NM.CBEM_GETITEMW, IntPtr.Zero, ref item, NM.SendMessageTimeoutFlags.SMTO_NORMAL, this.TimeOut, out messageResult);
                if (sendResult == IntPtr.Zero || messageResult == IntPtr.Zero) //Failed
                {
                    throw new Exception("Failed to get the text of the item in the " + description);
                }

                AddReturnValue(new Parameter(this, item.pszText.Substring(0, item.pszText.IndexOf('\0'))));
            }
        }
コード例 #15
0
 private static void MoveMouse(int x, int y)
 {
     NM.INPUT[] MouseEvent = new NM.INPUT[1];
     MouseEvent[0].type = NM.INPUT_TYPE.INPUT_MOUSE;
     MouseEvent[0].U.mi = CreateMouseInput(x, y, 0, 0, NM.MOUSEEVENTF.ABSOLUTE | NM.MOUSEEVENTF.MOVE);
     NM.SendInput((uint)MouseEvent.Length, MouseEvent, Marshal.SizeOf(MouseEvent[0].GetType()));
 }
コード例 #16
0
        /// <summary>
        /// Stops capturing the debug string
        /// </summary>
        public static void StopCapture()
        {
            lock (m_SyncRoot)
            {
                if (m_Capturer == null)
                {
                    throw new ObjectDisposedException("DebugString", "This DebugString is not running.");
                }
                m_Capturer = null;
                NM.PulseEvent(m_ReadyEvent);
                while (m_AckEvent != IntPtr.Zero)
                {
                    Thread.Yield();
                }
            }

            //compress the file
            m_tw.Close();

            using (FileStream fs = new FileStream(Path.GetDirectoryName(m_Filename) + @"\" + Path.GetFileNameWithoutExtension(m_Filename) + @".zip", FileMode.Create))
            {
                using (ZipArchive zipfile = new ZipArchive(fs, ZipArchiveMode.Create))
                {
                    zipfile.CreateEntryFromFile(Path.GetDirectoryName(m_Filename) + @"\" + Path.GetFileNameWithoutExtension(m_Filename) + @".txt", Path.GetFileNameWithoutExtension(m_Filename) + @".txt", CompressionLevel.Optimal);
                }
            }

            File.Delete(Path.GetDirectoryName(m_Filename) + @"\" + Path.GetFileNameWithoutExtension(m_Filename) + @".txt");
        }
コード例 #17
0
        public static bool SetTimerResolution(uint timerResolutionNs)
        {
            bool Succeed = false;

            lock (m_ResolutionLock)
            {
                if (!m_ResolutionSet)
                {
                    uint maximumResolution = GetMaximumTimerResolution();

                    if (timerResolutionNs >= maximumResolution)
                    {
                        uint currentResolution;
                        uint result = NM.NtSetTimerResolution(timerResolutionNs, true, out currentResolution);

                        switch (result)
                        {
                        case NM.STATUS_SUCCESS:
                            m_TimerResolution = timerResolutionNs;
                            m_ResolutionSet   = true;
                            Succeed           = true;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            return(Succeed);
        }
コード例 #18
0
        internal static Process GetParentProcess(Process process)
        {
            int     pid              = process.Id;
            Process parentProc       = null;
            IntPtr  handleToSnapshot = IntPtr.Zero;

            try
            {
                NM.ProcessEntry32 procEntry = new NM.ProcessEntry32();
                procEntry.dwSize = (uint)Marshal.SizeOf(typeof(NM.ProcessEntry32));
                handleToSnapshot = NM.CreateToolhelp32Snapshot(NM.ToolHelpCreateSnapshotFlags.Process, 0);
                if (NM.Process32First(handleToSnapshot, ref procEntry))
                {
                    do
                    {
                        if (pid == procEntry.th32ProcessID)
                        {
                            parentProc = Process.GetProcessById((int)procEntry.th32ParentProcessID);
                            break;
                        }
                    }while (NM.Process32Next(handleToSnapshot, ref procEntry));
                }
                else
                {
                    throw GUI.ApeException("Failed with win32 error code " + Marshal.GetLastWin32Error().ToString());
                }
            }
            finally
            {
                NM.CloseHandle(handleToSnapshot);
            }
            return(parentProc);
        }
コード例 #19
0
        /// <summary>
        /// Gets the parameters from the message then adds a mouse hook to the specified thread
        /// </summary>
        /// <param name="ptrMessage">A pointer to the message</param>
        /// <param name="messageNumber">The message number</param>
        private unsafe void AddMouseHook(Message *ptrMessage, int messageNumber)
        {
            if (messageNumber != 1)
            {
                throw new Exception("AddMouseHook must be the first message");
            }

            IntPtr handle = GetParameterIntPtr(ptrMessage, 0);

            CleanUpMessage(ptrMessage);

            int threadId = NM.GetWindowThreadProcessId(handle, IntPtr.Zero);

            m_HookWindow = handle;

            // Add the mouse hook
            DebugLogging.WriteLog("Adding Mouse hook");
            m_hMouseHook = NM.SetWindowsHookEx(NM.WH_MOUSE, MouseHookProcedure, IntPtr.Zero, threadId);
            if (m_hMouseHook == 0)
            {
                throw new Exception("SetWindowsHookEx failed to add mouse hook");
            }
            DebugLogging.WriteLog("Added Mouse hook");

            ClearMouseState();
        }
コード例 #20
0
ファイル: TabControl.cs プロジェクト: robguyoncourt/APE
        private ScalingMode TabStripScalingMode()
        {
            IntPtr containerHandle = NM.GetAncestor(Handle, NM.GetAncestorFlags.GetParent);

            NM.tagPoint containerClientPoint = new NM.tagPoint();
            NM.ClientToScreen(containerHandle, ref containerClientPoint);

            NM.tagPoint clientPoint = new NM.tagPoint();
            NM.ClientToScreen(Handle, ref clientPoint);

            int containerOffsetX = clientPoint.x - containerClientPoint.x;
            int containerOffsetY = clientPoint.y - containerClientPoint.y;

            int placement = TabStripPlacement();

            switch (placement)
            {
            case 0:     //Top
            case 1:     //Bottom
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "ClientLeft", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store1);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                //Get the value(s) returned MUST be done straight after the WaitForMessages call
                int clientLeft = (int)(Math.Round(GUI.m_APE.GetValueFromMessage()));
                if (clientLeft - containerOffsetX < 10)
                {
                    return(ScalingMode.Pixel);
                }
                if (TwipsToPixels(clientLeft, Direction.Horizontal) - containerOffsetX < 10)
                {
                    return(ScalingMode.Twip);
                }
                throw GUI.ApeException("Unsupported scaling mode");

            case 2:     //Left
            case 3:     //Right
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "ClientTop", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store1);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                //Get the value(s) returned MUST be done straight after the WaitForMessages call
                int clientTop = (int)(Math.Round(GUI.m_APE.GetValueFromMessage()));
                if (clientTop - containerOffsetY < 10)
                {
                    return(ScalingMode.Pixel);
                }
                if (TwipsToPixels(clientTop, Direction.Vertical) - containerOffsetY < 10)
                {
                    return(ScalingMode.Twip);
                }
                throw GUI.ApeException("Unsupported scaling mode");

            default:
                throw GUI.ApeException("The " + Description + " placement is of unsupported type " + placement.ToString());
            }
        }
コード例 #21
0
        public static IntPtr GetFocus()
        {
            NM.GUITHREADINFO CurrentGuiInfo = new NM.GUITHREADINFO();
            CurrentGuiInfo.cbSize = Marshal.SizeOf(CurrentGuiInfo);
            NM.GetGUIThreadInfo(0, ref CurrentGuiInfo);

            return(CurrentGuiInfo.hwndFocus);
        }
コード例 #22
0
ファイル: Language.cs プロジェクト: johnsewell/APE
        private static bool IsTopLevelWindow(IntPtr Window)
        {
            NM.WindowStyles Style = (NM.WindowStyles)(long) NM.GetWindowLongPtr(Window, NM.GWL.GWL_STYLE);

            // WS_OVERLAPPED and WS_POPUP indicate a top level window.
            // WS_OVERLAPPED constant is 0, it does not make a good mask.  But all
            // WS_OVERLAPPED windows MUST have a caption so use WS_CAPTION instead.
            return(Style.HasFlag(NM.WindowStyles.WS_CAPTION) || Style.HasFlag(NM.WindowStyles.WS_POPUP));
        }
コード例 #23
0
 /// <summary>
 /// Presses and releases the left alt key
 /// </summary>
 public static void SendAltKey()
 {
     NM.INPUT[] inputEvent = new NM.INPUT[2];
     inputEvent[0].type = NM.INPUT_TYPE.INPUT_KEYBOARD;
     inputEvent[0].U.ki = CreateKeyboardInput(NM.VirtualKeyShort.LMENU, NM.ScanCodeShort.LMENU, NM.KEYEVENTF.NONE, 0, UIntPtr.Zero);
     inputEvent[1].type = NM.INPUT_TYPE.INPUT_KEYBOARD;
     inputEvent[1].U.ki = CreateKeyboardInput(NM.VirtualKeyShort.LMENU, NM.ScanCodeShort.LMENU, NM.KEYEVENTF.KEYUP, 0, UIntPtr.Zero);
     NM.SendInput((uint)inputEvent.Length, inputEvent, NM.INPUT.Size);
 }
コード例 #24
0
        static TimerResolution()
        {
            uint minimumResolution;
            uint maximumResolution;
            uint currentResolution;

            NM.NtQueryTimerResolution(out minimumResolution, out maximumResolution, out currentResolution);

            m_MaximumResolution = maximumResolution;
        }
コード例 #25
0
        public static uint GetMaximumTimerResolution()
        {
            uint minimumResolution;
            uint maximumResolution;
            uint currentResolution;

            NM.NtQueryTimerResolution(out minimumResolution, out maximumResolution, out currentResolution);

            return(maximumResolution);
        }
コード例 #26
0
        public AppBar()
        {
            // Register a unique message as our callback message
            String uniqueMessageString = Guid.NewGuid().ToString();

            m_CallbackMessageID = NM.RegisterWindowMessage(uniqueMessageString);
            if (m_CallbackMessageID == 0)
            {
                throw new Exception("RegisterCallbackMessage failed");
            }
        }
コード例 #27
0
ファイル: ViewPort.cs プロジェクト: johnsewell/APE
 private void ctxtMenuViewPort_Opened(object sender, EventArgs e)
 {
     if (Cursor.Position.Y + ctxtMenuViewPort.Height > SystemInformation.PrimaryMonitorSize.Height)
     {
         NM.SetWindowPos(ctxtMenuViewPort.Handle, IntPtr.Zero, Cursor.Position.X, Cursor.Position.Y - ctxtMenuViewPort.Height, 0, 0, NM.SWP_NOSIZE | NM.SWP_NOZORDER);
     }
     else
     {
         NM.SetWindowPos(ctxtMenuViewPort.Handle, IntPtr.Zero, Cursor.Position.X, Cursor.Position.Y, 0, 0, 5);
     }
 }
コード例 #28
0
 private void ctxtMenuViewPort_Opened(object sender, EventArgs e)
 {
     if (Cursor.Position.Y + ctxtMenuViewPort.Height > SystemInformation.PrimaryMonitorSize.Height)
     {
         NM.SetWindowPos(ctxtMenuViewPort.Handle, IntPtr.Zero, Cursor.Position.X, Cursor.Position.Y - ctxtMenuViewPort.Height, 0, 0, NM.SetWindowPosFlags.IgnoreResize | NM.SetWindowPosFlags.IgnoreZOrder);
     }
     else
     {
         NM.SetWindowPos(ctxtMenuViewPort.Handle, IntPtr.Zero, Cursor.Position.X, Cursor.Position.Y, 0, 0, NM.SetWindowPosFlags.IgnoreResize | NM.SetWindowPosFlags.IgnoreZOrder);
     }
 }
コード例 #29
0
        private static double GetNormaliseFactor(Direction Axis)
        {
            switch (Axis)
            {
            case Direction.HORIZONTAL:
                return((double)65535 / NM.GetSystemMetrics(NM.SystemMetric.SM_CXSCREEN));

            case Direction.VERTICAL:
                return((double)65535 / NM.GetSystemMetrics(NM.SystemMetric.SM_CYSCREEN));
            }
            return(0);
        }
コード例 #30
0
ファイル: APE.Spy.cs プロジェクト: johnsewell/APE
        private void ClearHighlight(NM.tagRect area)
        {
            NM.tagRect tmpArea = new NM.tagRect();

            tmpArea.left   = area.left - 3;
            tmpArea.top    = area.top - 3;
            tmpArea.right  = area.right + 3;
            tmpArea.bottom = area.bottom + 3;

            NM.RedrawWindow(IntPtr.Zero, ref tmpArea, IntPtr.Zero, NM.RedrawWindowFlags.UpdateNow | NM.RedrawWindowFlags.Invalidate | NM.RedrawWindowFlags.AllChildren);
            Thread.Sleep(50);
        }