Jump to content

.au3 runs locally, but fails on Windows Server 2012 (data server R2)


Recommended Posts

All,

Tried hard to find anything (topic etc.) on this specific subject but did not find anything. I am totally new to autoIT.

I have written the simplistic script below. When I run this locally on my own laptop, nothing goes wrong except for a /ErrorStdOut which does not terminate the running of the script at all. However, when I try to run* this on a Windows Server 2012 VM, just nothing happened? (only the error appears)

I googled the keys out of my keyboard, but no helpfull results.

*e.g. installed au3 on the server, placed my data in a file on the machine and altered the WinWaitActive parameters to local titles, also the mouse coords are captured on the Server screen through remote DT.

#include <MsgBoxConstants.au3>
#Include <Clipboard.au3>
#include <Excel.au3>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;controleren voor uitvoeren script - startpositie =                                                               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Kladblok geopend met uit Excel gekopiëerde IP lijst (om te programmeren IPs)                                    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Sep2 Meterview geopend met geselecteerd meter "BMW", de template die wordt hergebruikt voor de reprogramming     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HotKeySet("{ESC}", "Terminate")
While 1
Sleep(500)
WinWaitActive("Naamloos - Notepad","")
Send("+{END}")
Send("^c")
Send("{HOME}")
Sleep(500)
Send("!{TAB}")
WinWaitActive("SEP2 MeterView 2014","")
Sleep(500)
Send("{TAB 10}")
Send("{DOWN 2}")
Send("{SPACE}")
Sleep(500)
Send("{BACKSPACE}")
Sleep(500)
Send("^v") ;plak IP adres
Send("^s")
Sleep(500)
Send("{UP 2}")
Send("+{TAB 11}")
Send("{DOWN 4}")
MouseClick("left",186,318,2) ;selecteer de goeie BMW config in treeview
Sleep(500)
MouseClick("left",340,220,2) ;selecteer alle waardes uit de config
Sleep(100)
MouseClick("left",1273,160,1) ;relateer de om te programmeren meter aan de goeie configuratie
Sleep(100)
Send("{TAB}")
Sleep(50)
Send("{RIGHT}")
Sleep(50)
Send("{DOWN}")
Sleep(50)
Send("{RIGHT}")
Sleep(50)
Send("{DOWN}")
Sleep(50)
Send("{TAB}")
Sleep(50)
Send("{LEFT}")
Sleep(50)
Send("{SPACE}") ;relatie gelegd
Sleep(10000) ;sleeptime op te controleren of het goed gaat, of om te ESCen
MouseClick("left",469,221,1) ;start verzenden configuratie
Sleep(100)
Send("{TAB}")
Send("{SPACE}")
Sleep(600000)
MouseClick("right",136,246,1); nog toevoegen: vanuit status " gereed met omprogrammeren "  terug naar scherm setting met aan te passen BMW meter rechts in de tree geselecteerd
Sleep(100)
Send("{DOWN 17}"); properties openen
Sleep(100)
Send("{ENTER}")
Send("+{TAB}")
Sleep(200)
Send("!{TAB}"); terug naar Kladblok
WinWaitActive("[TITLE:Naamloos - Notepad]","")
Send("{DOWN}"); 1 rij naar beneden verplaatsen
WEnd

;Functies

Func Terminate()
    Exit 0
 EndFunc

 

Link to comment
Share on other sites

Not familiar with that app, but I would expect the mouse positioning to vary from machine to machine. What is the setting for MouseCoordMode?

Have you tried using AU3Info to see if the controls are accessible where you could using the proper commands (ControlGetText, ControlSetText, ControlSend, etc) instead of Send and MouseClick?

Link to comment
Share on other sites

Thank you for attempting helping me out Danp2! Much obliged in advance. The setting for MouseCoordMode, what exactly do you mean? I recorded the coords on the VM, shouldn't this be enough?

I tried ControlSend() instead of Send() on the first two Send() lines, in an attempt to follow your advice. Only test-executed these lines:

#include <MsgBoxConstants.au3>
#include <AutoITConstants.au3>
#Include <Clipboard.au3>
#include <Excel.au3>

Sleep(500)
WinWaitActive("Naamloos - Notepad","")
ControlSend( "", "", "+{END}" [, flag = 0])
Send("^c")
Send("{HOME}")
Sleep(500)
ControlSend( "", "", "!{TAB}" [, flag = 0])

Unfortunately this did not make a difference, still the script was running (checked in taskmngr and also inside SciTE, was able to terminate successfully) but did not do anything. Am I doing it wrong?

Fun fact is, before I edited the code this morning, I gave the code posted in my OP another go, and this time magically the first few lines of code where done successfully.. just before it died executing again without any logging in SciTE?!

Link to comment
Share on other sites

Add

AutoItSetOption("TrayIconDebug", 1)

at the top of your script.
Shows the current script line in the tray icon tip to help debugging.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

pranaynanda, water and Danp2 thank you for your replies. I found a solution for now, but not a very neat one. A former colleague of mine gave me the tip to add

MsgBox(0, "Test!", "test")

between lines to see how far the script would go. His reply came in just before I read these, so I thought adding this would tell me wich one of your tips I would follow up first. After adding this and executing, I discovered the script somehow got stuck at the navigation between windows, so adding MouseCoordMode and ControlSend (and reading in to these) would not do the trick unfortunately. I will read up on these later.

For now I fixed my issue through bypassing navigating via controls, and using the mouse. This fixed my issue.

One could still wonder why this

Send("!{TAB}")

does not work on a VM though. I unfortunately haven't found out.

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