Wer kennt es nicht...man programmiert zu später Stunde und auf ein mal "KLINGELT DAS TELEFON" *Herzinfarkt*
Daher habe ich mich mal umgesehen wie ich als arme Vodafone Easybox Besitzerin mein Telefon ausstellen kann und auf dem Computer über Anrufe benachrichtigt werde.
Dabei bin ich auf die NCID Funktion gestoßen und habe mir die NCID-SDK durchgelesen.
Es gibt sicherlich schon einige fertige Tools, aber so wie ich gesehen habe noch keins in Autoit.
Zum anderen hat es mich doch sehr interessiert zu sehen wie das ganze funktioniert und was man so machen kann.
Daher hier nun für Euch, ein kleines Beispielscript zu diesem Thema NCID.
Die Funktionen im Überblick:
1. Verbindung prüfen und NCID Version erhalten
2.
Einlesen des Anrufer Logs (Noch keine Darstellung in Form einer Listview oder ähnlichem)
3. Auf einen Anruf warten und wenn dieser erfolgt, ein kleines Notify Fenster über der Taskbar anzeigen mit allen relevanten Informationen (Zeit/Datum,Anrufer Nummer, Nummer die angerufen wird)
Benutzung:
Script starten, IP eures Router eintippen und den NCID Port.
Bei einer Easybox wäre das 192.168.2.1 und Port 3333.
Vorausgesetzt es wurde im Routermenü die Funktion NCID gestartet.
Hier das erweiterbare Script:
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;##################################################
; NCID Anrufmonitor
; by JaneDoe...
; under Construction
;##################################################
#Include <ButtonConstants.Au3>
#Include <EditConstants.Au3>
#Include <GUIConstantsEx.Au3>
#Include <StaticConstants.Au3>
#Include <WindowsConstants.Au3>
#Include <GUIEdit.Au3>
#Include <Misc.Au3>
#include <Array.au3>
Opt ('GUIOnEventMode', 1)
TcpStartUp ()
Global $Server = -1
Global $TASKBAR_POS = WinGetPos("classname=Shell_TrayWnd")
Global $TIMERINIT = 0
Global $NotifyTime= 5000; 5 Sekunden
Dim $NOTIFY
Dim $TIME
$Settings = GUICreate ('NCID Einstellungen:', 180, 100, -1, -1, -1, 128)
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
GUICtrlCreateGroup ('', 5, 0, 170, 94)
$IP = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','IP', @IpAddress1), 12, 13, 100, 21, 1)
$Port = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','Port', 50), 117, 13, 50, 21, 1)
$Connect = GUICtrlCreateButton ('Connect', 12, 66, 100, 20, $WS_GROUP)
GUICtrlSetOnEvent ($Connect, '_Start')
$Exit = GUICtrlCreateButton ('Exit', 117, 66, 50, 20, $WS_GROUP)
GUICtrlSetOnEvent ($Exit, '_Exit')
GUISetState (@SW_SHOW)
WinSetOnTop ($Settings, '', 1)
$GUI = GUICreate ('NCID Anrufmonitor by JaneDoe', 375, 275, -1, -1, -1, 128)
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Toggle')
GUISetState (@SW_HIDE)
[/autoit] [autoit][/autoit] [autoit]While 1
Sleep (15)
;notify window...
If $TIMERINIT = 1 Then
If TimerDiff($TIME) > $NotifyTime Then
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $NOTIFY, "int", 500, "long", 327684)
While 1
$CALLHANDLE = WinGetHandle("Notify")
If $CALLHANDLE = "" And @error = 1 Then ExitLoop
GUIDelete($CALLHANDLE)
WEnd
$TIME = 0
$TIMERINIT = 0
EndIf
EndIf
;connection...
If $Server <> -1 Then
$Recv = TcpRecv ($Server, 1000000)
If @Error Then
GUISetState (@SW_HIDE, $GUI)
WinSetOnTop ($GUI, '', 0)
Sleep (100)
MsgBox (48, 'Server Notice','You have been disconnected from the server.')
_Disconnect ()
EndIf
If $Recv >""Then
$ncid_input = StringSplit($Recv, @CRLF) ; split zeilen
If $ncid_input[0] <> 0 Then
for $i = 1 to $ncid_input[0]-1 ; loope die zeilen
if $ncid_input[$i]<>"" then ; wenn nicht leer...
$StrCount = StringInStr($ncid_input[$i], ":") ; split zeilen
$command = StringLeft($ncid_input[$i], $StrCount) ; get command only
if StringInStr($command, "200")=1 then ; ncid version info + connected to ncid server
$NcidVersion = StringTrimLeft($ncid_input[$i], $StrCount); remove command
$NcidVersion = StringStripWS($NcidVersion, 1)
; Connect Icon auf Grün stellen
;MsgBox(0, "Connected", $NcidVersion)
elseif $command="CIDLOG:" then ; anrufer log
$NcidValue = StringTrimLeft($ncid_input[$i], $StrCount) ; remove command
$NcidSplit = StringSplit($NcidValue, '*') ; split zeilen
;_ArrayDisplay($NcidSplit, "test")
;Date Format...
$command1 = StringLeft($NcidSplit[3], 2)
$command2 = StringMid($NcidSplit[3], 3, 2)
$command3 = StringRight($NcidSplit[3], 2)
$Call_Date= $command1 & "." & $command2 & ".20" & $command3
;Time Format...
$command1 = StringLeft($NcidSplit[5], 2)
$command2 = StringRight($NcidSplit[5], 2)
$Call_Time = $command1 & ":" & $command2
;Nummer die angerufen wurde...
$CallingID = $NcidSplit[7]
;Nummer die angerufen hat...
$CallerID = $NcidSplit[9]
;in Listview einfügen...
;eventuell mit Telefonbuch Einträgen vergleichen...Name, Bild usw.
;MsgBox(0, "Log", "Date:" & $Call_Date & " Time:" & $Call_Time & " Called:" & $CallingID & " Caller:" & $CallerID)
elseif $command="CID:" then ; aktueller anruf
$NcidValue = StringTrimLeft($ncid_input[$i], $StrCount) ; remove command
$NcidSplit = StringSplit($NcidValue, '*') ; split zeilen
;_ArrayDisplay($NcidSplit, "test")
;Date Format...
$command1 = StringLeft($NcidSplit[3], 2)
$command2 = StringMid($NcidSplit[3], 3, 2)
$command3 = StringRight($NcidSplit[3], 2)
$Call_Date= $command1 & "." & $command2 & ".20" & $command3
;Time Format...
$command1 = StringLeft($NcidSplit[5], 2)
$command2 = StringRight($NcidSplit[5], 2)
$Call_Time = $command1 & ":" & $command2
;Nummer die angerufen wurde...
$CallingID = $NcidSplit[7]
;Nummer die angerufen hat...
$CallerID = $NcidSplit[9]
;Anruf in Listview speichern...
;eventuell mit Telefonbuch Einträgen vergleichen...Name, Bild usw.
;Norify Window anzeigen
Notify($Call_Time,$Call_Date,$CallingID,$CallerID)
endif
endif
Next
endif
endif
EndIf
WEnd
Func _Disconnect ()
TcpCloseSocket ($Server)
$Server = -1
GUISetState (@SW_HIDE, $GUI)
WinSetOnTop ($GUI, '', 0)
GUISetState (@SW_SHOW, $Settings)
WinSetOnTop ($Settings, '', 1)
EndFunc
Func _Toggle ()
TcpCloseSocket ($Server)
$Server = -1
GUISetState (@SW_HIDE, $GUI)
WinSetOnTop ($GUI, '', 0)
GUISetState (@SW_SHOW, $Settings)
WinSetOnTop ($Settings, '', 1)
EndFunc
Func _Start ()
If GUICtrlRead ($IP) == '' Or GUICtrlRead ($Port) == '' Then Return @Error
$Server = TcpConnect (GUICtrlRead ($IP), GUICtrlRead ($Port))
If $Server = -1 Or @Error Then
WinSetOnTop ($Settings, '', 0)
Sleep (100)
MsgBox (16, 'Fatal Error','Unable to connect to the server, change your settings and try again.')
WinSetOnTop ($Settings, '', 1)
Return @Error
EndIf
Sleep (150)
TcpSend ($Server, ""); <.. start commando
GUISetState (@SW_HIDE, $Settings)
WinSetOnTop ($Settings, '', 0)
GUISetState (@SW_SHOW, $GUI)
WinSetOnTop ($GUI, '', 1)
EndFunc
Func _Exit ()
IniWrite ('Settings.ini','Settings','IP', GUICtrlRead ($IP))
IniWrite ('Settings.ini','Settings','Port', GUICtrlRead ($Port))
Exit
EndFunc
Func Notify($CallTime,$CallDate,$CallNumber,$CallerNumber)
$NOTIFY = GUICreate("Notify", 302, 149, @DesktopWidth - 302, @DesktopHeight - (190 + $TASKBAR_POS), $WS_POPUP)
GUISetBkColor(0)
WinSetOnTop($NOTIFY, "", 1)
$LABEL1 = GUICtrlCreateLabel("Anrufer: " & $CallerNumber, 8, 32, 286, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 32768)
$LABEL2 = GUICtrlCreateLabel("Angerufene Nummer: " & $CallNumber, 8, 80, 278, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 32768)
$LABEL3 = GUICtrlCreateLabel("Uhrzeit: " & $CallTime, 8, 56, 284, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 32768)
$LABEL4 = GUICtrlCreateLabel("Datum: " & $CallDate, 8, 104, 284, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 32768)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $NOTIFY, "int", 500, "long", 262152)
GUISetState(@SW_SHOW)
$TIME = TimerInit()
$TIMERINIT = 1
EndFunc
Ich denke ich werde das für mich persönlich die Tage erweitern, um ein Telefonbuch wo mir bei Anrufen dann ein vorhandener Name zur Rufnummer angezeigt wird, ein Anruferlog wenn man mal außer Haus ist usw.
Möglichkeiten gibt es sehr viele, die Grundfunktionen sind ja in dem Script vorhanden.
Viel Spaß bei der Nutzung und eventuellen Anpassung