AutoHotKey (kurz: AHK) ist ein kleines und feines Automatisierungstool für Windows. Ich nutze AHK um viele NFON App User in kurzer Zeit zu aktivieren. Was ist AHK:
AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as: form fillers, auto-clicking, macros, etc.
https://www.autohotkey.com
Einfach AHK herunter laden, das gewünschte ahk-Skript laden und den gewünschten Programmteil per Hotkey starten.
Cloudya Migration Wizard
Das folgende ahk-Skript automatisiert die Aktivierung von NFON App Usern. App User haben eine gültige E‑Mail-Adresse und der Name hat das Format “Nachname, Vorname”. Das Skript aktiviert alle User mit einer (gültigen) E‑Mail-Adresse. Nach jeder Aktivierung ertönt ein kurzer Ton.
; --------------------------------------------------------------------------------
; AHK macro to automate NFON Cloudya Migration Wizard - (CMW)
; --------------------------------------------------------------------------------
; (c) Peter Wellmann, 19.09.2023
; --------------------------------------------------------------------------------
; CMW URL: https://nfon.telekom.net/auth/login
; Use Chrome brower, open CMW of your PBX, start AHK-script,
; press <strg> + <q>, follow instructions
; --------------------------------------------------------------------------------
; Global variables
; --------------------------------------------------------------------------------
global RowCounter := 25 ; rows/user per (inner) loop
global RowTimer := 2000 ; wait (ms) after each row/user
global WaitAfterRefresh := 2000 ; wait (ms) after browser refersh {F5}
global WaitAfterSend := 100 ; wait (ms) after each send()
global SwitchLanguage := 0 ; switch language from EN to DE by pressing {Up}
; --------------------------------------------------------------------------------
global WindowTitle := "Telekom: Migration Wizard" ; Telekom white label
; --------------------------------------------------------------------------------
;global WindowTitle := "Cloudya: Migration Wizard" ; NFON native
; --------------------------------------------------------------------------------
global NameDelimiter := ", " ; delimeter to split longname, optional empty
global NameOrder := 2 ; 2 = Lastname<Delimiter>Firstname
; --------------------------------------------------------------------------------
;global NameDelimiter := A_Space ; delimeter to split longname, optional empty
;global NameOrder := 1 ; 1 = Firstname<Delimiter>Lastname
; --------------------------------------------------------------------------------
global DefaultFirstName := "." ; default firstname if longname has no delimiter
; --------------------------------------------------------------------------------
;
; --------------------------------------------------------------------------------
; Emergency exit procedure
; --------------------------------------------------------------------------------
esc::
ExitApp
Return
; --------------------------------------------------------------------------------
; Main procedure. Start by pressing shortcut <strg> + <q>
; --------------------------------------------------------------------------------
^q::
; Ctrl + Q
Loop {
; outer loop
;-------------------------
; Validate browser window
if not VerifyWindow()
Break ; break outer loop
;-------------------------
MsgBox, 1,, Refresh %WindowTitle% window? Press <Enter>
IfMsgBox, Cancel
Break ; break outer loop and return
;Send {F5}
;Sleep, %WaitAfterRefresh%
;-------------------------
; Get OK from user
MsgBox, 1,, Courser in first e-mail address? Press <Enter>
IfMsgBox, Cancel
Break ; break outer loop and return
;-------------------------
Loop, %RowCounter% {
; inner loop
;-------------------------
; Validate browser window
if not VerifyWindow()
Break ; break inner loop and try again
;-------------------------
Clipboard := ""
SendCode("^a") ; highlight text
; Validate username (E-Mail)
SendCode("^c")
if ClipboardTimeout()
Break ; break inner loop and try again
email := Clipboard
if (!email) {
MsgBox, 0,, Error, no e-mail given!
Return ; end script !
}
;-------------------------
Clipboard := ""
SendCode("{Tab}") ; highlight text
; Split longname (e.g. "Lastname, Firstname") into parts
lastname := ""
firstname := ""
SendCode("^c")
if ClipboardTimeout() {
Break ; break inner loop and try again
}
longname := Clipboard
if (!longname) {
MsgBox, 0,, Error, no name given!
Return ; end script !
}
if (DefaultFirstName = "") {
lastname := longname
}
else {
if (NameOrder = 1 ) {
; Firstname<Delimiter>Lastname
firstname := StrSplit(longname,NameDelimiter," ").1
lastname := StrSplit(longname,NameDelimiter," ").2
}
else if (NameOrder = 2 ) {
; Lastname<Delimiter>Firstname
firstname := StrSplit(longname,NameDelimiter," ").2
lastname := StrSplit(longname,NameDelimiter," ").1
}
}
if (firstname = "") {
firstname := DefaultFirstName
}
; send lastname
SendCode(lastname)
;-------------------------
; send firstname
SendCode("{Tab}")
; Firstname
SendCode(firstname)
;-------------------------
SendCode("{Tab}")
if (SwitchLanguage = 1) {
; switch language: EN --> DE
Sleep, %LoopTimer%
SendCode("{Up}")
}
;-------------------------
SendCode("{Tab}")
; check App-Checkbox
; !! Seit dem 29.05.2020 ist die App-Checkbox voreingestellt !!
; SendCode("{Space}")
;-------------------------
SendCode("{Tab}")
; leave Admin-Checkbox unchecked
;-------------------------
SendCode("{Tab}")
; add / save / send
SendCode("{Enter}")
SoundBeep, 2200, 200
Sleep, %RowTimer%
;-------------------------
SendCode("{Tab}")
}
}
Return
; --------------------------------------------------------------------------------
; Subprocedures
; --------------------------------------------------------------------------------
SendCode(code) {
; send code an wait some msec
SendInput, %code%
Sleep, %WaitAfterSend%
}
VerifyWindow() {
; validate browser window
WinGetTitle, CurrentWinTitle, A
if not InStr(CurrentWinTitle, WindowTitle) {
MsgBox, 0,, Error, wrong URL! Please open %WindowTitle%
;~ Return 0 ; 0 = wrong window!
}
Return 1 ; 1 = ok
}
ClipboardTimeout() {
; wait for clipboard
ClipWait, 2
if ErrorLevel {
MsgBox, 0,, Error, clipboard is empty!
Return 1 ; 1 = timeout because no content!
}
Return 0 ; 0 = ok, no timeout
}
; --------------------------------------------------------------------------------