Jump to content

Help with URL please


onefish
 Share

Recommended Posts

Please forgive my ignorance here, I'm sure I will call everything the wrong name. I need to send a url to a local file from an autoit script and can't seem the get it working. When I type the url into a browser address bar and hit enter it does exactly what it's supposed to do (i.e. change apps and execute an internal script with parameters passed in the url [not an autoit script]). But I don't want to use a browser to send the url, I want to do it silently from the autoit script.

Most of the searches I did turned up requests to execute a url in the default browser, etc. I found THIS and THIS from Brugbart.com but I can't get it to work, not even with the copied and pasted solution at the end of his page. I tried using all sorts of stuff using run but never found one that worked.

Seems like this should be easy but....................................help

Cheers!

Link to comment
Share on other sites

  • Developers

Show what you have that isn't working as it is not really clear yet to me what you want to do.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Well the url is fmp: and about 100 charachters.

the code I tried from the link in my first post was copy and paste but with my url instead of the one in the solution.

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "fmp://MyURL", False)

$oHTTP.Send()
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status

If $oStatusCode == 200 then
 $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)
 FileClose($file)
EndIf

Edit: the above code seems to error at the "." in $oHTTP.Open if that helps?

I have tried:

run("explorer.exe fmp://MyURL")

and

run("MyApp.exe fmp://MyURL")

and a few others.

The URL is good as it executes properly when I put it onto a browser address bar and hit enter. I just can't figure out how to mimic that from Autoit without the browser.

Edited by onefish
Link to comment
Share on other sites

  • Developers

You are still faling to provide exact details as to the error you get some snippet that matches what you are doing.
You can't honestly expect anyone to guess what the problem could be. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sorry Jos, I don't want to post the whole url as it contains username and password information. I am simply trying to send the URL from autoit instead of the browser address bar. I don't really know exactly what the browser is doing or how the url is handled by it but I know it works properly from there. The url is somehow directed to a locally hosted application on the same PC, no dns resolving or anything as I can disconnect from the internet and it still works. The URL itself contains data the tells the application to run a script with a parameter (native, non-autoit).

The error I get when running the code from the link in my first post and pasted in my second post is:

$oHTTP.Open("GET","fmp://M......."

$oHTTP^ERROR

If I change get request to be "http://fmp://M........"

Then the error flag moves down the script to:

$oHTTP.Send()

$oHTTP^ERROR

But I'm even not sure if this code is the right way to achieve what I need to achieve. I just thought I'd try it because I couldn't get run to send the url request.

Link to comment
Share on other sites

  • Developers

Understand, but give us something that mimic's the error. The provided info doesn't so there is not way we can even remotely know what the issue could be.

On top of that, you still haven't provided the error description you get for the errors you get, which makes it even harder. :)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sorry again, I'm pretty green with AutoIt. the "^ERROR"/s that I posted is all that I see in the bottom section of ScitIE. Is there another way to see a better description of the error?

It would be nice to know if Braggart's approach is the right way to send a URL from AutoIT,or if there's a better way.

Link to comment
Share on other sites

  • Developers

Normally there is an error description and the line pointing to the place of the error in the SciTE outputpane.

Just post the whole output (after removing any privacy stuff)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Below is output using "http://fmp://...." which just seems wrong

>"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Someone\Downloads\FMP_URL.au3" /UserParams   
+>22:01:00 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X86    Environment(Language:0409)
+>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:C:\Users\Someone\Downloads\FMP_URL.au3
+>22:01:00 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Someone\Downloads\FMP_URL.au3"   
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\Users\Someone\Downloads\FMP_URL.au3" (7) : ==> The requested action with this object has failed.:
$oHTTP.Send()
$oHTTP^ ERROR
->22:01:07 AutoIt3.exe ended.rc:1
+>22:01:07 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 7.904
 

Below just using "fmp://...." see the error happens earlier in the script

>"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Someone\Downloads\FMP_URL.au3" /UserParams   
+>22:09:22 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X86    Environment(Language:0409)
+>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:C:\Users\Someone\Downloads\FMP_URL.au3
+>22:09:22 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Someone\Downloads\FMP_URL.au3"   
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\Users\Someone\Downloads\FMP_URL.au3" (5) : ==> The requested action with this object has failed.:
$oHTTP.Open("GET","fmp://A/WHOLE/LOT/OF/STUFF/HERE", False)
$oHTTP^ ERROR
->22:09:22 AutoIt3.exe ended.rc:1
+>22:09:22 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 1.15
 

Edited by onefish
Link to comment
Share on other sites

Quick question: can you describe in more detail what you are connecting to?  I see the "fmp" prefix to the URL.  Is that FileMaker?  I only ask because there is a guide for that which dictates what the URL in your code would need to look like to create the connection.

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

run this:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
If Not IsObj($oHTTP) Then
    MsgBox(0,'Error','No Object created')
    Exit
EndIf
$oHTTP.Open("GET", "fmp://MyURL", False)

$oHTTP.Send()
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status

If $oStatusCode == 200 then
 $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)
 FileClose($file)
EndIf

and tell if MsgBox appears. If not, post a anomysized url (in original scheme) of your browser after he has connected. 

Edited by AutoBert
Link to comment
Share on other sites

19 minutes ago, onefish said:

It's just pretty universal and doesn't require any additional setup on the database side.

But the fmp protocol is not universal.  It seems to require a FileMaker install on the machine you are running your script on that registers fmp as an internet protocol.  This page lays out all the requirements and formats for the url request.   Do you have FMP installed on the machine with your script?

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

I have been reading a bit more and fmp: is registered as an internet protocol in the local machine. I'm thinking that winhttp may not be the right way to go as it appears to have errors if the request is not http but fmp. Does this sound right?

Link to comment
Share on other sites

Database and script is on the same machine. The database actually initiates the AutoIt script with parameters. Then the AutoIt script does some things that the database can't do and the sends the info back using the fmp url (or at least that's what it's supposed to do).

By universal I meant to the purpose of the database/AutoIt script solution :)

Edited by onefish
Link to comment
Share on other sites

  • Developers

Are you sure this statement is correct as it seems it doesn't return an object?:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...