user32 dll not getting imported.

santosh dhere

New Member
Hi Team

I am trying to import dll user 32 as i want to use IntPtr in blue prism code snippet but blue prism is not able to recognize that keyword.

I think i am importing user 32 dll in wrong way. My code snippet is as below.

========================================================

[DllImport ("user32")]
private static extern IntPtr FindWindow(string ipClassName, string ipWindowName)

[DllImport ("user32")]
private static extern bool SetForegroundWindow (IntPtr hWnd)

======================================================

Its not working. Please advice if anybody worked with user32 dll before
 

VJR

Well-Known Member
Hi santosh dhere,

The user 32.dll and FindWindow both are used in the Global Code of the Ms Excel VBO (Initialise tab).
You can take a look there for its usage, but also be noted that not all features are fully supported in Blue Prism yet.
 

anisjolly

Administrator
I would suggest you take a look at the Object's Global Code / Named References to see if you need to reference it there. You can access these tabs by double clicking the information box on the Initialise page.

Like @VJR suggested, take a look at the Excel VBO (including Global Code and Named References) and see how it has been defined there.
 

santosh dhere

New Member
HI VJR/anisjolly

Thanks a ton for your input. I could able to use global code. I added below code in global code & tried to remove all compilation error.

================================================================

[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);

public void KeyPress()
{
IntPtr zero = IntPtr.Zero;
for (int i = 0; (i < 60) && (zero == IntPtr.Zero); i++)
{
Thread.Sleep(500);
zero = FindWindow(null, "Untitled - Notepad");
}
if (zero != IntPtr.Zero)
{
SetForegroundWindow(zero);
SendKeys.SendWait("{ENTER}");
SendKeys.SendWait("{ENTER}");
SendKeys.SendWait("{ENTER}");
SendKeys.Flush();
}
}

=====================================================

Trying to send keys on Notepad in background.

But i am getting one error in initialize stage -
"The type or namespace name 'VisualBasic' does not exist in the name Microsoft"

Please suggest your input. I tried to refer Microsoft.VisualBasic in namespaces of code option but no luck. Please suggest if i am missing something.

Regards

Santosh
 

VJR

Well-Known Member
Hi santosh dhere,

The 'Utility - File Management' VBO has actions to directly write something on a text file so there doesn't appear to be a reason for using Sendkeys on Notepad.

Even if you would like to use Sendkeys on Notepad, you can still spy the Notepad window to activate the application, and the inside text area and write to it without making use of any dlls or ptr.
 

santosh dhere

New Member
Hi VJ

Thanks a ton for your support prompt. You guys are really awesome.

Actually i will explain the pain area.

I want to perform action one one of IBM background application. Blue prism is not able to identify the object, so we tried using Region Method, but region method works fine in foreground mode not in background mode (Unattended mode).

I want to perform action on silverlight & IBM application in unattended mode, so i took notepad for experiment to send keys in unattended mode.

I don't want to use 'Utility - File Management' VBO for updating the notepad, i want to send keys in unattended mode to notepad(Just for checking send keys works in background). If send keys works in background then i will use it for IBM application automation.

Please suggest
 

santosh dhere

New Member
HI VJ

Bingo we can able to clicks on background application. I added visual basic dll in code option & global code started working.

I only facing problem now code is not able to click when Blue prism VDI is in unattended mode.

Thanks VJ now only this issue is peding.
 

anisjolly

Administrator
Hi @santosh dhere

Is it because the VDI locks or goes to screensaver? Can your IT dept create a policy where the VDI doesn't lock or power down when not being used as this will cause issues.

The only way to potentially tackle this is by using something like Dameware or TightVNC to log the VDI's on and then run the automations on them.
 

santosh dhere

New Member
Hi @anisjolly

Policy is in place on their VDI. We already did it. VDI never gets locked & doe not go on screensaver mode. It goes in sleeping mode(Inactive).

We have handled Mainframe application key events through send keys but for custom objects send keys are not working.

Surface automation does not work in inactive mode so i am trying to do it using C# code but no luck.

Please see if you can help me in this.
 

anisjolly

Administrator
You'd have to look at a way to disable sleep mode using the GPO (Group Policy). If that doesn't work then the next best option is to use either Dameware or TightVNC to logon to the machine, which should keep the machine active.
 
Top