BigDaddyO Posted April 12, 2019 Share Posted April 12, 2019 Some background on what I'm doing. I'm trying to build a version of the Citrix ControlUp Logon Simulator in order to perform multiple logins with different accounts from the same system so I can run some automated tests. The existing ControlUp free app doesn't do exactly what I wanted, and since it was free, I figured it must not have been difficult so I looked into it and found the Citrix ICAClient API's. It seems like my script will work, but I have to sit down with my Citrix guys to figure out the proper connection address as I'm connecting, but it's disconnecting shortly after. Now for my question. Each connection will need it's own ObjCreate() and ObjEvent() since they are using different credentials. There are 35 events that I need to watch for each ObjCreate() to know what the sessions are doing. Is there a way to know what Object is initiating the event so I know which Session just did what? Right now, the only thing I can think of is to hard code the 35 event functions 20+ times, or to launch my script 20+ times each with a different account. below is my POC code and a small sample of the Event functions. expandcollapse popupGlobal $aUsers[20][3] ;[][0] = username, [][1] = password, [][2] = citrixIP, [][3] = publishedDesktop/App Global $oICA[20][2] ;Create an array to store the connected object and Events for each user we will be connecting with ;Move through each user and connect to the specified Citrix box For $u = 0 to UBound($aUsers) - 1 $oICA[$u][0] = ObjCreate("Citrix.ICAClient") If @error Then ConsoleWrite("Failed to connect to ICA" & @CRLF) Exit Else ConsoleWrite("Sucessfully connected to ICS" & @CRLF) EndIf ;Each of the ICA objects will need their own event functions?!? $oICA[$u][1] = ObjEvent($oICA[$u][0], "ICO_") ;Register all of the events that can be returned. Add them as Func ICO_eventname() If @error Then ConsoleWrite("Failed to trap com events" & @CRLF) ;Cant easily use the Events with the loop, so simply query waiting for the connected or disconnected, and the OnWindowDisplayed() > 0 With $oICA[$u][0] ;These will set the Display settings within the connected desktop .DesiredColor = 8 ;Default = 1 which is 16 color which should be fine if not checking for colors, 4 = 16bit, 8 = 24bit, 16 = 32bit .DesiredHRes = 1024 .DesiredVRes = 768 ;These will set how that connected desktop will be displayed within the connection .ScalingMode = 2 .ScalingWidth = 640 .ScalingHeight = 480 .Username = $aUsers[$u][0] .SetProp("ClearPassword", $aUsers[$u][1]) ;Apparently in .ica %temp% folder while connected I can grab the encrypted password to store in db, but would be manual process .Domain = @LogonDomain .Address = $aUsers[$u][2] ;Starts, but seems to be refused as it closes shortly after opening .InitialProgram = $aUsers[$u][3] ;What Published app/Desktop we want to launch on that server .Launch = True ;Open the Citrix application window instead of trying to embed in my own app. .Connect() ;Connect to the specified Citrix server/application/ICA... EndWith Next ;Loop waiting for events to occur $hTimer = TimerInit() While 1 sleep(100) WEnd ;Do I really need to duplicate all of these 20+ times IC0_ > IC19_? or is there some way to know which Object called the event? Func ICO_OnConnect() ConsoleWrite("OnConnect() was triggered" & @CRLF) EndFunc Func ICO_OnConnectFailed() ConsoleWrite("OnConnectFailed() was triggered" & @CRLF) ConsoleWrite("OnConnectFailed Error = " & $oICA.GetErrorMessage($oICA.GetLastError) & @CRLF) ConsoleWrite("OnConnectFailed Client_Error = " & $oICA.GetErrorMessage($oICA.GetLastClientError) & @CRLF) Exit EndFunc Func ICO_OnConnecting() ConsoleWrite("OnConnecting() was triggered" & @CRLF) EndFunc Func ICO_OnDisconnect() ConsoleWrite("OnDisconnect() was triggered" & @CRLF) ConsoleWrite("OnDisconnect Error = " & $oICA.GetErrorMessage($oICA.GetLastError) & @CRLF) ConsoleWrite("OnDisconnect Client_Error = " & $oICA.GetErrorMessage($oICA.GetLastClientError) & @CRLF) Exit ;Exit the script since we have been disconnected for some reason. Assuming a refused connection EndFunc Thanks for any pointers you can offer. Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2019 Share Posted April 12, 2019 I don't know nothing about citrix, but normally, the first parameter of an event function is the object. With ObjName, you have the possibilities of knowing which object is which. Hope that helps... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
water Posted April 12, 2019 Share Posted April 12, 2019 Have a look at macro @COM_EventObj My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
BigDaddyO Posted April 12, 2019 Author Share Posted April 12, 2019 1 minute ago, water said: Have a look at macro @COM_EventObj Sweet! looks like just what I wanted. Thanks Water. Link to comment Share on other sites More sharing options...
water Posted April 12, 2019 Share Posted April 12, 2019 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now