Calling GetGUIThreadInfo from Outlook VBA -
I need to find the active window'm writing a VBA macro in MS Outlook, which is a specific process. The goal of this is to get the active window / document name even if its original application has more than one document interface.
User processor with GetCurrentThreadId is active, I am using GetGUIThreadInfo to get .dll. Here is the correct code:
private type RECT as as Left LongPtr top LongPtr right LongPtr down LongPtr termination of private type GUITHREADINFO cbSize as LongPtr flags LongPtr hwndActive LongPtr hwndFocus LongPtr hwndCapture LongPtr as as as as as reset as LongPtr rcCaret as LongPtr hwndCreate as LongPtr hwndMoveSize as HwndMenuOwner end of Private Equity PtrSafe function GetWindowThreadProcessId Lib "user32" (_BVV hnw LongPtr as LongPtr Nig Mr. announced as PtrSafe function GetGUIThreadInfo Lib "user32" _ (ByVal dwthreadid as LongPtr, _ lpguithreadinfo as GUITHREADINFO) LongPtr Sub MyFunction () as dim strWindowTitle string = space as strWindowTitle (30) dim GUIInfo GUITHREADINFO GUIInfo.cbSize = LenB (GUIInfo) calls GetGUIThreadInfo (GetCurrentThreadId, GUIInfo) calls GetWindowText (GUIInfo.hwndActive, strWindowTitle, 30) debug Kprnt Strdndotaitl e nd sub
I do whatever Yes (using different methods to get active type ID, around it Type change) Output is empty. Printing GUIInfo.hwndActive also gives me 0. The current thread ID is being found fine, but I'm doing something wrong in the GetGUIThreadInfo function. I guess it has to do with the VBA, but rather than calling from VB.net (as were those examples I was most capable of finding)
I also try to calculate through child windows , But it is difficult to tell me which one of them is active (it is that I have not missed a function to do, that would probably work as well!) >
I'm running Outlook 2010 64 on a 64-bit machine, so its LongPtr Ryog.
Any help would be greatly appreciated.
I think that you thread the first parameter GetGUIThreadInfo guns are jumping examples with some Dirgpttiaon is A DWORD for ID, DWORD is still 32 bit even on 64 bit windows Similarly, so far actually 32bits is still, so your RECT definition is incorrect . It's been a very long time even when I have VB, but I do not remember that ByVal or ByRef is the default if you need to specify the ByRef on the structure structure for GetGRIThreadInfo before the problem is.
c:. \ Users \ logon & gt; Type foop.c # include & lt; Windows.h & gt; # Include & lt; Stdio.h & gt; Int main () {int n = sizeof (DWORD); Printf ("% d \ n", n); N = sizeof (DWORD_PTR); Printf ("% d \ n", n); Return 0; } C: \ users \ logan & gt; Copyright Microsoft Corporation (c) copyright for Microsoft Corporation (c) C / C ++ Optimizer Compiler Version 14.00.50727.762 x64 All rights reserved. Foop.c Microsoft (R) Incremental Linker Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. /out:foop.exe foop.obj c: \ users \ logan> foop.exe 4 8
Comments
Post a Comment