#Persistent #SingleInstance, force SetBatchLines, -1 ahp= ( AHKhttp-server 1.0 [var] ) paths := {} paths["/GV"] := Func("GV") paths["404"] := Func("NotFound") server := new HttpServer() server.SetPaths(paths) server.Serve(8000) ;******************************************************************************************************** ; Following code opens a GV window at start-up. ;******************************************************************************************************** Loop, 1 ; Set Browser bcode:=%A_Index% if (bcode = "B") or (bcode = "b") global browsr:="brave" else if (bcode = "E") or (bcode = "e") global browsr:="msedge" else if (bcode = "F") or (bcode = "f") global browsr:="firefox" else global browsr:="chrome" if WinExist("Voice - Settings") ; Does a GV Settings exist? { WinActivate Send !{Left} ; Go Back to GV Calls Sleep 200 } ;******************************************************************************************************** ; Messages window might cause problems, so close it. ; if it's not one of ther other tabs, assume Messages ;******************************************************************************************************** if WinExist("Voice") and !WinExist("Voice - Calls") and !WinExist("Voice - Voicemail") and !WinExist("Voice - Archive") and !WinExist("Voice - Spam") { WinActivate WinGetTitle, title, A call_vmail := " " ; Checking if title name is "Voice - (n) Calls or Voicemail" Loop, Parse, title, " " ; Parse window title { ; Checking window if missed calls or unplayed voicemail if (A_Loopfield="Calls") or (A_Loopfield="Voicemail") call_vmail := "X" ; Set switch if Calls or Voicemail } if (call_vmail != "X") ; Is window Calls or Voicemail? { ; No WinClose ; Close the Window Sleep 250 ; Script will now open a new Voice Calls window } } if not WinExist("Voice") { Run, %browsr%.exe --new-window "https://voice.google.com/u/0/calls" WinWait Voice - Calls ; Wait for GV Sleep 3000 } WinMinimize, Voice ; Minimize window return ;******************************************************************************************************** ; End start-up code. ;******************************************************************************************************** NotFound(ByRef req, ByRef res) { res.SetBodyText("Page not found") } GV(ByRef req, ByRef res) { global ahp SetTitleMatchMode, 1 dialnum:=req.queries["parm1"] ; Get parms fwdnum:=req.queries["parm2"] rbutt:=req.queries["parm3"] vertadj:=req.queries["parm4"] if fwdnum is not integer fwdnum:=1 if vertadj is not integer vertadj:=0 if WinExist("Voice - Settings") ; Does a GV Settings exist? { WinActivate Send !{Left} ; Go Back to GV Calls Sleep 200 } ;******************************************************************************************************** ; Messages window might cause problems, so close it. ; if it's not one of ther other tabs, assume Messages ;******************************************************************************************************** if WinExist("Voice") and !WinExist("Voice - Calls") and !WinExist("Voice - Voicemail") and !WinExist("Voice - Archive") and !WinExist("Voice - Spam") { WinActivate WinGetTitle, title, A call_vmail := " " ; Checking if title name is "Voice - (n) Calls or Voicemail" Loop, Parse, title, " " ; Parse window title { ; Checking window if missed calls or unplayed voicemail if (A_Loopfield="Calls") or (A_Loopfield="Voicemail") call_vmail := "X" ; Set switch if Calls or Voicemail } if (call_vmail != "X") ; Is window Calls or Voicemail? { ; No WinClose ; Close the Window Sleep 250 ; Script will now open a new Voice Calls window } } ;******************************************************************************************************** ; Following code processes a call using an existing GV window. ; This is normal call processing. ;******************************************************************************************************** if WinExist("Voice") ; Does a GV window exist? { WinActivate WinGetPos, X, Y, W, H, A ; Get coordinates of window M1 := (W//1.015) ; MouseClick 1.5% from right edge of window M2 := (A_ScreenHeight//3.2) ; and 31% of screen height from top edge of window if (H < A_ScreenHeight*.60) ; Window height less than 60% of screen height? ; A narrow screen with might cause a failure ; When window is very flat it scrools when tab to number field ; This causes subsequent calls to fail { SendInput #{Up} ; Maximize window - fixes above peoblem M1 := (A_ScreenWidth//1.015) ; MouseClick 1.5% from right edge of window Winmaxed := "Y" Sleep 200 } Send {Esc} ; Close any popups M2 := (M2 + vertadj) ; Vertical adjustment via parm4 If (rbutt="R") or (rbutt="r") ; Mouse buttons switched? MouseClick, Right, %M1%, %M2% ; Reposition cursor so only 1 tab needed for next step else MouseClick, Left, %M1%, %M2% Sleep 250 SendInput {Tab} ; Tab to outbound number field Sleep 100 SendInput %dialnum% ; Type outbound number SendInput {Enter} Sleep 1000 } ;******************************************************************************************************** ; End existing window code. ;******************************************************************************************************** else ;******************************************************************************************************** ; When script can't find a window name beginning with "Voice" ; opens a new GV window to process a call ; This happens when the GV window is closed or settings, etc., was clicked. ;******************************************************************************************************** { if (StrLen(dialnum) = 10) ; Outbound number 10 digits? dialnum := 1 . dialnum ; Add country code, otherwise will be treated as international call Run, %browsr%.exe --new-window "https://voice.google.com/u/0/calls?a=nc`,`%2b%dialnum%" WinWait Voice - Calls ; Wait for GV ;******************************************************************************************************** Sleep 2500 ; Pause until GV page fully loads ; This value works with with a 1st gen I3 and faster CPU's ; Slower computers might need to increase this value ;******************************************************************************************************** WinGetPos, X, Y, W, H, A ; Get coordinates of GV window M1 := (W//2) ; Calc coordinates of approx middle of window M2 := (H//2) If (rbutt="R") or (rbutt="r") ; Mouse buttons switched? MouseClick, Right, %M1%, %M2% ; Position cursor to middle of window for forwarding# selection else MouseClick, Left, %M1%, %M2% Sleep 600 } ;******************************************************************************************************** ; End new window code. ;******************************************************************************************************** ;******************************************************************************************************** ; Start of common code for new & existing GV window. ;******************************************************************************************************** SendInput {Tab} ; Tab to forwarding number selection SendInput {Enter} ; Enter to display the forwarding numbers Sleep 250 ;******************************************************************************************************** ; The script will use parm2 (fwdnum) to select the forwarding number ; Valid numbers are 1, 2 or 3 ; It will select the 1st when fwdnum is invalid or not specified ;******************************************************************************************************** if (fwdnum=2) ; Position cursor to 2nd forwarding number { SendInput {Down} Sleep 100 } if (fwdnum=3) ; Position cursor to 3rd forwarding number { SendInput {Down} Sleep 100 SendInput {Down} Sleep 100 } SendInput {Enter} ; Enter will select the forwarding number Sleep 500 SendInput {Tab} ; 2 tabs to "Connect" button SendInput {Tab} Sleep 100 SendInput {Enter} ; Enter to initiate callback Sleep 1500 if (Winmaxed = "Y") SendInput #{Down} Sleep 1500 WinMinimize ; Minimize window res.status := 200 } ;******************************************************************************************************** ; End common code. ;******************************************************************************************************** #Include %A_ScriptDir%\AHKhttp.ahk ; File muat be in same folder as Script #Include %A_ScriptDir%\AHKsock.ahk