Depending on how you connect to Citrix terminal services sessions and your licensing setup, you may see one or both of the following dialog boxes:
These dialog boxes are informational and may or may not appear when you initially log into terminal services sessions. Following are two ways of handling these dialog boxes.
This solution creates an interrupt that handles the dialog boxes if they appear:
transaction TMain
var
begin
CitrixInit(800, 600);
CitrixAddInterrupt(INTERRUPT_WindowCreate, "ICA Seamless Host Agent", MATCH_Exact);
CitrixConnect("lab74", "labadmin", "labpass", "testlab1", COLOR_16bit);
CitrixWaitForLogon();
hWnd4 := CitrixWaitForWindowCreation("", MATCH_Exact, 0x96840000, -2, 572, 804, 30);
CitrixWaitForWindowCreation("Program Manager");
CitrixMouseClick(36, 17, hWnd4, MOUSE_ButtonLeft, MOD_None, -1, 0);
hWnd11 := CitrixWaitForWindowCreation("", MATCH_Exact, 0x96400000, 2, 313, 163, 263);
CitrixMouseClick(62, 247, hWnd11, MOUSE_ButtonLeft);
CitrixWaitForWindow(hWnd11, EVENT_Destroy);
hWnd12 := CitrixWaitForWindowCreation("Shut Down Windows", MATCH_Exact, 0x94C808CC, 191, 136, 417, 192);
CitrixWaitForWindow(hWnd12, EVENT_Activate);
CitrixMouseClick(203, 170, hWnd12, MOUSE_ButtonLeft);
CitrixWaitForDisconnect();
end TMain;
dclevent
handler Handler1 <EVENT_CITRIXINTERRUPT>
var
nInterrupt, nWindow : number;
nStyle : number;
begin
CitrixGetActInterrupt(nInterrupt, nWindow);
ErrorAdd(FACILITY_CITRIXENGINE, 47, SEVERITY_INFORMATIONAL);
print(string(nWindow));
if CitrixGetWindowStyle(nWindow, nStyle) and (nStyle <> 0xB4000000) then
CitrixWaitForWindow(nWindow, EVENT_Activate);
CitrixMouseClick(201, 202, nWindow, MOUSE_ButtonLeft);
CitrixWaitForWindow(nWindow, EVENT_Destroy);
end;
ErrorRemove(FACILITY_CITRIXENGINE, 47);
end Handler1;
This sample code loops for 30 seconds, waiting for the Citrix dialog boxes to appear. If the dialog boxes appear, this code closes them.
function MyCitrixStartup(nMaxWait: number optional): boolean
var
hwndICAHandle : number;
hwndFoundLicenseWarning : number;
nCount : number;
begin
hwndICAHandle:=-1;
hwndFoundLicenseWarning:=-1;
nCount:=0;
if (nMaxWait = 0) then
nMaxWait:=10;
// if no wait time was passed,
// use 10 tries (seconds) as a default
end;
MeasureStart("MyCitrixStartup");
//
// loop until we've handled the conditions or we've tried
//
while ((nCount < nMaxWait) and ((hwndICAHandle <=0) or
(hwndFoundLicenseWarning <=0))) do
//
// Just a little feedback, every 10 tries
//
if ((nCount MOD 10) =0) then
print(string(nCount) + ")MyCitrixStartup "
+ " vUser:" + string(GetUserId())
+ " hwndICAHandle=" + string(hwndICAHandle)
+ " hwndFoundLicenseWarning="
+ string(hwndFoundLicenseWarning),
OPT_DISPLAY_ERRORS , TEXT_GREEN );
end;
//
// if we haven't handled this window yet
//
if (hwndICAHandle <=0) then
hwndICAHandle := CitrixWaitForWindowCreation
("ICA Seamless Host Agent", MATCH_Exact, 0x94C800C4,
0, 0, 0, 0, false, 1, true);
if (hwndICAHandle > 0) then
if (CitrixWindowBringToTop(hwndICAHandle)) then
CitrixKey(KEY_ENTER); // press ok to close the dialog
CitrixWaitForWindow(hwndICAHandle, EVENT_Destroy);
// wait for the close
end; // end waiting for window to top
end; // end if we have a valid handle
end; // if window has not been found yet
if (hwndFoundLicenseWarning <=0) then
hwndFoundLicenseWarning := CitrixWaitForWindowCreation
("Citrix License Warning Notice", MATCH_Exact, 0x94C800C4,
0, 0, 0, 0, false, 1, true);
if (hwndFoundLicenseWarning > 0) then
if (CitrixWindowBringToTop(hwndFoundLicenseWarning)) then
CitrixKey(KEY_ENTER); // Press ok
CitrixWaitForWindow(hwndFoundLicenseWarning,
EVENT_Destroy);
// wait for it to go away
end; // end waiting for window to top
end; // end if we have a valid handle
end; // if window has not been found yet
nCount :=nCount+1;
Wait 1.0;
end; // while nCount
MeasureStop("MyCitrixStartup");
//
// return true if we handled any one of these conditions
//
MyCitrixStartup2 := (hwndFoundLicenseWarning > 0)
or (hwndICAHandle > 0) ;
print("MyCitrixStartup "
+ " vUser:" + string(GetUserId())
+ " Waited " + string(nCount) + " of " + string(nMaxWait)
+ " hwndICAHandle=" + string(hwndICAHandle)
+ " hwndFoundLicenseWarning=" + string(hwndFoundLicenseWarning),
OPT_DISPLAY_ERRORS , TEXT_GREEN );
end MyCitrixStartup;