Au­to­Hot­Key

Au­to­Hot­Key (kurz: AHK) ist ein klei­nes und fei­nes Au­to­ma­ti­sie­rungs­tool für Win­dows. Ich nut­ze AHK um vie­le NFON App User in kur­zer Zeit zu ak­ti­vie­ren. Was ist AHK:

Au­to­Hot­key is a free, open-source scrip­ting lan­guage for Win­dows that al­lows users to ea­si­ly crea­te small to com­plex scripts for all kinds of tasks such as: form fil­lers, au­to-cli­cking, macros, etc.

https://​www​.au​to​hot​key​.com

Ein­fach AHK her­un­ter la­den, das ge­wünsch­te ahk-Skript la­den und den ge­wünsch­ten Pro­gramm­teil per Hot­key star­ten.

Clou­dya Mi­gra­ti­on Wi­zard

Das fol­gen­de ahk-Skript au­to­ma­ti­siert die Ak­ti­vie­rung von NFON App Usern. App User ha­ben ei­ne gül­ti­ge E‑­Mail-Adres­se und der Na­me hat das For­mat “Nach­na­me, Vor­na­me”. Das Skript ak­ti­viert al­le User mit ei­ner (gül­ti­gen) E‑­Mail-Adres­se. Nach je­der Ak­ti­vie­rung er­tönt ein kur­zer 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
}
; --------------------------------------------------------------------------------

Schreibe einen Kommentar