Jump to content

Web browser URL checker


Recommended Posts

#include <IE.au3>
$oIE = _IECreate()
_IEBodyWriteHTML($oIE, "Now navigate to your desired Web-Page")
MsgBox(64 + 262144, Default, "Click OK when disired Web-Page is active", 0)
$sURL = _IEPropertyGet($oIE, "locationurl")
$sName = _IEPropertyGet($oIE, "locationname")
MsgBox(64 + 262144, Default, $sURL & @LF & $sName, 0)
_IEQuit($oIE)

 

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

On 2016-05-28 at 10:04 PM, MichaelHB said:

Yes. Look here.

Thanks for that. Though, I'm really a beginner so I don't understand very much of what it does. Could you please explain to me or take out only the strings of code that I need? I've tried for a while now, and I can make it work partly. Though it dumps xml files to my desktop every time I run the code, which is very annoying! How do I get rid of that? And how do I get the simpliest possible code?

Thank you for your help.

Link to comment
Share on other sites

Marzupilami,

Let me see what you have tried so far. In the link there is an example that junkew made and the code is commented. Look for the part ";~  get the value of the addressbar".

To stop the xml and highlight use this: (this information can found in the forum search)

_UIA_setVar("Global.Debug", False)
_UIA_setVar("Global.Debug.File", False)
_UIA_setVar("Global.Highlight", False)

 

Link to comment
Share on other sites

@MichaelHB

This is what I have right now. Modified the script you linked as long as it was working, have no idea what I'm doing though. It didn't work what you said to stop the xml dumping! Tried to change it to false in the UIAWrappers.au3 file as well, but it didn't work then either. I am very thankful for all help with this.

 

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <constants.au3>
#include <WinAPI.au3>
#include <debug.au3>
#include "CUIAutomation2.au3"
#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=Y  ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os

_UIA_setVar("Global.Debug", False)
_UIA_setVar("Global.Debug.File", False)
_UIA_setVar("Global.Highlight", False)

Global $myText


If ProcessExists("chrome.exe") Then
    _getaddressbar()

Else
    Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
    ProcessWait("chrome.exe")
    Sleep(3000)
    _getaddressbar()
EndIf


Func _getaddressbar()

$oChrome=_UIA_getFirstObjectOfElement($UIA_oDesktop,"class:=Chrome_WidgetWin_1", $treescope_children)

$oChromeAddressBar=_UIA_getFirstObjectOfElement($oChrome,"controltype:=" & $UIA_EditControlTypeId , $treescope_subtree) ;works in chrome 29

$oValueP=_UIA_getpattern($oChromeAddressBar,$UIA_ValuePatternId)

$myText=""
$oValueP.CurrentValue($myText)

EndFunc


MsgBox(64 + 262144, Default, $myText)


Exit

 

Link to comment
Share on other sites

I knew you could make it work. :)

I dont know if you need all the includes. Almost the same as yours:

#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=Y  ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os

_UIA_setVar("Global.Debug", False)
_UIA_setVar("Global.Debug.File", False)
_UIA_setVar("Global.Highlight", False)

If Not ProcessExists("chrome.exe") Then
    Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
    ProcessWait("chrome.exe")
    Sleep(3000)
EndIf

MsgBox(0, "", _getaddressbar())

Func _getaddressbar()
    Local $oChrome, $oChromeAddressBar, $oValueP, $sURL

    $oChrome = _UIA_getFirstObjectOfElement($UIA_oDesktop, "class:=Chrome_WidgetWin_1", $treescope_children)
    If Not IsObj($oChrome) Then Exit ConsoleWrite("Error in $oChrome" & @CRLF)

    $oChromeAddressBar = _UIA_getFirstObjectOfElement($oChrome, "controltype:=" & $UIA_EditControlTypeId , $treescope_subtree)
    If Not IsObj($oChromeAddressBar) Then Exit ConsoleWrite("Error in $oChromeAddressBar" & @CRLF)

    $oValueP = _UIA_getpattern($oChromeAddressBar, $UIA_ValuePatternId)
    If Not IsObj($oValueP) Then Exit ConsoleWrite("Error in $oValueP" & @CRLF)

    $sURL = ""
    $oValueP.CurrentValue($sURL)

    Return $sURL
EndFunc

Exit

To stop the logs, go to the "UIAWrappers.au3" file and comment the 2 functions like this: (line 1570 and 1583)

func _UIA_LogFile($strName="log.xml", $reset=false)
;~  if $reset=true Then
;~      $__g_hFileLog=fileopen($strName, $FO_OVERWRITE + $FO_UTF8)

;~      filewrite($__g_hFileLog,"<?xml version=""1.0"" encoding=""UTF-8""?>")
;~      filewrite($__g_hFileLog,"<log space=""preserve"">")

;~ ;;~      filewrite($__g_hFileLog,"<!DOCTYPE html><html><body>")
;~ ;;~      filewrite($__g_hFileLog,"<h1>UIA logging</h1>")
;~  Else
;~      $__g_hFileLog=fileopen($strName,$FO_APPEND + $FO_UTF8)
;~  EndIf
EndFunc
func _UIA_LogFileClose()
;~ ;;~  filewrite($__g_hFileLog,"</body></html>")
;~  filewrite($__g_hFileLog,"</log>" & @CRLF)
;~  fileclose($__g_hFileLog)
EndFunc

This will stop the log file, if you need it back just take the comment off. I dont know why the log dont stop after the "_UIA_setVar("Global.Debug.File", False)". I will try to look this later.

Link to comment
Share on other sites

  • 3 years later...
On ‎6‎/‎3‎/‎2016 at 8:02 PM, Marzupilami said:

@MichaelHB

This is what I have right now. Modified the script you linked as long as it was working, have no idea what I'm doing though. It didn't work what you said to stop the xml dumping! Tried to change it to false in the UIAWrappers.au3 file as well, but it didn't work then either. I am very thankful for all help with this.

 

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <constants.au3>
#include <WinAPI.au3>
#include <debug.au3>
#include "CUIAutomation2.au3"
#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=Y  ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os

_UIA_setVar("Global.Debug", False)
_UIA_setVar("Global.Debug.File", False)
_UIA_setVar("Global.Highlight", False)

Global $myText


If ProcessExists("chrome.exe") Then
    _getaddressbar()

Else
    Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
    ProcessWait("chrome.exe")
    Sleep(3000)
    _getaddressbar()
EndIf


Func _getaddressbar()

$oChrome=_UIA_getFirstObjectOfElement($UIA_oDesktop,"class:=Chrome_WidgetWin_1", $treescope_children)

$oChromeAddressBar=_UIA_getFirstObjectOfElement($oChrome,"controltype:=" & $UIA_EditControlTypeId , $treescope_subtree) ;works in chrome 29

$oValueP=_UIA_getpattern($oChromeAddressBar,$UIA_ValuePatternId)

$myText=""
$oValueP.CurrentValue($myText)

EndFunc


MsgBox(64 + 262144, Default, $myText)


Exit

 

Thanks. This is what I am looking for!!!

Ivo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...