Access VB Namespaces, Classes and Methods that are not an integrated part of UiPath: Check if ScrollLock, CapsLock, or NumLock are in effect

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.


@TDagsvik, thanks for your contribution.
Could I trouble you for a workflow that illustrates what you describe? I’m having trouble implementing it.
Thanks in advance,

Here you go:

Turn_ScrollLock_Off.xaml (12.6 KB)


Thank you very much for the workflow. I appreciate your effort. The comments are extremely helpful! I feel it’s going to be very useful for me going forward.
Best regards,


Happy to be of help, friend.