Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URL identification
#1
Hi guys, I'm just starting with Quick Macros and would like your help.
I'm using it to access several webpages, automatically surf on them and identify if it is on the right one. I'm using Opera as a browser.
I am using this:

ifi win("Window Name - Opera" "OperaWindowClass")

However, while surfing some of the pages have the same window name but different URLs. Is there a function/way I can use to identify the URL rather than the window title ?
Thanks.
#2
Function OperaGetAddress
Code:
Copy      Help
;/
function~

;Returns URL from address bar of Opera browser.
;Error if fails.
;Tested with Opera 10.61. May fail with other Opera versions.
;Fails if address bar is hidden.

;EXAMPLE
;str s=OperaGetAddress
;sel s 3
,;case "http://www.google.*"
,;out "Google"
,;
,;case "http://www.quickmacros.com*"
,;out "Quick Macros"
,;
,;case else
,;out s


Acc a=acc("" "TEXT" win(" - Opera" "OperaWindowClass") "" "Enter address or search" 0x1C04 0x0 0x20000040)
ret a.Value

err+ end _error
#3
For Firefox.

Function FirefoxGetAddress
Code:
Copy      Help
;/
function~

;Returns URL from address bar of Firefox browser.
;Error if fails.
;Tested with Firefox 3.6.8 - 21.0. May fail with other versions.
;Fails if address bar is hidden.

;EXAMPLE
;str s=FirefoxGetAddress
;sel s 3
,;case "http://www.google.*"
,;out "Google"
,;
,;case "http://www.quickmacros.com*"
,;out "Quick Macros"
,;
,;case else
,;out s


int w=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804)
Acc a=acc("Search or enter address|Go to a Website|Go to a Web Site|Search Bookmarks and History|Location" "TEXT" w "" "" 0x1802 0x0 0x20000040)
ret a.Value

err+ end _error

______________________________________

For Internet Explorer

Function IeGetAddress
Code:
Copy      Help
;/
function~

;Returns URL from address bar of Internet Explorer browser.
;Error if fails.
;Tested with IE 5, 6, 7, 8. May fail with other versions.
;Fails if address bar is hidden.

;EXAMPLE
;str s=IeGetAddress
;sel s 3
,;case "http://www.google.*"
,;out "Google"
,;
,;case "http://www.quickmacros.com*"
,;out "Quick Macros"
,;
,;case else
,;out s


Acc a=acc("Address" "TEXT" win(" Internet Explorer" "IEFrame") "Edit" "" 0x1801 0x0 0x20000040)
ret a.Value

err+ end _error

______________________________________

For Chrome

Function ChromeGetAddress
Code:
Copy      Help
;/
function~

;Returns URL from address bar of Google Chrome browser.
;Error if fails.
;Tested with Chrome 5.0. May fail with other versions.
;Fails if address bar is hidden.

;EXAMPLE
;str s=ChromeGetAddress
;sel s 3
,;case "http://www.google.*"
,;out "Google"
,;
,;case "http://www.quickmacros.com*"
,;out "Quick Macros"
,;
,;case else
,;out s


Acc a=acc("Location" "TEXT" win(" Chrome" "Chrome_WidgetWin_0") "" "" 0x1801 0x0 0x20000040)
ret a.Value

err+ end _error
#4
Sorry Gintara, newbie here... Couldn't make it work.
Copied the entire code, pasted it, clicked on "Correct..."
After I ran the macro I got an error msg point to "err+ end _error": "Error (RT) in Teste 2: object not found"

Replaced this:
Quote:Acc a=acc("" "TEXT" win(" - Opera" "OperaWindowClass") "" "Enter address or search" 0x1C04 0x0 0x20000040)
ret a.Value

err+ end _error
For this:
Quote:Acc a=acc("" "TEXT" win("Google - Opera" "OperaWindowClass") "" "http://www.google.com.BR/webhp?hl=pt-BR" 0x1C04 0x0 0x20000040)
ret a.Value

err+ end _error
and got the same error msg.

Also tried to use the example you gave
Quote:;str s=OperaGetAddress
;sel s 3
,;case "http://www.google.*"
,;out "Google"
,;
,;case "http://www.quickmacros.com*"
,;out "Quick Macros"
,;
,;case else
,;out s
After clicking on "Correct.." and runing it, got an error msg pointing to "str s=OperaGetAddress": "Error in Teste 2: unknown identifier."

My intention when trying to identify the url was: "If the url X is found, do something, if not, continue with the other actions".
Sorry for the trouble and thanks for the help.
#5
Create new function named OperaGetAddress and paste the code there.
Paste the EXAMPLE code in a macro, uncomment and run.
If error, try to install newer Opera version. When I tested with Opera 10.50, it did not work. Works with 10.61.


Forum Jump:


Users browsing this thread: 1 Guest(s)