Jump to content

Open website without web browser.


Recommended Posts

Hi!
Is it possible to create website (not to get some information, but to send information to server) without using Internet Explorer or any other browser?

The reason why I need it is because I need to send an email if database backup file is missing on computer. I wrote a script to check that, but I need to send that email, if there is error and programm didn't find file. I tried to send mail via SMTP, but anti-virus blocked that. So I thougt that I can make php file on my server, where I can post contents using $_GET variables. For now I am using Internet Explorer, which is opened hidden, but I think that there could be better ways to do this.

 

(Sorry if this question is already answered, I just couldn't imagine how to find something like this.. And sorry for my english..)

Thanks in advance! :)

Link to comment
Share on other sites

I think this function will not do for this, because I still need to run php script.. And backup check is not only for one computer, but for like 10 computers and there is that schedule task, which run my autoit programm...

Edited by macz
Link to comment
Share on other sites

Ahh, it worked perfectly until I tested it on that computer, where mail wasn't working.. I guess the same reason - firewall blocked it. Any other ideas or should I continue to use my way with IExplorer?

Link to comment
Share on other sites

Sorry, I can't find what is not working...

$site = 
$query = 

Local $hOpen = _WinHttpOpen()
Local $hConnect = _WinHttpConnect($hOpen, $site)
; Specify the reguest:
Local $hRequest = _WinHttpOpenRequest($hConnect, Default, $query)
; Send request
$hres = _WinHttpSendRequest($hRequest)
MsgBox(0, 0, "SendRequest: " & $hres)
If @error Then
MsgBox(0, 0, "ERROR!")
EndIf
;Wait for the response
$resp = _WinHttpReceiveResponse($hRequest)
MsgBox(0, 0, "ReceiveRequest: " & $resp)
If @error Then
MsgBox(0, 0, "ERROR!")
EndIf
Local $sHeader = _WinHttpQueryHeaders($hRequest) ; ...get full header
; Clean
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen
MsgBox(0,0,$sHeader)

 

 

That's the code which I used.. On this computer it's working correctly,

1st MsgBox contains "SendRequest: 1"

2nd - "ReceiveRequest: 1"

3td - full with header data...

But on another computer

1st  - "SendRequest: 0"

and there is no error...

2nd - "ReceiveRequest: 0"

3td - empty

 
 
I tried to look into WinHttp.au3, but I don't understand how dll files are working and I am just a begginer in AutoIT...
Edited by macz
Link to comment
Share on other sites

You should add some error checking to see where your code is failing:

#Include "WinHttp.au3"

$site =
$query =

Local $hOpen = _WinHttpOpen()
Local $hConnect = _WinHttpConnect($hOpen, $site)

; Specify the reguest:
Local $hRequest = _WinHttpOpenRequest($hConnect, Default, $query)

If @error Then
    MsgBox(0, "Error", "_WinHttpOpenRequest: " & @error)
    Exit
EndIf

; Send request
$hres = _WinHttpSendRequest($hRequest)

If @error Then
    MsgBox(0, "Error", "_WinHttpSendRequest: " & @error)
    Exit
EndIf

;Wait for the response
$resp = _WinHttpReceiveResponse($hRequest)

If @error Then
    MsgBox(0, "Error", "_WinHttpReceiveResponse: " & @error)
    Exit
EndIf

Local $sHeader = _WinHttpQueryHeaders($hRequest) ; ...get full header


If @error Then
    MsgBox(0, "Error", "_WinHttpQueryHeaders: " & @error)
    Exit
EndIf

; Clean
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen

MsgBox(0,0,$sHeader)
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...