Jump to content

Script failed as soon as I am losing focus while execution


Recommended Posts

Hi Guys, 

I am running my scripts .au3 and when its start, open window, and navigation as per script however if I clicked outside the screen then the script is losing its focus seems and executing somewhere in desktop or browser and start clicking here and there. 

How can I make sure my script will run properly even though I clicked outside the window.

Can somebody help ?

Link to comment
Share on other sites

Depends on what the script needs to do, can you put a reproductible script here?

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Developers
9 minutes ago, HiteshSharma said:

I am running my scripts .au3

Show the script and properly define the error you get.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks Careca, here we go
Run("xyz.exe","")

if WinExists($winTitle,"") Then
   ;Wait for some seconds and navigate
   Sleep(2000)
   Send("!f")
   Sleep(2000)
   Send("{ENTER}")
   Sleep(2000)
   Send("C:\Autoit")
   Sleep(3000)
   Send("{ENTER",false)
   Sleep(2000)
   Send("^a")
   Sleep(2000)

   Send("{BACKSPACE}")
   Sleep(2000)
   Send("CiAssignLog_ " & $string3 & ".txt")
   Sleep(5000)
   Send("{ENTER}",false)
EndIf

 

Once if condition is true then subsequent window will be open and if click anywhere outside the then I want to run my script and focu should come back again. Hope this help

Link to comment
Share on other sites

  • Developers

Have you tried using ControlXXX() functions? What is the program you are trying to automate?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

No, i haven't used Control functions. A script will open .exe, navigate to 2nd tab click on the menu bar and opens another window and generate the logs and then click on menu bar again and save as a local desktop.

I have used SendKeepActive("window name") and disable after action completed but I don't find this as the proper solution as it's working partially. 

Can you please share ex for control funtion ? 

H

Link to comment
Share on other sites

  • Moderators

Look at Control functions in the help file - ControlClick, ControlSend, etc. The examples in each will give you the best idea how the function works

"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

  • Moderators

What did you try regarding the Control commands, and what is the result? "It's broke" doesn't exactly help us help you.

"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

#include <Date.au3>
;Opt("WinTitleMatchMode",2)
Run("my exe path","")
;WinWaitActive("Untitled - Notepad")
;WinMenuSelectItem("Untitled - Notepad", "", "&File", "Save &As" )
WinWait("Database Options")
WinSetState("Database Options","")
;WinWait("Database Options")

ConsoleWrite("Test" & @CRLF)
ControlClick("Database Options","","[NAME:btnCancel]")
ConsoleWrite("Test2" & @CRLF)
ControlSend("CiAssign - No ABCS Connection","","","!f")
;Send("!f")
ConsoleWrite("Test3" & @CRLF)
ControlSend("CiAssign - No ABCS Connection","","","{ENTER}")
WinSetState("Save As","",@SW_HIDE)
;ControlClick("CiAssign - No ABCS Connection","","{ENTER}")
ConsoleWrite("Test4" & @CRLF)
;WinWait("Save As")

ControlSend("Save As","","Logssssssssssssss.txt","")
ConsoleWrite("Test6" & @CRLF)
;ControlClick("Save As","","{ENTER}")
ControlSend("Save As","","","{ENTER}")
ConsoleWrite("Test7" & @CRLF)

Link to comment
Share on other sites

  • Developers

There is still not enough information to go on.
Show us the information as shown by au3info for the windows/controls you are trying to do the ControlSend() for.

One thing that is for sure missing is the waiting for the correct window to appear. You will require spme WinWait() statements in there.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Okay Jos, thanks let me work out more into this and keep you posted. 

Can you please check my other query too. 

Is there any way we can run the script in the background before launch or immediately after launch?

I tried this

Run("path to.exe","","@SW_HIDE)

but its hide rest of the window ? 

Link to comment
Share on other sites

  • Moderators

One problem at a time: if you get the Control commands working, it will be easier to run the whole thing in the background.

"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

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...