sn2006

WinActivate does not work on some applications

9 posts in this topic

Hi,

I am working on a script and facing problems with WinActivate and other windows functions. It works on some applications e.g. Notepad and Excel but does not work on Omnesys Nest Trader application. I want to restore this application from the minimized state. On running the script I can see the focus on the application in the taskbar but application does not restored. But it can restore Notepad and Excel etc. My OS is Windows 10, 64 bit. The script is just a single line.

WinActivate("Welcome DS")

I have also tried with hwnd, process id, winsetstate etc. but none is working for this application.

Please tell me what is wrong.

Thanks.

SN2006

Share this post


Link to post
Share on other sites



I have already tried it with @sw_maximize and @sw_restore parameters but it is not working for this application.

Share this post


Link to post
Share on other sites

Are you compiling the function and running it under normal permissions or as an administrator?  Are the windows which are not affected by WinActivate being launched/need to be launched with administrative rights?  If so, in order to have your script successfully manipulate the windows, you need to run them with admin credentials (require admin when compiling).  I had an issue a while back trying to automate application installs by clicking controls and progressing through windows, but since most applications require admin credentials to write to Program files, it didn't work until it was compiled with "require admin".  Hope this helps.

Share this post


Link to post
Share on other sites

I am running script directly (without compiling) with admin rights. I just want to activate the program from the minimized state and the script has nothing to manipulate the windows. The application program can be run without admin rights (just like Excel, Word etc).

Share this post


Link to post
Share on other sites

Have you checked whether there are more windows (winlist) with the same name stopping you from restoring he correct one?

Jos

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yes, I have checked this in the Taskbar and Windows Task Manager. There is only one window with this title. WinActivate("Welcome DS") returns 0 if I close the application and returns 1 when the application is running but unable to restore it from the minimized state. If the application is not minimized but covered by other windows then WinActivate brings it to the top (get focus for keyboard and mouse).

Share this post


Link to post
Share on other sites
1 minute ago, sn2006 said:

Yes, I have checked this in the Taskbar and Windows Task Manager. There is only one window with this title. WinActivate("Welcome DS") returns 0 if I close the application and returns 1 when the application is running but unable to restore it from the minimized state. If the application is not minimized but covered by other windows then WinActivate brings it to the top (get focus for keyboard and mouse).

Correction: WinActivate returns handle for this application if it is running and returns 0 if application is closed.

Share this post


Link to post
Share on other sites

#9 ·  Posted

On 5/21/2016 at 11:36 PM, MattHiggs said:

Are you compiling the function and running it under normal permissions or as an administrator?  Are the windows which are not affected by WinActivate being launched/need to be launched with administrative rights?  If so, in order to have your script successfully manipulate the windows, you need to run them with admin credentials (require admin when compiling).  I had an issue a while back trying to automate application installs by clicking controls and progressing through windows, but since most applications require admin credentials to write to Program files, it didn't work until it was compiled with "require admin".  Hope this helps.

I'm adding to this post to help future searchers.

@MattHiggs had it right, but the answer wasn't obvious to me because I wasn't "compiling" to an .EXE - just "running a script" - (yah - I get it) ... and I did not know about AutoIt's #RequireAdmin directive.

In my case (on Windows 10) I was trying to restore a minimized CMD window that had been opened with [Run as Administrator].  WinActivate() would bring it from the back and give it focus if it was available as an open background window - but it would not restore it from its minimized state.

Adding the #RequireAdmin directive to my script solved the problem.

That's a really strange behavior, even for UAC, since the user at the keyboard can restore an admin-opened window ... but, hey! ... I didn't write Windows - I just have to figure out how to work around all of its issues.

Share this post


Link to post
Share on other sites

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