HiteshSharma

Script failed as soon as I am losing focus while execution

18 posts in this topic

#1 ·  Posted

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 ?

Share this post


Link to post
Share on other sites



#2 ·  Posted

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


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

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

BeatsPlayer - Music player.

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

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

9 minutes ago, HiteshSharma said:

I am running my scripts .au3

Show the script and properly define the error you get.

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

#4 ·  Posted

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

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

Share this post


Link to post
Share on other sites

#7 ·  Posted

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#8 ·  Posted

Hi Logan, i tried but its not working as expected 

Share this post


Link to post
Share on other sites

#10 ·  Posted

Hi Jos, I have shared the code and scenario above, can you please specify what you need. Happy to share the information wherever required. 

Share this post


Link to post
Share on other sites

#11 ·  Posted

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#12 ·  Posted

I tried with ControlSend and ControlClick both. In both the cases, it clicking on google setting button if I click outside the screen during execution.

Share this post


Link to post
Share on other sites

#13 ·  Posted

Show your code, please.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#14 ·  Posted

#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)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

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

#16 ·  Posted

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 ? 

Share this post


Link to post
Share on other sites

#17 ·  Posted

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#18 ·  Posted

Thank you

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