Capturar la dirección del navegador

Post Reply
User avatar
TOTOVIOTTI
Posts: 430
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina
Has thanked: 5 times

Capturar la dirección del navegador

Post by TOTOVIOTTI »

Buenas tardes:

¿Cómo puedo capturar desde mi aplicación, la ruta que indica mi navegador que está abierto?

Necesito tomar esa dirección, para realizar un procedimiento... tengo el navegador abierto y
desde mi sistema, necesito saber dónde está apuntando...

Muchas gracias
Roberto
Last edited by TOTOVIOTTI on Mon Sep 19, 2022 2:01 pm, edited 1 time in total.
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Capturar la dirección del navegador

Post by Antonio Linares »

Que navegador ?

Cualquier navegador ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
TOTOVIOTTI
Posts: 430
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina
Has thanked: 5 times

Re: Capturar la dirección del navegador

Post by TOTOVIOTTI »

Si es posible, si Antonio... del navegador que esté activo.
Sino, puedo llegar a lanzar uno y usar ese, pero para librarme de eso y que el usuario pueda
elegir el que más le guste...

Muchas gracias!
Roberto
Last edited by TOTOVIOTTI on Mon Sep 19, 2022 2:01 pm, edited 1 time in total.
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Capturar la dirección del navegador

Post by Antonio Linares »

Roberto,

You can use Ctrl + L ; Ctrl + C. This is valid for all the browser I have used.

You can also use F6; Ctrl + C this is working with chrome.

You can use F4; Ctrl + C. This is working with Firefox.

https://www.edureka.co/community/33916/how-to-get-the-url-of-the-current-tab-in-google-chrome

Tendrias que localizar el handle de la ventana del navegador y enviar esas combinaciones de teclas. El resultado queda en el clipboard.

Prueba asi: MsgInfo( FindWindow( "Chrome_WidgetWin_1", 0 ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Capturar la dirección del navegador

Post by Antonio Linares »

Estoy probando asi pero aun falla el envío de Ctrl+C

Code: Select all | Expand

#include "FiveWin.ch"

#define WM_ACTIVATE  0x0006

function Main()

   local hWndChrome := FindWindow( "Chrome_WidgetWin_1", 0 )

   PostMessage( hWndChrome, WM_ACTIVATE, 0x1, 0x056C )
   PostMessage( hWndChrome, WM_KEYDOWN, VK_F6, 0 )
   PostMessage( hWndChrome, WM_KEYUP, VK_F6, 0 )
   PostMessage( hWndChrome, WM_KEYDOWN, VK_CONTROL, 0 )
   PostMessage( hWndChrome, WM_KEYDOWN, Asc( "c" ), 0 )
   PostMessage( hWndChrome, WM_KEYUP, VK_CONTROL, 0 )
   PostMessage( hWndChrome, WM_KEYUP, Asc( "c" ), 0 )

   OpenClipboard( 0 )
   MsgInfo( GetClpData( 1 ) )
   CloseClipboard()

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Capturar la dirección del navegador

Post by Antonio Linares »

He probado también asi pero de momento no hay suerte:

Code: Select all | Expand

#include "fivewin.ch"

#define WM_ACTIVATE  0x0006

function Main()

   local hWndChrome := FindWindow( "Chrome_WidgetWin_1", 0 )

   PostMessage( hWndChrome, WM_ACTIVATE, 0x1, 0x056C )
   Sleep( 500 )
   PostMessage( hWndChrome, WM_KEYDOWN, VK_F6, 0 )
   PostMessage( hWndChrome, WM_KEYUP, VK_F6, 0 )
   SendCtrlC()

   OpenClipboard( 0 )
   MsgInfo( GetClpData( 1 ) )
   CloseClipboard()

return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( SENDCTRLC )
{
   INPUT ip;
   ip.type = INPUT_KEYBOARD;
   ip.ki.wScan = 0;
   ip.ki.time = 0;
   ip.ki.dwExtraInfo = 0;
 
   // Press the "Ctrl" key
   ip.ki.wVk = VK_CONTROL;
   ip.ki.dwFlags = 0; // 0 for key press
   SendInput( 1, &ip, sizeof( INPUT ) );

   // Press the "c" key
   ip.ki.wVk = 'c';
   ip.ki.dwFlags = 0; // 0 for key press
   SendInput( 1, &ip, sizeof( INPUT ));

   // Release the "c" key
   ip.ki.wVk = 'c';
   ip.ki.dwFlags = KEYEVENTF_KEYUP;
   SendInput( 1, &ip, sizeof( INPUT ) );

   // Release the "Ctrl" key
   ip.ki.wVk = VK_CONTROL;
   ip.ki.dwFlags = KEYEVENTF_KEYUP;
   SendInput( 1, &ip, sizeof( INPUT ) );
   
   Sleep( 1000 ); // pause for 1 second
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
TOTOVIOTTI
Posts: 430
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina
Has thanked: 5 times

Re: Capturar la dirección del navegador

Post by TOTOVIOTTI »

Muchas gracias Antonio!

La consulta es, se podrá?
He probado con el formato que me pasas y no tengo el resultado tampoco...

Roberto
Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.ar
User avatar
TOTOVIOTTI
Posts: 430
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina
Has thanked: 5 times

Re: Capturar la dirección del navegador

Post by TOTOVIOTTI »

Antonio,
si lanzo mi url a WebView, no puedo obtener el resultado en algún dato?

Veo que la WebView tiene un par de datas pero no devuelve eso.

Avísame cuando puedas!
Gracias!!
Last edited by TOTOVIOTTI on Mon Sep 19, 2022 2:01 pm, edited 1 time in total.
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Capturar la dirección del navegador

Post by Antonio Linares »

Usando WebView es muy sencillo:

Code: Select all | Expand

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWebView := TWebView():New()

   oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
   oWebView:Bind( "SendToFWH" )
   oWebView:Navigate( "https://www.google.com" )
   Sleep( 200 )
   oWebView:Eval( "SendToFWH( document.URL )" )
   oWebView:Run()
   oWebView:Destroy()

return nil

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
TOTOVIOTTI
Posts: 430
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina
Has thanked: 5 times

Re: Capturar la dirección del navegador

Post by TOTOVIOTTI »

Gracias Maestro... intentaré ver si puedo aplicar esto...

muchas gracias!!!!!!
Saludos, Roberto...
Post Reply