Jump to content
Sign in to follow this  
SeanD215

Unusual Behavior in AutoIt running any scirpts (with Melba23 Authorization)

Recommended Posts

Hi all,

I have cleared this topic with Melba23. 

When I run any script in autoit in two of the three computers i have it installed,  it will not run until I click inside the AutoIt script. and any character intended to be send to any application ends up in the Autoit script. for example if i run this script to search for the word "Hello" in search engine;

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinActivate("Mozilla Firefox")
Sleep(500)

MouseClick(657,164)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

will end up looking like this

 

#include <MsgBoxConstants.au3>Hello

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinActivate("Mozilla Firefox")
Sleep(500)

MouseClick(657,164)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

Please note the word "Hello" after the #include line, where i clicked to start the script.  The script won't run no matter how long i wait after pressing the F5, till i click inside of the script.

what am i missing here???  in installation, or configuration.  my other computer is running fine, 2 of my other computers are just like this.  I have to run them from an executable to avoid this issue. and I have uninstall and reinstall the Autoit.  Could anyone care to explain??? I am pulling my hairs out.

Kind regards

Sean

Share this post


Link to post
Share on other sites

I have Windows 10 Enterprise in all the computers. I haven't tried edge and i will not use edge, but in chrome has the same issue, please see this

 

Before

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinActivate("New Tab - Google Chrome")
Sleep(500)

MouseClick(730,419)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

 

 

After

#include <MsgBoxConstants.au3>Hello

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinActivate("New Tab - Google Chrome")
Sleep(500)

MouseClick(730,419)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

I am not sure what you mean with ff Version, I constantly upgrade patches and run the computer with the latest files. all these 3 computers had been installed from the scratch (Clean installed).   

Share this post


Link to post
Share on other sites
2 minutes ago, SeanD215 said:

I have Windows 10 Enterprise in all the computers. I haven't tried edge and i will not use edge, but in chrome has the same issue, please see this

 

Before

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinActivate("New Tab - Google Chrome")
Sleep(500)

MouseClick(730,419)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

 

 

After

#include <MsgBoxConstants.au3>Hello

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinActivate("New Tab - Google Chrome")
Sleep(500)

MouseClick(730,419)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

I am not sure what you mean with ff Version, I constantly upgrade patches and run the computer with the latest files. all these 3 computers had been installed from the scratch (Clean installed).   

ff Version === Firefox version  ==>>  68.0.2 (64-bit)

Share this post


Link to post
Share on other sites

Try ie and edge as those browsers have different engines under the surface. If you have same issue on all browsers you know its not caused by the browser but probably some kind of uac. Did you try to run your script as admin. Are you all runing in 32 or 64 bit.

Share this post


Link to post
Share on other sites

This is using the WinMove in Chrome

before;

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinMove("New Tab - Google Chrome",0,0,1916,2118)
Sleep(500)

MouseClick(730,419)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

after

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinMove("New Tab - Google Chrome",0,0,1916,2118Hello)
Sleep(500)

MouseClick(730,419)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

Hello is inside the WinMove now.... that's where i was making the change last!

This is using IE

before

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinMove("Google - Internet Explorer",0,0,1916,2118)
Sleep(500)

MouseClick(709, 395)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

after

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

WinMove("Google - Internet Explorer",0,0,1916,2118)
Sleep(500)

MouseClick(709, 395Hello)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

The Hello ends up where i am making the last changes! now inside the MouseClick

Share this post


Link to post
Share on other sites

It worked correctly in Notepad...  

 

Before and after

#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    msgbox(0,'Ending','Macro Ended')
    Exit
 EndFunc

 Run("notepad.exe")
 Local $hWnd = WinWait("[CLASS:Notepad]", "", 50)

WinMove($hWnd,0,0,500,500)
Sleep(500)

MouseClick(709, 395)
Sleep(1000)

Send("H")
sleep(10)
Send("e")
sleep(10)
Send("l")
sleep(10)
Send("l")
sleep(10)
Send("o")
sleep(10)

 

Share this post


Link to post
Share on other sites

I used the winlist function and it all came out the same and the uninfected computer acted strange executing the same script (Same file).  When i use a script that i was using (a different file) on the computer that was running correct on this odd behaving computer it ran just fine!...  It seems that the script file must have been corrupted somehow.  is that possible?  I just opened and copy and paste some stuff, i can't see how i messed it up????  does it make sense?  still it is very strange to me...

Share this post


Link to post
Share on other sites

let me note that the new files i create with the infected computer act strange everywhere, but the file created with the other computer that run good is good everywhere.  even if i write from scratch the two identical scripts with no copying and pasting.   something is a miss in this installation

Share this post


Link to post
Share on other sites

I think you did point me to the right direction, I installed it using the Admin and now it is working just fine.  As you mentioned, it must have been a UAC setting that was preventing it.  thanks for your help.  At least now it is clear that running as admin must be a must considering my situation! maybe we can incorporate that into the installation requirement. So folks like me don't take your valuable time.

Much much appreciated your time and guidance

Thank you M23 for allowing my thread to be posted.

Share this post


Link to post
Share on other sites

Good to see its resolved.

 

Checkout also the UIAutomation thread in examples sections. That can be more robust and reliable to deal with elements and setting values.

 

You should be able to run autoit sendkeys without admin rights but indeed it can be influenced/prohibited if UAC is enabled.

I did not fully understand why it was working with notepad.exe

anyway another script that can deal with ff and chrome

#include <MsgBoxConstants.au3>

Example()

Func Example()
    consolewrite("Script has started")
    
    ; Retrieve a list of window handles.
    Local $aList = WinList()

    ; Loop through the array displaying only visable windows with a title.
;~  Alternative can be just a WinExists but this is easie when you have to debug/see which windowtitles are there
    For $i = 1 To $aList[0][0]
        If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
            $title=$aList[$i][0]
            $hwnd=$aList[$i][1]
;~             consolewrite("Title: " & $title & @CRLF & "Handle: " & $hwnd)
;~          if stringinstr($title, "Google Chrome") then ExitLoop
            if stringinstr($title, "Firefox") then ExitLoop

        EndIf
        $title="Not found"
        $hwnd=-1
    Next

    if $hwnd<> -1 Then
;~      #so we have found it lets move it to a fixed position
        winmove($hwnd, "", 10,10)
        winactivate($hwnd)
        sleep(1000)

        send("^l") ;~ activate addressbar
        sleep(250)

        send("www.google.com~{enter}")
        sleep(1000)
        send("hello{enter}")
        sleep(1000)

    Else
;~  no chrome window found
        consolewrite("No window found")
    EndIf

EndFunc   ;==>Example

 

 

Edited by junkew

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...