Jump to content
Sign in to follow this  

[Solved]Callback function and Objet

Recommended Posts


I follow my project about the use of DirectInput with Autoit

If i can create the interface correctly with the DirectInput8create Function

I have a problem when i want to use Callback function to enum Devices. ("bad callee")

i have Written this piece of code, but is it the the good syntax to callback the function _EnumJoystickProc?

i have looked in this forum and Google, but no samples of code using callback and Objet, may be its no possible?

Or there is a special syntax to callback function with autoit objet?

Local $oDirectInput8 = ObjCreateInterface ( $sCLSID_DirectInput8 , $sIID_IDirectInput8 ,$dtagIDirectInput8 )
; Create callback function
Global $handle = DllCallbackRegister("_EnumJoystickProc", "BOOL", "ptr;ptr")
$aa=$oDirectInput8.EnumDevices($DI8DEVCLASS_ALL,DllCallbackGetPtr($handle), 0, $DIEDFL_ATTACHEDONLY)
; MsgBox(0,hex($aa,8),$oDirectInput8)
Func _EnumJoystickProc($pDIinstance, $pContexte)
     Return $DIENUM_STOP



Edited by Frenchy

Share this post

Link to post
Share on other sites

You should post runnable code if you want precise help. Ten things could be wrong with the code that you aren't posting.

What I can see in your posted code is that you don't initialize DirectInput object. If you use ObjCreateInterface() then you have to call Initialize method before you start working with the object. It's all there on MSDN page for DirectInput8Create, just read carefully.

Share this post

Link to post
Share on other sites

Okay Trancexx, i have poste a runnable code (sorry for my english..)

So when i try to initialize the DirectInput interface

i have this com error: ! COM Error ! Number: 0x80020010 - Invalid Callee

So i have tried to understand.. iahev redad MSDM to understand better COM objet, so the objet interface to be correctly created, but Initialize Fails..

the function in C++ gives

HRESULT Initialize(


DWORD dwVersion


But when i test the VarGetType of Handle of Dll ($hDINPUT) it says Int32, but in help Autoit, Handle is pointer.. Dunno if the cause of error..

I need some light...!!

;#include "WINAPI.au3"
Opt("GUIOnEventMode", 1)
; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
ConsoleWrite("! COM Error !  Number: 0x" & Hex($oError.number, 8) & "   ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc
; DirectInput related constants
Global Const $DIDEVTYPE_DEVICE      = 1
Global Const $DIDEVTYPE_MOUSE        = 2
Global Const $DIDEVTYPE_KEYBOARD      = 3
Global Const $DIDEVTYPE_JOYSTICK      = 4
Global Const $DI8DEVCLASS_ALL        = 0
Global Const $DI8DEVCLASS_DEVICE      = 1
Global Const $DI8DEVCLASS_POINTER    = 2
Global Const $DI8DEVCLASS_KEYBOARD    = 3
Global Const $DI8DEVCLASS_GAMECTRL    = 4
Global Const $DI8DEVTYPE_DEVICE    = 0x11
Global Const $DI8DEVTYPE_MOUSE      = 0x12
Global Const $DI8DEVTYPE_KEYBOARD    = 0x13
Global Const $DI8DEVTYPE_JOYSTICK    = 0x14
Global Const $DI8DEVTYPE_GAMEPAD      = 0x15
Global Const $DI8DEVTYPE_DRIVING      = 0x16
Global Const $DI8DEVTYPE_FLIGHT    = 0x17
Global Const $DI8DEVTYPE_1STPERSON    = 0x18
Global Const $DI8DEVTYPE_DEVICECTRL   = 0x19
Global Const $DI8DEVTYPE_REMOTE    = 0x1B
Global Const $DIEDFL_ALLDEVICES    = 0x00000000
Global Const $DIEDFL_ATTACHEDONLY    = 0x00000001
Global Const $DIEDFL_FORCEFEEDBACK    = 0x00000100
Global Const $DIEDFL_INCLUDEALIASES   = 0x00010000
Global Const $DIEDFL_INCLUDEPHANTOMS  = 0x00020000
Global Const $DIEDFL_INCLUDEHIDDEN    = 0x00040000
Global Const $DIENUM_STOP            = 0
Global Const $DIENUM_CONTINUE        = 1
Global Const $DIRECTINPUT_VERSION = 0x0800
Global const $sIID_IDirectInput8  = "{BF798031-483A-4DA2-AA99-5D64ED369700}"
Global const $sCLSID_DirectInput8 = "{25E609E4-B259-11CF-BFC7-444553540000}"
; Used Dlls
Global Const $hDINPUT = DllOpen("dinput8.dll")
; Tag interface
Global $dtagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _
  "AddRef dword();" & _
  "Release dword();"
Global $dtagIDirectInput8W = $dtagIUnknown & _
"CreateDevice hresult(ptr;ptr*;ptr);" & _
"EnumDevices hresult(uint;ptr;ptr;uint);" & _
"GetDeviceStatus hresult(ptr);" & _
"RunControlPanel hresult(ptr;uint);" & _
"Initialize hresult(ptr;uint);" & _
"FindDevice hresult(ptr;wstr;ptr);" & _
"EnumDevicesBySemantics hresult(wstr;ptr;ptr;ptr;uint);" & _
"ConfigureDevices hresult(ptr;ptr;uint;ptr);"
; IDirect3D9 interface pointer
Global $oDirectInput8 = ObjCreateInterface ( $sCLSID_DirectInput8 , $sIID_IDirectInput8 , $dtagIDirectInput8W)
ConsoleWrite ("$oDirectInput8 is an Objet Interface -> " & (IsObj($oDirectInput8) = True) & @CRLF)
ConsoleWrite ("$hDINPUT VarGetType -> " & VarGetType($hDINPUT) & @CRLF)
$oDirectInput8.Initialize($hDINPUT, $DIRECTINPUT_VERSION)
; Create callback function
Global $handle = DllCallbackRegister("EnumJoystickProc", "BOOL", "ptr;ptr")
$result=$oDirectInput8.EnumDevices($DI8DEVCLASS_ALL, DllCallbackGetPtr($handle), 0, $DIEDFL_ALLDEVICES)
$oDirectInput8 = 0
Func EnumJoystickProc($p, $d)
Static Local $index=1
ConsoleWrite("Enter in Callback function " & $index )
$index = $index +1
; On Exit Function
Func _Quit()
EndFunc   ;==>_Quit

Regards Terry

Share this post

Link to post
Share on other sites

Don't look inside before you get it working.

#include <WinApi.au3>

Global Const $sCLSID_DirectInput = "{25E609E4-B259-11CF-BFC7-444553540000}"
Global Const $sIID_IDirectInput8W = "{BF798031-483A-4DA2-AA99-5D64ED369700}"
Global Const $tagIDirectInput8 = "CreateDevice hresult(clsid;ptr*;ptr);" & _
        "EnumDevices hresult(dword;ptr;ptr;dword);" & _
        "GetDeviceStatus hresult(clsid);" & _
        "RunControlPanel hresult(hwnd;dword);" & _
        "Initialize hresult(handle;dword);" & _
        "FindDevice hresult(clsid;wstr;clsid*);" & _
        "EnumDevicesBySemantics hresult(wstr;ptr;ptr;ptr;dword);" & _
        "ConfigureDevices hresult(ptr;ptr;dword;ptr);"

Global Const $DIRECTINPUT_VERSION = 0x0800
Global Const $DIENUM_CONTINUE = 1
Global Const $DI8DEVCLASS_ALL = 0
Global Const $DIEDFL_ATTACHEDONLY = 0x00000001

Global $oIDirectInput8 = ObjCreateInterface($sCLSID_DirectInput, $sIID_IDirectInput8W, $tagIDirectInput8)

$oIDirectInput8.Initialize(_WinAPI_GetModuleHandle(0), $DIRECTINPUT_VERSION)

Global $hCallback = DllCallbackRegister("_EnumAllProc", "bool", "ptr;ptr")

$oIDirectInput8.EnumDevices($DI8DEVCLASS_ALL, DllCallbackGetPtr($hCallback), 0, $DIEDFL_ATTACHEDONLY)

; Callback definition
Func _EnumAllProc($pDIinstance, $pContext)
    If $pDIinstance Then
        Local $tDIDEVICEINSTANCE = DllStructCreate("dword dwSize;" & _
                "byte guidInstance[16];" & _
                "byte guidProduct[16];" & _
                "dword dwDevType;" & _
                "wchar tszInstanceName[260];" & _
                "wchar tszProductName[260];" & _
                "byte guidFFDriver[16];" & _
                "word wUsagePage;" & _
                "word wUsage;", _

        ConsoleWrite("guidInstance = " & _WinAPI_StringFromGUID(DllStructGetPtr($tDIDEVICEINSTANCE, "guidInstance")) & @CRLF)
        ConsoleWrite("guidProduct = " & _WinAPI_StringFromGUID(DllStructGetPtr($tDIDEVICEINSTANCE, "guidProduct")) & @CRLF)

        ConsoleWrite("tszInstanceName = " & DllStructGetData($tDIDEVICEINSTANCE, "tszInstanceName") & @CRLF)
        ConsoleWrite("tszProductName = " & DllStructGetData($tDIDEVICEINSTANCE, "tszProductName") & @CRLF)

        ConsoleWrite("guidFFDriver = " & _WinAPI_StringFromGUID(DllStructGetPtr($tDIDEVICEINSTANCE, "guidFFDriver")) & @CRLF)

        ConsoleWrite("wUsagePage = " & DllStructGetData($tDIDEVICEINSTANCE, "wUsagePage") & @CRLF)
        ConsoleWrite("wUsage = " & DllStructGetData($tDIDEVICEINSTANCE, "wUsage") & @CRLF)



Share this post

Link to post
Share on other sites

Okay Trancexx i understant better the sentence in help file about the 3 methods automatically added in Objet COM, and i understand why my program fails (certainly an offset problem with function)

i have to increase my skills in english langage !!

Thanks again for your time to help me..With Com objet i have discovered a part of autoit i have never opened!!

In fact all is possible with Autoit!!

i really appreciate


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By GtaSpider
      Hey everyone,
      I searched some hours for a way to use the function WaitForSingleObject not as a function the script has to wait for, but a function which calls a callback function when the event is signaled. I found a way with RegisterWaitForSingleObject  but no AutoIt implemention, so I made one on my own, and now I want to share it with you guys!
      The only limitation by this implemention is that you are not able to use more than one callback at once. to avoid this, you could write a static array in the function which fills with the selfmade callback structs. If you find another way, let me know!

      Hope you like it and find use for it!
    • By MikahS
      Hello all,
      Back again it seems. I've hit a snag in the below script. I use this on win 7 and XP machines frequently and have just realized that sorting using column headers is not 'working' (is not updating listview; it looks like something is going on behind the scenes..) when clicked. Also this does not show the sorting arrow when using the callback sort functionality.
      So, to sum up, I am not seeing the arrow keys when clicking the column header to sort. And, it is not sorting the values in the $List1 ListView box on a win XP machine.
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <GUIListBox.au3> #include <GUIEdit.au3> #include <GuiListView.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <ScrollBarConstants.au3> #include <GuiScrollBars.au3> Local $List1, $List2, $List3, $List4, $GUIhandle Local $Button19, $Button91, $ButtonAZ, $ButtonZA Local $hChild_1, $cLabel_1, $cLabel_2, $cLabel_3 GUI() Repaint() Local $bSysMsg = False Local $aRect = _GUICtrlListView_GetItemRect($List1, 0) $iDeltaY = $aRect[3] - $aRect[1] _GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List2), $SB_BOTH, $ESB_DISABLE_BOTH) _GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List3), $SB_BOTH, $ESB_DISABLE_BOTH) _GUICtrlListView_RegisterSortCallBack($List1) _GUICtrlListView_RegisterSortCallBack($List2) _GUICtrlListView_RegisterSortCallBack($List3) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND") While 1     $msg = GUIGetMsg(1)     Switch $msg[1]         Case $GUIhandle             Switch $msg[0]                 Case $GUI_EVENT_CLOSE                     Quit()             EndSwitch             If $bSysMsg Then                 $bSysMsg = False                 _Resize_ListViews()             EndIf         Case $hChild_1             Switch $msg[0]                 Case $GUI_EVENT_CLOSE                     GUIDelete($hChild_1)             EndSwitch     EndSwitch WEnd Func Repaint()     Local $L1, $L2, $L3     _GUICtrlListView_BeginUpdate($List1)     _GUICtrlListView_DeleteAllItems($List1)     _GUICtrlListView_BeginUpdate($List2)     _GUICtrlListView_DeleteAllItems($List2)     _GUICtrlListView_BeginUpdate($List3)     _GUICtrlListView_DeleteAllItems($List3)     For $Index = 0 To 10 Step 1         $L1 = _GUICtrlListView_AddItem($List1, $Index, $Index)         $L2 = _GUICtrlListView_AddItem($List2, $Index, $Index)         $L3 = _GUICtrlListView_AddItem($List3, $Index, $Index)     Next     _GUICtrlListView_SetColumnWidth($List1, 0, $LVSCW_AUTOSIZE)     _GUICtrlListView_SetColumnWidth($List2, 0, $LVSCW_AUTOSIZE)     _GUICtrlListView_EndUpdate($List1)     _GUICtrlListView_EndUpdate($List2)     _GUICtrlListView_EndUpdate($List3) EndFunc   ;==>Repaint Func Quit()     _GUICtrlListView_UnRegisterSortCallBack($List1)     _GUICtrlListView_UnRegisterSortCallBack($List2)     _GUICtrlListView_UnRegisterSortCallBack($List3)     Exit EndFunc   ;==>Quit Func GUI()     Local $Index, $LV1, $LV2, $LV3, $L1_EX, $L2_EX, $L3_EX     $GUIhandle = GUICreate("ArchServer", 680, 575, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;creates the parent window     $List1 = _GUICtrlListView_Create($GUIhandle, "Computer Name ", 20, 35, 300, 448, -1, $LVS_EX_DOUBLEBUFFER) ;;$ES_READONLY incase you don't want to be able to select text     $cLabel_1 = GUICtrlCreateLabel("", 20, 35, 300, 448)     GUICtrlSetState($cLabel_1, $GUI_DISABLE)     GUICtrlSetResizing($cLabel_1, $GUI_DOCKAUTO)     GUICtrlSetBkColor($cLabel_1, $GUI_BKCOLOR_TRANSPARENT)     _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_TWOCLICKACTIVATE)     $List2 = _GUICtrlListView_Create($GUIhandle, "Date/Time", 355, 35, 190, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))     $cLabel_2 = GUICtrlCreateLabel("", 355, 35, 190, 450)     GUICtrlSetState($cLabel_2, $GUI_DISABLE)     GUICtrlSetResizing($cLabel_2, $GUI_DOCKAUTO)     GUICtrlSetBkColor($cLabel_2, $GUI_BKCOLOR_TRANSPARENT)     $List3 = _GUICtrlListView_Create($GUIhandle, "Speed", 574, 35, 95, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))     $cLabel_3 = GUICtrlCreateLabel("", 574, 35, 95, 450)     GUICtrlSetState($cLabel_3, $GUI_DISABLE)     GUICtrlSetResizing($cLabel_3, $GUI_DOCKAUTO)     GUICtrlSetBkColor($cLabel_3, $GUI_BKCOLOR_TRANSPARENT)     GUICtrlCreateLabel("Additional Info", 20, 489) ;creates the label for $List4     GUICtrlSetResizing(-1, $GUI_DOCKSIZE)     $List4 = GUICtrlCreateList("", 20, 512, 635, 40, BitOR($WS_BORDER, $WS_VSCROLL), $ES_READONLY)     GUICtrlSetResizing($List4, $GUI_DOCKAUTO)     GUICtrlCreateLabel("Active Connections: ", 525, 487) ;creates the label for the active connections     GUICtrlSetResizing(-1, $GUI_DOCKSIZE)     $ActiveConnections = GUICtrlCreateList("0", 625, 486, 30, 30) ;dynamically updating list of connections as they come in     GUICtrlSetResizing($ActiveConnections, $GUI_DOCKSIZE)     GUICtrlSetResizing(-1, $GUI_DOCKSIZE)     GUISetState(@SW_SHOW) ;shows the GUI window     For $Index = 0 To 10 Step 1         $LV1 = _GUICtrlListView_AddItem($List1, " ") ;adds a default value into $List1         $LV2 = _GUICtrlListView_AddItem($List2, " ") ;adds a default value into $List2         $LV3 = _GUICtrlListView_AddItem($List3, " ") ;adds a default value into $List3     Next EndFunc   ;==>GUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)     Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, _             $ceLines, $cl     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))     $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")     $iCode = DllStructGetData($tNMHDR, "Code")     Local Const $iLines = _SendMessage($List1, $LVM_GETTOPINDEX) - _SendMessage($List2, $LVM_GETTOPINDEX)     _SendMessage($List2, $LVM_SCROLL, 0, $iLines * $iDeltaY)     _SendMessage($List3, $LVM_SCROLL, 0, $iLines * $iDeltaY)     Switch $hWndFrom         Case $List1             Switch $iCode                 Case $LVN_COLUMNCLICK                     _GUICtrlListView_SortItems($List1, GUICtrlGetState($List1))                 Case $NM_CLICK                     $sData = _GUICtrlListView_GetSelectedIndices($List1)                     _GUICtrlListView_SetItemSelected($List2, $sData, True, False)                     _GUICtrlListView_SetItemSelected($List3, $sData, True, False)             EndSwitch         Case $List2             Switch $iCode                 Case $LVN_COLUMNCLICK                     _GUICtrlListView_SortItems($List1, GUICtrlGetState($List1))                 Case $NM_CLICK                     $sData = _GUICtrlListView_GetSelectedIndices($List2)                     _GUICtrlListView_SetItemSelected($List1, $sData, True, False)                     _GUICtrlListView_SetItemSelected($List3, $sData, True, False)             EndSwitch         Case $List3             Switch $iCode                 Case $LVN_COLUMNCLICK                     _GUICtrlListView_SortItems($List1, GUICtrlGetState($List1))                 Case $NM_CLICK                     $sData = _GUICtrlListView_GetSelectedIndices($List3)                     _GUICtrlListView_SetItemSelected($List1, $sData, True, False)                     _GUICtrlListView_SetItemSelected($List2, $sData, True, False)             EndSwitch     EndSwitch EndFunc   ;==>WM_NOTIFY Func WM_SIZE($hWnd, $msg, $wParam, $lParam)     _Resize_ListViews()     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_SIZE Func _WM_SYSCOMMAND($hWnd, $msg, $wParam, $lParam)     Const $SC_MAXIMIZE = 0xF030     Const $SC_RESTORE = 0xF120     Switch $wParam         Case $SC_MAXIMIZE, $SC_RESTORE             $bSysMsg = True     EndSwitch EndFunc   ;==>_WM_SYSCOMMAND Func _Resize_ListViews()     $aRet = ControlGetPos($GUIhandle, "", $cLabel_1)     WinMove($List1, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])     $aRet = ControlGetPos($GUIhandle, "", $cLabel_2)     WinMove($List2, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])     $aRet = ControlGetPos($GUIhandle, "", $cLabel_3)     WinMove($List3, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3]) EndFunc   ;==>_Resize_ListViews ;========RESIZE FUNCTIONALITY THANKS TO MELBA All replies are much appreciated!
    • By GtaSpider
      Hey folks,
      I just explored the new helpfile and found a new Keyword (dunno if its that new, but i never saw it before) called Volatile. It was made especally for CallBack and Com event functions, so I wanted to try that out. the advantage of this Keyword is, that you can run the Dll while you can do other things in autoit (AutoIt wont freeze/pause anymore while the dllcall is executed!)
      I made up a little example i want to share with you, the c source is compiled in MinGW, you need at least AutoIt
      Hope you like it, would be interested in some comments
    • By JScript
      Function Reference
      Adlib function with support for parameters, pause and resume using Call Back!


      _Adlib_Register( "Function" [, "Params" [, Time [, RepeatCount ]]] ) _Adlib_Pause( "Function" ) _Adlib_Resume( "Function" ) _Adlib_SetTimer( "Function" [, Time ] ) _Adlib_UnRegister( "Function" )

      ; You can call functions with parameters and native functions also!

      Version: 0.10

      Note: Usage example is included!




      João Carlos.
    • By AdmiralAlkex
      I wanted to see if I could manage to use IAppVisibility (Win8) in one of my scripts.
      (it seems the name was changed in Release Preview but MSDN wasn't updated)

      It took some time but I learned to make tlb file and made definitions for GetAppVisibilityOnMonitor and IsLauncherVisible methods (working good as far as I can tell), but I would like Advise and Unadvise too if possible, but I don't know how...

      See definition on above link.

      Only example I found is some (too advanced for me to translate) c++ code. Here. But it compiles and runs fine at least.

      trancexx is doing a similar thing in maybe that can be used somehow?

      Anyone have a clue?

      Test script with the working funcs:

      #include <WinAPI.au3> ;=============================================================================== #interface "IAppVisibility" Global Const $sCLSID_AppVisibility = "{7E5FE3D9-985F-4908-91F9-EE19F9FD1514}" Global Const $sIID_IAppVisibility = "{2246EA2D-CAEA-4444-A3C4-6DE827E44313}" ; Definition Global Const $tagIAppVisibility = "GetAppVisibilityOnMonitor hresult(ptr;int*);" & _ "IsLauncherVisible hresult(int*);" & _ "Advise hresult(ptr;dword*);" & _ "Unadvise hresult(dword);" ;============================================================================== Local $oAppVisibility = ObjCreateInterface($sCLSID_AppVisibility, $sIID_IAppVisibility, $tagIAppVisibility) ;~ MsgBox(0, @ScriptName, IsObj($oAppVisibility)) ;~ ConsoleWrite(IsObj($oAppVisibility) & @CRLF) If Not IsObj($oAppVisibility) Then ConsoleWrite("NOT IsObj" & @LF) MsgBox(0, "", "NOT IsObj") Exit EndIf HotKeySet("ö", "_IsLauncherVisible") HotKeySet("å", "_GetAppVisibilityOnMonitor") $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler $callback=DllCallbackRegister("_MonitorEnumProc","int","ptr;ptr;ptr;lparam") Global $Monitor DllCall("user32.dll","int","EnumDisplayMonitors","ptr",0,"ptr",0,"ptr",DllCallbackGetPtr($callback),"lparam",10) While 1 Sleep(1000) WEnd Func _IsLauncherVisible() Local $bVisible $iRet = $oAppVisibility.IsLauncherVisible($bVisible) ;~ If @error Then ;Enable this and disable AutoIt.Error if on Alpha ;~ MsgBox(0, @ScriptName, @error) ;~ EndIf ToolTip("1: " & $iRet & @CRLF & "2: " & $bVisible) EndFunc Func _GetAppVisibilityOnMonitor() Local $iMode $iRet = $oAppVisibility.GetAppVisibilityOnMonitor($Monitor, $iMode) ToolTip("1: " & $iRet & @CRLF & "2: " & $iMode) EndFunc ; This is a custom error handler Func ErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "WinDescription is: " & $oMyError.windescription) $iEventError = 1 ; Use to check when a COM Error occurs EndFunc ;==>ErrFunc Func _MonitorEnumProc($hMonitor, $hdcMonitor, $lprect, $lparam) MsgBox(0, "Monitor", "Monitor handle: " & $hMonitor & @CRLF & "LPARAM: " & $lparam) $Monitor = $hMonitor EndFunc
      Here's tlb stuff:

      ================================================================================== coclass AppVisibility; CLSID = {7E5FE3D9-985F-4908-91F9-EE19F9FD1514}; // Implemented interface: <Interface> IAppVisibility ================================================================================== Interface IAppVisibility; IID = {2246EA2D-CAEA-4444-A3C4-6DE827E44313}; // Inherits from: IUnknown {00000000-0000-0000-C000-000000000046} 1. STDCALL FUNC PUREVIRTUAL; HRESULT GetAppVisibilityOnMonitor( [in] hMonitor, [out] int* pMode ); 2. STDCALL FUNC PUREVIRTUAL; HRESULT IsLauncherVisible( [out] int* pfVisible ); 3. STDCALL FUNC PUREVIRTUAL; HRESULT Advise( [in] * pCallback, [out] dword* pdwCookie ); 4. STDCALL FUNC PUREVIRTUAL; HRESULT Unadvise( [in] dword dwCookie ); ================================================================================== enum MONITOR_APP_VISIBILITY; { MAV_UNKNOWN = 0, MAV_NO_APP_VISIBLE = 1, MAV_APP_VISIBLE = 2 }; ================================================================================== Interface IAppVisibilityEvents; IID = {6584CE6B-7D82-49C2-89C9-C6BC02BA8C38}; // Inherits from: IUnknown {00000000-0000-0000-C000-000000000046} 1. STDCALL FUNC PUREVIRTUAL; HRESULT AppVisibilityOnMonitorChanged( [in] hMonitor, [in] previousMode, [in] currentMode ); 2. STDCALL FUNC PUREVIRTUAL; HRESULT LauncherVisibilityChange( [in] int currentVisibleState ); ==================================================================================
  • Create New...