I could not figure out how to check if the ScrollLock key was in effect without using screen scraping. I knew that there were several ways of doing this with VB code, but none of the necessary namespaces was available to me in UiPath Studio. Fortunately, it is possible to load namespaces, classes and methods in UiPath, which means that everything you can do in VB, you can essentially do in UiPath.
In my case, I needed the method isKeyLocked() which is contained in the Control class within the Forms namespace. Here’s how one could do it:
#Load the Forms namespace/assembly:
[Assembly] formsA = System.Reflection.Assembly.LoadWithPartialName(“System.Windows.Forms”)
#Load the Control class/type:
[Type] controlT = formsA.GetType(“System.Windows.Forms.Control”)
#Load the isKeyLocked method:
[MethodInfo] keylockedM = controlT.GetMethod(“IsKeyLocked”)
#Create an instance of the Control class:
[Object] controlI = Activator.CreateInstance(controlT)
#Get the ScrollLock key, which is contained in the Keys enumerator with the index 132:
[Object] scrollKey = formsA.GetType(“System.Windows.Forms.Keys”).GetEnumValues.GetValue(132)
#Invoke the isKeyLocked method with the scroll key as a parameter:
[Boolean] keyLocked = keylockedM.Invoke(controlI, {scrollKey})
Hope this saves someone any trouble.