user32

Issue with callback method in SetTimer Windows API called from C# code

丶灬走出姿态 提交于 2019-12-12 01:57:49
问题 I'm currently involved in a project that is migrating some old VB6 code to C# (.Net Framework 3.5). My mandate is to just do the migration; any functional enhancements or refactoring is to be pushed to a later phase of the project. Not ideal, but there you go. So part of the VB6 code makes a call out to the Windows API SetTimer function. I've migrated this and cannot get it to work. The migrated project builds as a DLL; I've created a small WinForms test harness that links to the DLL and

How do I call the DialogBox() function in the user32.dll?

耗尽温柔 提交于 2019-12-11 23:59:21
问题 I'm trying to call the WinAPI function DialogBox() . On the Microsoft website this function is specified to be in the user32.dll. However, when tried to import this function by declaring it as function to import from a dll, the linker told me it isn't there. Then I tried to find the function with the dependency walker in C:\Windows\System32\user32.dll, but the function wasn't there. (I could see all the other fancy function literals there though.) What can be reasons for that and how can I

CB_SELECTSTRING ignored on some machines

梦想的初衷 提交于 2019-12-11 19:57:41
问题 I am using user32 library to automate some out of browser clicks on Windows, IE - "save as" dialog in particular. My solution works fine on my box however on other computers not really. The problem is when I am setting download path in a combobox, the file name I am passing in is just ignored and the original value is used. Other messages are accepted just fine on both environment, this includes clicking buttons, getting handles to windows, iterating windows, you name it. I know it is quite

C# KEYEVENTF_KEYUP doesn't work in specific app

我的未来我决定 提交于 2019-12-11 19:43:40
问题 I need to emulate some keys, here the code: [DllImport("user32.dll")] private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); private const int KEYEVENTF_EXTENDEDKEY = 1; private const int KEYEVENTF_KEYUP = 2; public static void KeyDown(Keys vKey) { keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY, 0); } public static void KeyUp(Keys vKey) { keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } KeyboardSend.KeyDown(Keys.Z); KeyboardSend

Problem Using user32.dll in C# (Error 1008 An attempt was made to reference a token that does not exist.)

余生长醉 提交于 2019-12-11 17:15:20
问题 Hello legendary coders. Flowing by my previous question I tried to use user32.dll in windows universal application (UWP) in C# language but I encountered an error while trying to use the method I imported from that .dll here is my code: [DllImport("user32.dll")] public static extern bool LockWorkStation(); private async void btnLock_Click(object sender, RoutedEventArgs e) { string path; if (Images.TryGetValue(selectedRadioButton.Name, out path)) { StorageFile file = await StorageFile

python 调用win32 api

﹥>﹥吖頭↗ 提交于 2019-12-11 16:49:54
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 刚学python,前几天在java中调用了win32api,给eclipse窗口来了个抖动,也想拿python实现下。 在网上找python调用win32api的资料,清一色的是 win32api模块,我晕。 作为一个新手,我也知道python调用c还是很方便的,我也不想去 sourceforge上下载 模块安装,于是翻遍了google, 加上自己的“冷静思考,理性分析” 哈哈!!终于通过两种方法实现 摘录在此,以备本人以及其他python新人查阅 (我的环境是 python2.7) 这里我们实现的是:枚举所有窗口,输出窗口的titile 第一种,通过ctypes的windll,user32实现。 #coding=utf-8 from ctypes import * from ctypes.wintypes import BOOL, HWND, LPARAM #定义回调函数 @WINFUNCTYPE(BOOL, HWND, LPARAM) def print_title(hwnd,extra): title = create_string_buffer(1024) #根据句柄获得窗口标题 windll.user32.GetWindowTextA(hwnd,title,255) title = title

Java JNA FindWindow() - Error looking up function 'FindWindow': The specified procedure could not be found

家住魔仙堡 提交于 2019-12-11 13:18:41
问题 I'm trying to bring to front a window named MyWindowTitle , using JNA . import com.sun.jna.Native; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.platform.win32.WinDef.HWND; public class ToFront { public static interface User32 extends StdCallLibrary { final User32 instance = (User32) Native.loadLibrary ("user32", User32.class); HWND FindWindow(String winClass, String title); boolean ShowWindow(HWND hWnd, int nCmdShow); boolean SetForegroundWindow(HWND hWnd); } public static void

SetForegroundWindow does not activate my window

旧街凉风 提交于 2019-12-11 10:46:12
问题 I can't figure out why it is not working ? static void ActivateApp(string processName) { Process[] p = Process.GetProcessesByName(processName); // Activate the first application we find with this name if (p.Any()) SetForegroundWindow(p[0].MainWindowHandle); else { Console.WriteLine("Something wrong"); } } [STAThread] static void Main(string[] args) { ActivateApp("Acrobat.exe"); } Output : Something is wrong But I'm sure that Acrobat.exe exist. 回答1: There are some weird rules for whether

How to bring external application window on top? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-11 09:25:40
问题 This question already has an answer here : Check process is running, then switch to it? (1 answer) Closed 2 years ago . I have Outlook express always on top and Google chrome behind Outlook. How to bring running Google chrome on top of OutLook express using visual basic? Following opens a new application but i want existing Google chrome to bring on top? Shell("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", AppWinStyle.MaximizedFocus) EDIT: Public Class Form1 Declare Auto

Detecting Key Presses Across Applications in Powershell

邮差的信 提交于 2019-12-11 05:00:00
问题 This is a post that can be found on Powershell.com via Wayback machine. It is from 2015 and is not on the site anymore. A link to it is here: Detecting Key Presses Across Applications. This post is meant to be Archival. 回答1: By accessing the Windows low-level system calls, PowerShell can query the keyboard for pressed keys. The following example waits until the user presses 'A'. This is a simple example that does not consider the state of the SHIFT keys, nor does it check virtual keys.