findwindow

Get window handle from window class name

和自甴很熟 提交于 2021-01-27 04:08:25
问题 I'm trying to get a window handle on a child window in my process and the only information I have is the window class name. Are there any win32 functions I can use for that? I'm doing this from C#. A bit more detail: This is a Visual Studio plugin, written in C#. So my process is visual studio, which has lots of windows. One of them has a window class "VsTipWindow". I don't know the immediate parent window of that window, all I have is the class name. Is there any way for me to get the window

Get window handle from window class name

痞子三分冷 提交于 2021-01-27 04:08:05
问题 I'm trying to get a window handle on a child window in my process and the only information I have is the window class name. Are there any win32 functions I can use for that? I'm doing this from C#. A bit more detail: This is a Visual Studio plugin, written in C#. So my process is visual studio, which has lots of windows. One of them has a window class "VsTipWindow". I don't know the immediate parent window of that window, all I have is the class name. Is there any way for me to get the window

Delphi中调用API函数经验点滴(三)

◇◆丶佛笑我妖孽 提交于 2020-02-29 10:02:40
三、防止多次载入应用程序实例   某些应用程序需要禁止用户载入多次实例。比如,控制面板中的应用程序,不管用户打开多少次,同一应用程序只有一个实例,而且每一次试图重复打开都会自动激活已经存在的实例。   Windows API 提供了函数FindWindow,可以是应用程序在启动时检查自己是否已经存在。   该函数在Delphi中的语法是:   function FindWindow(lpClassName: PChar, lpWindowName: PChar): HWND;   其中,参数lpCalssName 是要查找的窗口的类的名称,参数lpWindowName是要查找的窗口的标题(Caption)。 如果找到了相应的窗口实例,将返回一个非0 的该窗口句柄的整型值,否则返回0 。因此,只要判断应用程序的主窗口(或者伴随着应用程序存在而存在的窗口)是否存在就可以判断是否已经有实例存在了。   例如:   H := FindWindow('TForm1', nil);   if H = 0 then begin    ShowMessage('没有发现相同的应用程序实例。');    //加入加载应用程序的语句    //...   end else begin    ShowMessage('应用程序已经加载。');    SetActiveWindow(H);   end;

关闭ShowDialog的模态窗口

人盡茶涼 提交于 2020-02-21 14:05:52
[DllImport("user32.dll")] private static extern IntPtr FindWindow(string a, string b); [DllImport("user32.dll")] private static extern IntPtr PostMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); Timer timer = new Timer(); timer.Tick += (obj, arg) => { //1、尝试关闭ColorDialog IntPtr ptr1 = FindWindow(null, "颜色"); if (ptr1 != IntPtr.Zero) { PostMessage(ptr1, 0x0010, IntPtr.Zero, IntPtr.Zero); SetInfoBar("ColorDialog已关闭"); } //2、尝试关闭FolderBrowserDialog IntPtr ptr2 = FindWindow(null, "浏览文件夹"); if (ptr2 != IntPtr.Zero) { PostMessage(ptr2, 0x0010, IntPtr.Zero, IntPtr.Zero); SetInfoBar(

Sending keystrokes from a C# application to a Java application - strange behaviour?

风流意气都作罢 提交于 2020-01-04 14:18:29
问题 I'm trying to send keystrokes from my C# program to a Java application The code for sendig keys is: private void SendKeysToWindow(string WindowName, string KeysToSend) { IntPtr hWnd = FindWindow(null, WindowName); ShowWindowAsync(hWnd, SW_SHOWNORMAL); SetForegroundWindow(hWnd); SendKeys.Send(KeysToSend); } This code works fine with all programs, except with the Java application that I'm tyring to control. For example, if I create a button with the folowing code: SendKeysToWindow("Java

Finding a MessageBox in a specific app?

别等时光非礼了梦想. 提交于 2019-12-24 13:07:13
问题 We have implemented a solution to give our internal users a nag message that they need to redeploy our application. We are using the filesystem watcher to monitor the network and look for a change in a specific file which has worked very well. Most of the functionality has been implemented in a base form class that most of the forms of our application inherit from. A new message box will be displayed every five minutes until the redeploy the app. It nags them enough that its effective in

How to use Control.FromHandle?

半城伤御伤魂 提交于 2019-12-23 19:42:02
问题 i saw a method called Control.FromHandle wich (should) give you the access to it. Now, i wanted to try it using this code [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); // Find window by Caption only. Note you must pass IntPtr.Zero as the first parameter. [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); [DllImport(

Findwindow and SendMessage

北城以北 提交于 2019-12-20 05:15:42
问题 Hey all i am trying to figure out why this is not sending a ALT+F to notepad! Private Declare Function FindWindow1 Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Const WM_KEYUP = &H101 Private Const WM_KEYDOWN = &H100 Private Const WM_SYSKEYDOWN = &H104 Private Sub Command_Click() Dim parenthwnd As Long Dim hwnd As Long parenthwnd = FindWindow1(vbNullString, "Untitled - Notepad") retvalue = SendMessage(parenthwnd, WM_SYSKEYDOWN, VK