Jump to content
Jacky-2007

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

Recommended Posts

Jacky-2007

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

 

Share this post


Link to post
Share on other sites
Danp2

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?

Share this post


Link to post
Share on other sites
Jacky-2007

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?!

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
pranaynanda

@Jacky-2007

10 hours ago, Danp2 said:

What is the setting for MouseCoordMode?

Opt("MouseCoordMode", 0)        ;1=absolute, 0=relative, 2=client

 

Share this post


Link to post
Share on other sites
Danp2

You can't just blindly call ControlSend. You need to know information about the desired control, which I why I recommended that you use AU3Info to see if the controls were accessible. Also, see the help file for an example of using ControlSend with Notepad.

Share this post


Link to post
Share on other sites
Jacky-2007

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.

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

×