Need help for checking google connection

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Oriven
Posts: 1
Joined: 09 Feb 2024, 05:35

Need help for checking google connection

Post by Oriven » 09 Feb 2024, 05:44

Here is the function i use to check a google connection but it doesn't work i would need help in order to do this as it is the last step of something i am making (i am still a beginner so please don't judge my level):

Code: Select all

CheckGoogleLogin()
{
    ControlGetText, PageSource, Chrome_RenderWidgetHostHWND1, ahk_exe chrome.exe
    if InStr(PageSource, "Se déconnecter")
        return true 
    else
        return false
}
i use it like this:

Code: Select all

#i::
IfWinExist, ahk_exe chrome.exe
{
    WinActivate
    Sleep, 200
    if (CheckGoogleLogin())
    {
        Send, ^t 
        Sleep, 200
        Clipboard := "https://cas-uds.grenet.fr/login?service=https%3A%2F%2Fintranet.univ-smb.fr%2F"
        Send, ^v
        Sleep, 200
        Send, {Enter}
    }
    else
    {
        Send, ^t 
        LoginGoogle()
    }
}
else
{
    Run, chrome.exe
    Sleep, 500
    WinMaximize
    Send, ^t
    LoginGoogle()
    Send, ^t 
    Sleep, 200
    Clipboard := "https://cas-uds.grenet.fr/login?service=https%3A%2F%2Fintranet.univ-smb.fr%2F"
    Send, ^v
    Sleep, 200
    Send, {Enter}
}
return
i won"t be putting the code for the login function as it has private information but if someone can help it would be very appreciated.

User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

Re: Need help for checking google connection

Post by lmstearn » 10 Feb 2024, 00:31

Hi, and welcome to AHK. :)

Have up-to-date Chrome on W11 here and tested the contents of PageSource for any tab/window, and all it revealed was:
Chrome Legacy Window
Pretty sure that's going to remain the same after logging out of Google.
This bit runs well enough, no confusion at all if Chrome has one window and one tab.

Code: Select all

CheckGoogleLogin()
IfWinExist, ahk_exe chrome.exe
WinActivate
Sleep, 200
Send, ^t 
Sleep, 200
Clipboard := "https://cas-uds.grenet.fr/login?service=https%3A%2F%2Fintranet.univ-smb.fr%2F"
Send, ^v
Sleep, 200
Send, {Enter}
When it comes to pasting the password into the login box with a script like LoginGoogle(), it's a different story, since the login field is an HTML element. Only way to interact with it is using tools such as Chrome.ahk, Rufaydium, or pure COM.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Post Reply

Return to “Ask for Help (v1)”