Sign in to follow this  
Followers 0
NELyon

IE.au3

8 posts in this topic

#1 ·  Posted (edited)

I'm creating a music searching program, and i found a way to search google doing a music search, leaving out most webpages. Just typing this url in my browser will bring up a box saying "ENTER SONG NAME OR ARTIST", but if i try _IENavigate or $oIE.navigate they bring up a "Page cannot be displayed".

#include <GUIConstants.au3>
#Include <IE.au3>
$oIE = _IECreateEmbedded()
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 763, 542, 192, 125)
$Edit1 = GUICtrlCreateObj($oIE, 0, 0, 761, 497)
GUICtrlSetData($Edit1, "AEdit1")
$Button1 = GUICtrlCreateButton("Music Search", 288, 504, 201, 33)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        $oIE.navigate (INIRead("Url.ini", "url", "url", ""))
    EndSelect
WEnd
Exit

The INI:

[url]
url=java script:Qr='';if(!Qr){void(Qr=prompt('ENTER ARTIST OR SONG NAME:',''))};if(Qr)location.href='http://www2.google.com/ie?query=%22parent+directory%22+%22'+escape(Qr)+'%22+mp3+OR+wma+OR+ogg+-html+-htm+-php+-asp+-jsp&num=100&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=active&sa=N'
Edited by codemyster

Share this post


Link to post
Share on other sites



I'm guessing trouble with quotes... what is the exact string returned by the IniRead?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Well, it does the same thing if i do it without the INI. If i just put the Url on one line, it gives no errors, but just directs me to "Page cannot be displayed"

Share this post


Link to post
Share on other sites

You can call javascript functions with $oIE.eval(), but it's hard, and you don't have to here. Plus, I think you had some javascript errors anyway. Try this:

#include <GUIConstants.au3>
#Include <IE.au3>
#include <INet.au3> ; required for _INetExplorerCapable(), which replaces your javascript escape
$oIE = _IECreateEmbedded()
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 763, 542, 192, 125)
$Edit1 = GUICtrlCreateObj($oIE, 0, 0, 761, 497)

_IENavigate ( $oIE,"about:blank")
GUICtrlSetData($Edit1, "AEdit1")
$Button1 = GUICtrlCreateButton("Music Search", 288, 504, 201, 33)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1

        ; this replaces your javascript call

        $qr = InputBox ( "Music Search", "ENTER ARTIST OR SONG NAME:")
        if $qr <> "" Then
            $url = "http://www2.google.com/ie?query=%22parent+directory%22+%22"
            $url &= _INetExplorerCapable ( $qr )
            $url &= "%22+mp3+OR+wma+OR+ogg+-html+-htm+-php+-asp+-jsp&num=100&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=active&sa=N"
            _IENavigate ( $oIE,$url)
        EndIf
    EndSelect
WEnd
Exit

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

But the javascript worked fine in IE.

Share this post


Link to post
Share on other sites

Well, if you really want to go that route, you can just Navigate to your functional html page that you already created.

In fact, why are you using AutoIt at all? This all could be accomplished via simpler methods- are you hoping to hook in automatic downloading capabilites or something?


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

I don't have a functional HTML webpage. I simply paste the javascript into my address bar and it works. I am just trying to create a program that will let me download music easier without using a third-party p2p.

Share this post


Link to post
Share on other sites

I see, well then, here is a functional HTML web page:

<script>
function searchy(){
var Qr=prompt('ENTER ARTIST OR SONG NAME:','');
if(Qr){
    location.href='http://www2.google.com/ie?query=%22parent+directory%22+%22'+escape(Qr)+'%22+mp3+OR+wma+OR+ogg+-html+-htm+-php+-asp+-jsp&num=100&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=active&sa=N'
}
}
</script>
<input value=Search type=button onclick=searchy()>

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0