AutoHotkey Community

It is currently May 26th, 2012, 5:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 233 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 16  Next

Should a more generic function be released which will include the already available web functions, such as header queries, uri encoding, base encoding, etc ?
yes, i'd like to have one function to get all neccessary http functionalities in one instead of collecting each for my own
no, i prefer collecting the functions i need
neither nor ... explained in post
You may select 1 option

View results
Author Message
 Post subject:
PostPosted: December 6th, 2008, 8:44 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
degarb wrote:
Now, anyone found a similar trick to telnet? ( have an email check and cddb scrip that relies on controlsend to a telnet that takes me half second to hide, and sometimes I don't think the send works so well.)


solved

take a look here: [function] send/expect() for Autohotkey TelnetAlike sessions

greets
dR

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2008, 10:33 pm 
Offline

Joined: February 14th, 2007, 8:01 pm
Posts: 308
By the way, any wput replacement natively?

Need help, I am coming on another glitch. I have a simple ahk that works, using your code, but embedded in a larger ahk-a dyndnsupdateclient-, the html variable (the html telling me that the ip was updated or not) is returning blank. Is this because variable used previously on another case, in the ahk?

Code:
dynquery:
;replace wget
#noenv
html     := ""
URL      := "http://me:mypassword@members.dyndns.org/nic/update?"
POSTData := "hostname=hyhost.homeip.net&myip=173.89.183.11"

length := httpQuery(html,URL,POSTdata)
varSetCapacity(html,-1)

fileappend,..%html%`n,log.txt
msgbox,, %html%,%html%,1
;end of dynquery
filedelete,dyndnserrorlog.txt
sleep, 1000
fileappend, %html%,dyndnserrorlog.txt
IfInString, html, bad, msgbox, Your ini has errors!
IfInString, html, nochg, msgbox,,Warning!,May be updating too often!,1

   ExitApp
   
#include httpQuery.ahk


This is working fine. But in the huge file, the html variable is returning blank. Listing other variables looks like working fine.

Code:
;this code is the main ahk to dyndns.com updating client, only missing help and httpquery.ahk
;todo reinstall  jump.htm homehost.html
;done:eliminate wget with http://www.autohotkey.com/forum/viewtopic.php?p=235283#235283
;done:http://www.autohotkey.com/forum/viewtopic.php?t=33506
;


;FileInstall, wget\wget.exe, wget\wget.exe
FileInstall, helpme.txt, helpme.txt
FileInstall, source-code.ahk, source-code.ahk
FileInstall, httpQuery.ahk, httpQuery.ahk

#singleinstance
DetectHiddenWindows, On
settitlematchmode,2

iniread,hostname, dyn.ini,Prefs,hostname

trays:
Menu, Tray, Tip, Dyna-Dingle! Another Dyndns.com updater 4 free! %hostname%
menu:
menu, tray, Nostandard
;Menu, Tray, Click, 1
;menu, tray, add,Dial/Hang,dialhang
;menu, tr5y, Default,Dial/Hang


menu, tray, add,Check and update dyndns.com, firstcheck

Menu, MySubmenu, add, List_Recent_Executed_Code
Menu, MySubmenu, add, List_Variables
Menu, MySubmenu, add, Update-Log_View
Menu, tray, add, Tools,:MySubmenu

;menu, tray, add,ListLines,ListLines
;menu, tray, add,ListVars,ListVars
;menu, tray, add,View Update Logs,Logview
menu, tray, add,Help and Configure,help
Menu, tray, add  ; Creates a separator line.
menu, tray, add,Pause, Pause
menu, tray, add,Exit , exit



firstcheck:
fileread, String3, ip.txt
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, oldip, String5,
,


;sleep 360000
FileDelete, ipstring.txt
;;;run wget\wget -O ipstring.txt "http://checkip.dyndns.org" ,,hide
ipquery1:
;replaces wget
#noenv
html     := ""
URL      := "http://checkip.dyndns.org"
POSTData := ""

length := httpQuery(html,URL,POSTdata)
varSetCapacity(html,-1)

fileappend,%html%,ipstring.txt
;msgbox,, %html%,ip is %html%,10
;end of ipquery


sleep, 3000
FileRead, String, ipstring.txt
StringReplace, String2, String, <html><head><title>Current IP Check</title></head><body>Current IP Address: ,
StringReplace, String3, String2, </body></html>,
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, String5a, String5, |,
 StringReplace, currentip, String5a,
,

;msgbox,  %currentip% = %oldip%
ifequal, currentip, %oldip%,   goto, sleeping


inicheck:
ifnotexist,%A_WorkingDir%\dyn.ini
{
   iniwrite,me, dyn.ini,Prefs,UserName
   iniwrite,hostname.homeip.net, dyn.ini,Prefs,hostname
   iniwrite,password, dyn.ini,Prefs,Password
      runwait, notepad.exe dyn.ini
      runwait, notepad.exe helpme.txt

}


   iniread,username, dyn.ini,Prefs,UserName
   iniread,hostname, dyn.ini,Prefs,hostname
   iniread,password, dyn.ini,Prefs,Password


sleep, 1800
; increase above value to 180000 so running at startup works on all machines

run, %A_WinDir%\system32\ipconfig.exe >> d:\ipnow.txt


dnyservice:
FileDelete, ipstring.txt
;;;run wget\wget -O ipstring.txt "http://checkip.dyndns.org" ,,hide
ipquery2:
;replaces wget
#noenv
html     := ""
URL      := "http://checkip.dyndns.org"
POSTData := ""

length := httpQuery(html,URL,POSTdata)
varSetCapacity(html,-1)

fileappend,%html%,ipstring.txt
;msgbox,, %html%,%html%,10
;end of ipquery

sleep, 3000
FileRead, String, ipstring.txt

StringReplace, String2, String, <html><head><title>Current IP Check</title></head><body>Current IP Address: ,
StringReplace, String3, String2, </body></html>,
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, String5a, String5, |,
StringReplace, currentip, String5a,
,

goto, writejumppage

ipconfig:
controlsend,, ipconfig > d:\ip4now.txt{enter}, ahk_id %ControlHwnd%
sleep, 2500
controlsend,, exit{enter}, ahk_id %ControlHwnd%
FileRead, String3, d:\ip4now.txt
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, String5a, String5, |, 
StringReplace, currentip, String5a,
,
 
FileDelete, d:\ip4now.txt
StringMid, currentip, currentip, 460,14

writejumppage:
msgbox, ,Updating ip!,Updating ip %currentip%! (writejumpage),1
;3 lines below is test code to see in sendkeys working on second cmd.
FileDelete, homehost.htm
fileappend,  <HEAD> `n<meta HTTP-EQUIV="REFRESH" content="0; url=http://%currentip%">`n </HEAD>,homehost.htm
sleep, 2500


;;;runwait wget\wget.exe -O wget\dyndnsupdate.txt "http://%username%:%password%@members.dyndns.org/nic/update?hostname=%hostname%&myip=%currentip%{enter}",%a_working_Dir%/wget,hide
dynquery:
;replace wget
#noenv
html =
html     := ""
URL      := "http://%username%:%password%@members.dyndns.org/nic/update?"
POSTData := "hostname=%hostname%&myip=%currentip%"

;length := httpQuery(html,URL,POSTdata)
;varSetCapacity(html,-1)

fileappend,..%html%`n,log.txt
sleep, 1000
msgbox,, %html%,%html%`nhttp://%username%:%password%@members.dyndns.org/nic/update?hostname=%hostname%&myip=%currentip% ,11
;end of dynquery
filedelete,dyndnserrorlog.txt
sleep, 1000
fileappend, %html%,dyndnserrorlog.txt
IfInString, html, bad, msgbox, Your ini has errors!
IfInString, html, nochg, msgbox,,Warning!,May be updating too often!,1

sleep, 4500
log:
fileappend, New ip is %currentip% Found at %A_MM%-%A_DD% %A_Hour%:%A_Min%..`n, log.txt
;:UrlDownloadToFile, http://%username%:%password%@members.dyndns.org/nic/update?hostname=%hostname%&myip=%currentip%, Filename.txt
;:run, http://%username%:%password%@members.dyndns.org/nic/update?hostname=%hostname%&myip=%currentip%

;MsgBox, Your IP is: %currentip%
filedelete, ip.txt
;msgbox, ,writeing ip,%currentip%,3
fileappend, %currentip%, ip.txt
fileread, String3, ip.txt
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, String5a, String5, |,
StringReplace, oldip, String5a,
,

sleeping:
;msgbox,, Sleeping!, Sleeping!,1
sleep 720000
FileDelete, ipstring.txt
;;;run wget\wget -O ipstring.txt "http://checkip.dyndns.org" ,,hide


ipquery3:
;replaces wget
#noenv
html     := ""
URL      := "http://checkip.dyndns.org"
POSTData := ""

length := httpQuery(html,URL,POSTdata)
varSetCapacity(html,-1)

fileappend,%html%,ipstring.txt
;msgbox,, %html%,%html%,10
;end of ipquery

sleep, 3000
FileRead, String, ipstring.txt
StringReplace, String2, String, <html><head><title>Current IP Check</title></head><body>Current IP Address: ,
StringReplace, String3, String2, </body></html>,
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, String5a, String5, |,
StringReplace, currentip, String5a,
,
fileread, String3, ip.txt
StringReplace, String4, String3, `n,
StringReplace, String5, String4, %a_space%,
StringReplace, String5a, String5, |,
StringReplace, oldip, String5a,
,

ifnotequal, currentip, %oldip%,msgbox, ,Updating ip!,Updating ip!,3
ifnotequal, currentip, %oldip%, goto, writejumppage
goto, sleeping

exit:
exitapp

List_Recent_Executed_Code:
ListLines
goto, sleeping
Return

List_Variables:
ListVars
goto, sleeping
Return


help:
      runwait, notepad.exe dyn.ini
      runwait, notepad.exe helpme.txt
goto, sleeping
Return

Update-Log_View:
      runwait, notepad.exe log.txt
goto, sleeping
Return

Pause:
pause
return

#include httpQuery.ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 7th, 2008, 4:46 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
i can only make a wild guess, but to me it look like the problem is in this line:

Code:
URL      := "http://%username%:%password%@members.dyndns.org/nic/update?"
POSTData := "hostname=%hostname%&myip=%currentip%"


the questionmark at the end of the url indicates that rest of params should be appended as get params in the query. instead u r passing the params via post (which is a different way)

also the percentsign within the quotationmarks wont work.

u have top rewrite that part to something like:

Code:
url := "http://" username ":" password "@members.dyndns.org/nic/update?"
     . "hostname=" hostname "&myip= "currentip


postdata is only needed when having a form whose content is transferred using the post method.

greets
dR

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 7th, 2008, 9:06 pm 
Offline

Joined: February 14th, 2007, 8:01 pm
Posts: 308
That solves it.

I don't understand why the little ahk works with same line, but not the large one (with bad line).

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 7th, 2008, 11:42 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
degarb wrote:
That solves it.

I don't understand why the little ahk works with same line, but not the large one (with bad line).

Thanks.


i helpful,

there is "=" and ":="

with = you don't use quotes,

eg. this = This is GREAT!



but how to use vars ?

put them in %here%.

ie. with = the answer is %answer%


but := works different. you need quotes.

this := "something is here"

vars are naked

this := "the answer is " answer

so,

this := "the %answe%r"

gives you

the %answer%.

and not... the actual answer.


hope helps

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 24th, 2009, 2:17 pm 
Offline

Joined: May 24th, 2006, 7:08 pm
Posts: 66
Location: New Mumbai, India
www.autohotkey.com/forum/viewtopic.php?p=246328


Last edited by geeneeyes on January 28th, 2009, 7:44 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2009, 7:47 am 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
Hi,

Is it possible to use HTTPQuery to handle cookies?

I am asking this because i am creating a movie poster grabber from a site that requires cookies to be saved, if you dont have cookies you get blocked. :)

I just love beeing able to do POST :).

Awaiting your reply,
Twhyman

_________________
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2009, 5:25 am 
Offline

Joined: November 19th, 2008, 12:06 am
Posts: 101
ok i am VERY confused with this. ive read the first post about 5 times and been looking at everything for like half an hour. so can someone PLEASE help me out a bit?

i have a few questions about how to get this to work:

1) Do i have to install anything to get this to work?
2) How do I get it to do this: Post a search term on Google, then search for it and get the list of results?



Any help is apreciated, greatly apreciated.


Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2009, 8:57 am 
Offline

Joined: May 24th, 2006, 7:08 pm
Posts: 66
Location: New Mumbai, India
soccer18soccer18 wrote:
1) Do i have to install anything to get this to work?
2) How do I get it to do this: Post a search term on Google, then search for it and get the list of results?
You have to download and save this script in the same folder as your script.
Also put this code in your script
Code:
#Include httpQuery.ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2009, 11:23 pm 
Offline

Joined: November 19th, 2008, 12:06 am
Posts: 101
what do i download and save?

post a link please.

Thanks so much!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2009, 6:55 pm 
hi i was trying to get your sample imageshack script working for another site http://decaptcher.com/client/

here's my mod...
Code:
#SingleInstance,Force
#Include httpquery.ahk

DUser := ""
DPass := ""

FileSelectFile,image
   FileGetSize,size,%image%
   SplitPath,image,OFN
   FileRead,img,%image%
   VarSetCapacity(placeholder,size,32)
   boundary := makeProperBoundary()

Post:="--" boundary "`ncontent-disposition: form-data; name=""function""`n`npicture2`n--"
   . boundary "`ncontent-disposition: form-data; name=""username""`n`n" DUser "`n--"
   . boundary "`ncontent-disposition: form-data; name=""password""`n`n" DPass "`n--"
   . boundary "`ncontent-disposition: form-data; name=""pict""; filename="""
   . ofn """`nContent-type: " MimeType(img) "`n`n" placeholder "`n--"
   . boundary "`ncontent-disposition: form-data; name=""pict_to""`n`n 0`n--"
   . boundary "`ncontent-disposition: form-data; name=""pict_type""`n`n0`n--" boundary "--"

 headers:="Content-type: multipart/form-data, boundary=" boundary "`nContent-Length: " strlen(post)
   DllCall("RtlMoveMemory","uInt",(offset:=&post+strlen(post)-strlen(Boundary)-size-5)
         ,"uInt",&img,"uInt",size)

   size := httpQuery(result:="","http://decaptcher.com/poster/",post,headers)
varSetCapacity(result, -1)
 Gui,Add,Edit,w800 h600, % result
   Gui,Show
return

GuiClose:
GuiEscape:
   ExitApp

makeProperBoundary(){
   Loop,26
      n .= chr(64+a_index)
   n .= "0123456789"
   Loop,% StrLen(A_Now) {
      Random,rnd,1,% StrLen(n)
      Random,UL,0,1
      b .= RegExReplace(SubStr(n,rnd,1),".$","$" (round(UL)? "U":"L") "0")
   }
   Return b
}

MimeType(ByRef Binary) {
   MimeTypes:="424d image/bmp|4749463 image/gif|ffd8ffe image/jpeg|89504e4 image/png|4657530"
          . " application/x-shockwave-flash|49492a0 image/tiff"
   @:="0123456789abcdef"
   Loop,8
      hex .= substr(@,(*(a:=&Binary-1+a_index)>>4)+1,1) substr(@,((*a)&15)+1,1)
   Loop,Parse,MimeTypes,|
      if ((substr(hex,1,strlen(n:=RegExReplace(A_Loopfield,"\s.*"))))=n)
         Mime := RegExReplace(A_LoopField,".*?\s")
   Return (Mime!="") ? Mime : "application/octet-stream"
}


no matter what i try, though i may not understand enough yet, it always returns nothing.

here's some documentation from there site.

Quote:
Example 4. POST a picture

<form
method="post"
action="http://decaptcher.com/poster/"
enctype="multipart/form-data">
<input type="hidden" name="function" value="picture2">
<input type="text" name="username" value="client">
<input type="text" name="password" value="qwerty">
<input type="file" name="pict">
<input type="text" name="pict_to" value="0">
<input type="text" name="pict_type" value="0">
<input type="submit" value="Send">
</form>



Example 5. Claim picture as badly recognized

<form
method="post"
action="http://decaptcher.com/poster/"
enctype="multipart/form-data">
<input type="hidden" name="function" value="picture_bad2">
<input type="text" name="username" value="client">
<input type="text" name="password" value="qwerty">
<input type="text" name="major_id" value="123">
<input type="text" name="minor_id" value="12345">
<input type="submit" value="Send">
</form>


POST API returns a line of text separated with | character

Example 6. POST API returned string

0|107|44685|0|0|n7hjks


Format of the string is the following:

ResultCode|MajorID|MinorID|Type|Timeout|Text


if anyone could provide some assistance that would be appriciated.

thx again for httpquery!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2009, 7:51 am 
Offline

Joined: January 31st, 2008, 8:47 pm
Posts: 88
Anybody knows how to get the redirected url (the page the redirect landed on) from httpQuery?

thanks
fures


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 5th, 2009, 9:56 pm 
Offline

Joined: October 18th, 2008, 6:43 pm
Posts: 18
Could anyone give me a quick example syntax of how to use httpQuery against a server using HTTPS instead of http.

i read the docs, and read the code and i dont get it.

I tried this and results come back empty.

REPORTURL = "https://www.amazon.com"
length := httpQuery(htmlx,REPORTURL,POSTdata)
varSetCapacity(htmlx,-1)

another question would be, is httpQuery the best way to do this, or is there another method which is better?

thank you in advance!
-don

_________________
-d :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 12:52 pm 
Offline

Joined: March 27th, 2009, 12:46 pm
Posts: 76
Location: Dublin, IE
Quote:
You need to inject a header into the datastream which looks like this:
Code:
header := "Proxy-Authorization: Basic " base64(username":"password)


Keep in mind that Basic Authetification is case sensitive.

username:password needs to be base64 encoded.



I am behind a proxy at work as well, and I'm trying to understand how to get Example III to work while being behind the proxy.

What's the proper way to base64 encode the username and password?

How do I properly inject the header using Example III?

I'm a total noob when it comes to ahk.

Thanks in advance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks
PostPosted: April 15th, 2009, 7:44 pm 
Offline

Joined: December 30th, 2007, 5:42 pm
Posts: 31
Location: East Coast
I'm used to the functionality and freedom of cURL but I will give this a shot. Not having to include an external application will be nice for small projects. Secure connections with the ssl version of curl require several files. I'm just hoping that I don't run into something I need that this has not covered yet. Thanks a lot Raphael.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 233 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group