Jump to content

Set focus after start program from the taskmanager


 Share

Recommended Posts

I have an autoit script that I need start it from the windows taskmanager.

But every time I start the script it continue its execution only if I click in the windows program.

I've tried a lot of things to bring the program to the top and set the focus, but nothing work.

My last code to try do it was:

Run('my_app.exe')
Local $hWnd = WinWait('Program title')
WinSetOnTop($hWnd, "", 1)
WinWaitActive('Program title')
WinActivate('Program title')
; To continue after this point I have to click in the my_app windows
Send("{CTRLDOWN}i{CTRLUP}")
(...)

What do I have to do ?

Regards.

Kleyson Rios.

Link to comment
Share on other sites

  • Moderators

Why do you "need to start it from the windows taskmanager"? That makes no sense. If it is compiled into an executable, why can you not double click on it to launch?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Because the autoit script is part of an automated process that I need to run every day at night.

I mean, a have a process to upload some files to the server at the end of day and at night my autoit script need read those files to do some operations.

Link to comment
Share on other sites

Depends what your app is doing, if it is started by task manager then it becomes a child of task manager, if your app is trying to automate some admin stuff, then task manager would need to be running as admin.

A non admin process cannot automate an admin process (> XP)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

John, my script basically open an application, send some commands as, Send("{CTRLDOWN}i{CTRLUP}"), to import some files and extract some information.

As I said in my first post, the script stop in the line "Send("{CTRLDOWN}i{CTRLUP}")", my application is opened, maximized and on top. But my script continue its execution only if I click on the application window to set the focus.

Link to comment
Share on other sites

Unless you are logged in, and have the task run as 'logged in user', you'll have to take this into account:

https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F

There are ways around this with PAExec (freeware), as well...would still require a user session to be logged in.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...