Jump to content

Recommended Posts

Posted

Hello all,

I have developed a code to use WinActivate to login to an application for validation/testing. If I RDP to the machine, the code executes successfully. 

However, if I use an interactive console session, it does not work. I initially thought the root cause was related to the screen resolution, but even after settings the resolution to 1920x1080, the issue still persists.

I would greatly appreciate your help. Thank you in advance!

-SK

  • 2 weeks later...
Posted

 

Thank you for your response.

 

Here are some additional details:

The automation is compiled as an executable and launched through Windows Task scheduler. Its purpose is to open Microsoft Dynamics GP, log in and perform application validation. 

When an RDP session is active and the EXE is launched, it runs successfully. When it runs in the console environment, it reaches the window-activation portion of the code and does not proceed.  Changing the screen resolution to 1920x1080 did not resolve the issue. 

This appears to be related to the Windows session or interactive desktop used by Task Scheduler rather than resolution. The task is configured to run only when the user is logged on and that is all configured properly at the OS level. 

I am providing the code snippet for review.

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

FileWriteLine($sLog, "Waiting for the GP Window")

Local $hGP = WinWait("Microsoft Dynamics GP", "", 180)

if  $hGP =0 Then
    $sStatus = "Failed"
    $sErrorMessage = "GP login window not found within 180 seconds."
    SendStatusMail($sStatus, $sErrorMessage)
    Exit
EndIf

FileWriteLine($sLog, "Attempting to activate GP Window")
WinActivate($hGP)

Sleep(2000)

Local $hActive=WinGetHandle("[ACTIVE]")
FileWriteLine($sLog, "Active Window handle after WinActivate")

If Not WinWaitActive($hGP, "", 30) Then
    $sStatus = "Failed"
    $sErrorMessage = "GP login window found but could not be activated."
    SendStatusMail($sStatus, $sErrorMessage)
    Exit 1
EndIf

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

Posted (edited)

When you post code, please use the method shown in the link.

The code you provide doesn't help a bit.  We cannot run this.  You need to post a runnable code that  we can actually see the issue.

But at first glance, your code is running on a different privilege level (I'm probably wrong on this).

Edited by Nine

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...