Hi Sean + others,
very helpful script you wrote accessing COM.
I have some problems, maybe you can give me a hint
on how to solve my problem.
I am trying to communicate with the Citrix API through the ICA client.
I am new to this topic but I have to figure out how I can send
keystrokes and maybe also mouseclicks to a citrix application.
I tried to use PostMessage but this won't work on a Citrix window.
So now I am using cohelper.ahk to use the wfica.ocx.
I managed to login through citrix but now I get stuck on how to use
the keyboard.
Alright. Now some information.
I use
Code:
piT := ActiveXObject("Citrix.ICAClient")
to connect to the API and piT contains a valid identifier. Then I am able to set some properties and to pass them.
For instance:
Code:
Ctrx_SetProp(ByRef piT, propName, propVal)
{
pName := SysAllocString(propName)
pStr := SysAllocString(propVal)
ret := DllCall(VTable(piT, 16), "Uint", piT, "Uint", pName, "Uint", pStr)
SysFreeString(pName)
SysFreeString(pStr)
return ret
}
Ctrx_SetProp(piT,"Username",user)
Ctrx_SetProp(piT,"Password",Pwd)
Now the problem. As I can see from the typelib browser, there are differten CLSIDs and IIDs but I don't know, how to use different than
the ICAClient
Code:
' ****************************************************************************************
' ProgIDs (Program identifiers)
' ****************************************************************************************
$PROGID_CitrixICAClient25 = "Citrix.ICAClient.2.5"
$PROGID_CitrixICAClientProp24 = "Citrix.ICAClientProp.2.4"
' ****************************************************************************************
' ClsIDs (Class identifiers)
' ****************************************************************************************
$CLSID_ICAClient = GUID$("{238F6F83-B8B4-11CF-8771-00A024541EE3}")
$CLSID_ICAClientProp = GUID$("{238F6F85-B8B4-11CF-8771-00A024541EE3}")
$CLSID_Keyboard = GUID$("{B5D6ED13-EDAA-4C2C-B2E2-26FD9BC1C710}")
$CLSID_Mouse = GUID$("{901591F7-7ACA-477A-9119-C75198E74F72}")
$CLSID_ScreenShot = GUID$("{1F26DF05-9E90-4156-B58B-44632B0DC461}")
$CLSID_Session = GUID$("{1DA5FBD9-3ED4-4617-9A95-334789A2B52A}")
$CLSID_window = GUID$("{CBC0A3C6-7F47-4F70-B0FC-307688E5EAB2}")
$CLSID_Windows = GUID$("{30DBF909-6147-46C8-B02C-96B460712ED3}")
' ****************************************************************************************
' IIDs (Interface identifiers)
' ****************************************************************************************
$IID_IICAClient = GUID$("{238F6F81-B8B4-11CF-8771-00A024541EE3}")
$IID_IKeyboard = GUID$("{17BFCA0A-C42E-4AC9-A693-29473FF9BA6C}")
$IID_IMouse = GUID$("{02093274-7B69-4FEB-B7FD-3A010561A5F3}")
$IID_IScreenShot = GUID$("{8F2D9E63-D224-47E4-8111-32DBB016A4C6}")
$IID_ISession = GUID$("{4A502C16-CFAE-4BB0-B1F9-93ACADDA57BB}")
$IID_IWindow = GUID$("{4D5D2139-29E2-4CDC-8020-429B35999BE6}")
$IID_IWindows = GUID$("{9B371833-5E4F-4B72-A8F6-CB8E762999F4}")
$IID__IICAClientEvents = GUID$("{238F6F82-B8B4-11CF-8771-00A024541EE3}")
$IID__IKeyboardEvents = GUID$("{8A5961DF-314E-4B7C-B57F-AAF35EA33079}")
$IID__IMouseEvents = GUID$("{24013613-FF51-4B50-9832-37FA561594ED}")
$IID__IScreenShotEvents = GUID$("{785A16E9-4E42-4C87-84AD-BFB4A60570A3}")
$IID__ISessionEvents = GUID$("{24FD31DB-3560-4C78-8950-30F03352D830}")
$IID__IWindowEvents = GUID$("{49813E6D-17FF-41A1-9A7B-95C3D5B44185}")
I tried the following to send a keystroke:
Code:
GUID4String(CLSID_Keyboard, "{B5D6ED13-EDAA-4C2C-B2E2-26FD9BC1C710}")
GUID4String(IID_IKeyboard, "{17BFCA0A-C42E-4AC9-A693-29473FF9BA6C}")
puh := CreateObject(CLSID_Keyboard, IID_IKeyboard)
VK = 65
DllCall(VTable(piT, 7), "Uint", piT, "Long", VK, "Long")
But the puh variable always contains 0 instead of a valid identifiert.
What am I missing and what do I wrong?
I read through many articles containg cohelper and got that far but no further

here is the original function as revealed with TypeLib browser
Code:
' ****************************************************************************************
' SendKeyUp method
' Interface name = IKeyboard
' method SendKeyUp
' VTable offset = 32 [&H20]
' DispID = 101 [&H00000065]
' ****************************************************************************************
FUNCTION CitrixIKeyboard_SendKeyUp ALIAS "CitrixIKeyboard_SendKeyUp" ( _
BYVAL pthis AS DWORD PTR _ ' %VT_DISPATCH <dispinterface>
, BYVAL keyId AS LONG _ ' %VT_I4 <LONG> [in]
) EXPORT AS LONG ' %VT_HRESULT <LONG>
LOCAL HRESULT AS LONG
IF pthis = 0 THEN FUNCTION = %E_POINTER : EXIT FUNCTION
CALL DWORD @@pthis[8] USING CitrixIKeyboard_SendKeyUp(pthis, keyId) TO HRESULT
FUNCTION = HRESULT
END FUNCTION
Any help is appreciated!
n/b: I never used cohelper nor Citrix before. So both is new to me.
Thanks alot,
FlowPEE