Windows API to check if currently selected object is of the outlook data type

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
554
Is there a windows api function to check the data type of the last item focused on or clicked down on (this includes a dragged object) is of the outlook object type? For instance, if you clicked on your desktop icon to drag it highlights to show its been selected and when you select an email in outlook it highlights and unhighlights the desktop icon since its no longer in focus. Is there a way to check that the current focus selection is outlook related or even better a mailitem in the outlook object model?

Thanks!
 
Last edited:

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
554
Currently I found this code which tells the active program window on the screen. Unfortunately, if outlook is put in front and you see the file explorer on the screen. You can select a file and drag it without making the file explorer the active window. Any ideas. I have included the code for reference. I want to get the active window for the actively selected object.

Rich (BB code):
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">ublicDeclareFunction GetForegroundWindow Lib"user32" _
    Alias"GetForegroundWindow"()AsLong
PublicDeclareFunction GetWindowText Lib"user32" _
    Alias"GetWindowTextA"(ByVal hwnd AsLong, _
    ByVal lpString AsString,ByVal cch AsLong)AsLong

Sub AAA()
    Dim WinText AsString
    Dim HWnd AsLong
    Dim L AsLong
    HWnd = GetForegroundWindow()
    WinText =String(255, vbNullChar)
    L = GetWindowText(HWnd, WinText,255)
    WinText = Left(WinText, InStr(1, WinText, vbNullChar)-1)
    Debug.Print L, WinText
EndSub

</code>
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,102,369
Messages
5,486,448
Members
407,547
Latest member
Sankarasrinivas

This Week's Hot Topics

Top