an HTTP GET or POST call to URL

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: an HTTP GET or POST call to URL

13 Jun 2021, 15:20

@Drugwash
Could someone, anyone, please help me with reaching youtube from AHK? All I need is get some details from the video page in order to format a link.
Don't know , maybe can use youtube-dl ( ? )

Code: Select all

youtube-dl https://www.youtube.com/watch?v=iR0w0mWB3uA --encoding UTF-8 -e --get-duration --get-description =
李香蘭  Li Xiang Lan   1920 - 2014
An unforgettable and irreplaceable Li Xiang Lan.  A legendary Mandarin songs singer from the Shanghai era and later HK in the 1950s.
I am truly saddened by her passing at an old age of 94 years in Japan.
I grew up with her songs as far as I can remembered when still a very young child in Malaysia, my original country. Her songs are part of me !
May her soul rest in peace and her songs be eternally treasured in the Chinese peoples heart !
3:12

Code: Select all

;- test for youtube: get TITLE DURATION DESCRIPTION
;- needs : youtube-dl.exe   https://youtube-dl.org/latest/youtube-dl.exe
;-
;- modified=20210613
;- created =20210613

;--------- this command start for test ------------------------------------
url:="https://www.youtube.com/watch?v=iR0w0mWB3uA"
cmdx=youtube-dl %url% --encoding UTF-8 -e --get-duration --get-description
;cmdx=youtube-dl -U  ;- update youtube-dl.exe
;cmdx=youtube-dl -h  ;- HELP   youtube-dl.exe
;------------------------------------------------
;-
youtubedl:=a_scriptdir . "\youtube-dl.exe"         ;<<< youtube-dl.exe in a_scriptdir
ifexist,%youtubedl%
 goto,guitest
else
 {
 run,https://youtube-dl.org/latest/youtube-dl.exe  ;- downloads youtube-dl.exe
 exitapp
 }
;-
;-----------------------------------------------------------------
GUITEST:
#warn
#noenv
name1:="YOUTUBE_TEST"
FileEncoding, UTF-8
global name1
e:=""
;CPX:="cp" . DllCall("GetOEMCP", "UInt")        ;- get CODEPAGE e.g. CP850
;cpx:="cp65001"

setworkingdir,%a_scriptdir%
Gui,1:default
Gui,1: -DPIScale 
Gui,1:Color,Black,Black                        ; GUI black   / EDIT is BLACK
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
;- maybe change fontsize
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,1:Font,s12 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,1:Font,s10 cYellow,Lucida Console
else
 Gui,1:Font,s8 cYellow,Lucida Console
;=============================================================
x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*72)/xx,h:=(ha*60)/xx
Gui, Add, Edit, x%x%   y%y%  w%w% h%h% readonly vED1                  ;- here the output
x:=(wa*1)/xx,y:=(ha*63)/xx,w:=(wa*65)/xx,h:=(ha*6)/xx
Gui, Add, Edit, x%x%   y%y% w%w%  h%h% vED2,%cmdx%                    ;- add CMDx command above
x:=(wa*67)/xx,y:=(ha*63)/xx,w:=(wa*5)/xx,h:=(ha*2.2)/xx
Gui, add, Edit, x%x%  y%y% w%w%  h%h% vED3,
x:=(wa*67)/xx,y:=(ha*66)/xx,w:=(wa*5)/xx,h:=(ha*2.2)/xx
Gui,add,button, x%x%  y%y% w%w%  h%h% gPrintx, PRINT
x:=(wa*2)/xx,y:=(ha*2)/xx,w:=(wa*75)/xx,h:=(ha*75)/xx
Gui, Show,x%x% y%y% w%w% h%h%,%name1%
gosub,a0
GuiControl,1: Focus,ED2
;send,^{end}
return
;-------------------------
Guiclose:
Exitapp
esc::exitapp
;-------------------------

A0:
Gui,1:submit,nohide
Guicontrol,1:,ED3,running...
cpx:="cp65001"
ed2a:="cmd /c " . cmdx
xxc:=cmdret(ED2a,,CPX)
sleep,400
e .="`r`n=========================== START ===================================`r`n" . cmdx . " =`r`n-------------------------------`r`n" . xxc . "`r`n================================ ENDXX ================================`r`n"
sleep,100
Guicontrol,1:,ED1,%e%
Guicontrol,1:,ED3,ENDED
return

;--------------------------
printx:
Gui,1:submit,nohide
File1 =%a_now%_Youtube-TEST_cmdret.txt
if e<>
 {
 e:=Trim(RegExReplace(e, "`am)^(?!.*[[:alnum:]]).*\R+"), "`r`n")
 fileappend,%e%,%File1%,UTF-8
 try
  run,%File1%
 e:=""
 }
return
;==========================
;================= function from user teadrinker ========================================
;- https://www.autohotkey.com/boards/viewtopic.php?p=369467#p369467
CmdRet(sCmd, callBackFuncObj := "", encoding := "CP0")
{
   static HANDLE_FLAG_INHERIT := 0x00000001, flags := HANDLE_FLAG_INHERIT
        , STARTF_USESTDHANDLES := 0x100, CREATE_NO_WINDOW := 0x08000000
   hPipeRead:=""
   hPipeWrite:=""
   sOutput:=""
   DllCall("CreatePipe", "PtrP", hPipeRead, "PtrP", hPipeWrite, "Ptr", 0, "UInt", 0)
   DllCall("SetHandleInformation", "Ptr", hPipeWrite, "UInt", flags, "UInt", HANDLE_FLAG_INHERIT)
   
   VarSetCapacity(STARTUPINFO , siSize :=    A_PtrSize*4 + 4*8 + A_PtrSize*5, 0)
   NumPut(siSize              , STARTUPINFO)
   NumPut(STARTF_USESTDHANDLES, STARTUPINFO, A_PtrSize*4 + 4*7)
   NumPut(hPipeWrite          , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*3)
   NumPut(hPipeWrite          , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*4)
   
   VarSetCapacity(PROCESS_INFORMATION, A_PtrSize*2 + 4*2, 0)
   if !DllCall("CreateProcess", "Ptr", 0, "Str", sCmd, "Ptr", 0, "Ptr", 0, "UInt", true, "UInt", CREATE_NO_WINDOW
                              , "Ptr", 0, "Ptr", 0, "Ptr", &STARTUPINFO, "Ptr", &PROCESS_INFORMATION)
   {
      DllCall("CloseHandle", "Ptr", hPipeRead)
      DllCall("CloseHandle", "Ptr", hPipeWrite)
      throw Exception("CreateProcess is failed")
   }
   DllCall("CloseHandle", "Ptr", hPipeWrite)
   VarSetCapacity(sTemp, 4096), nSize := 0
   while DllCall("ReadFile", "Ptr", hPipeRead, "Ptr", &sTemp, "UInt", 4096, "UIntP", nSize, "UInt", 0) {
      sOutput .= stdOut := StrGet(&sTemp, nSize, encoding)
      ;sOutput .= stdOut := StrGet(&sTemp, nSize)
      ;sOutput .= stdOut := StrGet(&sTemp, nSize, CPX)
      ( callBackFuncObj && callBackFuncObj.Call(stdOut) )
   }
   DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION))
   DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, A_PtrSize))
   DllCall("CloseHandle", "Ptr", hPipeRead)
   Return sOutput
}
;================= END SCRIPT ========================================================================

/*
 Verbosity / Simulation Options:
    -q, --quiet                          Activate quiet mode
    --no-warnings                        Ignore warnings
    -s, --simulate                       Do not download the video and do not
                                         write anything to disk
    --skip-download                      Do not download the video
    -g, --get-url                        Simulate, quiet but print URL
    -e, --get-title                      Simulate, quiet but print title
    --get-id                             Simulate, quiet but print id
    --get-thumbnail                      Simulate, quiet but print thumbnail URL
    --get-description                    Simulate, quiet but print video
                                         description
    --get-duration                       Simulate, quiet but print video length
    --get-filename                       Simulate, quiet but print output
                                         filename
    --get-format                         Simulate, quiet but print output format
    -j, --dump-json                      Simulate, quiet but print JSON
                                         information. See the "OUTPUT TEMPLATE"
                                         for a description of available keys.
    -J, --dump-single-json               Simulate, quiet but print JSON
                                         information for each command-line
                                         argument. If the URL refers to a
                                         playlist, dump the whole playlist
                                         information in a single line.
*/
;=======================================================================================================
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

13 Jun 2021, 15:46

For working with XMLHTTP , You need to set cookie with InternetSetCookie.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

13 Jun 2021, 16:06

@garry: I already have a fully developed script that should work with more domains, not only with youtube, and retrieves a bunch of attributes. As such I'd like to avoid the usage of a (large) third-party tool.

@malcev: Hm, so for WinHttp it's just Cookie and for XmlHttp it's InternetSetCookie? Didn't find that detail in my searches. Will try using the latter, see if it yields the desired result.
Right now I'm getting another unexpected failure: default static image won't download anymore through WinHttps. Possibly the same cookie issue? Will test. Thank you again.
Part of my AHK work can be found here.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

13 Jun 2021, 17:16

Persistent cookie:

Code: Select all

DllCall("wininet\InternetSetCookie", "str", "https://youtube.com", "ptr", 0, "str", "CONSENT=YES+EN; expires = Fri,01-Jan-2038 00:00:00 GMT")
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

13 Jun 2021, 19:42

Got it. Permanent cookies may not be fancied by everybody so I won't try that but it's a good info to know. Thanks.

Now basically the script works correctly but only with XmlHttp. (note to self: being too impulsive doesn't pay)

With WinHttp it won't retrieve the image regardless whether the cookie is already set or not. Most relevant code is as follows:

Code: Select all

IID_IStream := "{0000000C-0000-0000-C000-000000000046}"
if RS := ComObjQuery(reqObj.ResponseStream, IID_IStream)
	DllCall("gdiplus\GdipCreateBitmapFromStream", "Ptr", RS, "PtrP", pImg)
RS is returned as a valid pointer but pImg is always zero, meaning gdiplus can't work with what it's being fed. The very same code works when reqObj is a "Msxml2.XMLHTTP" request. I'm probably doing something wrong, like ResponseStream being incompatible with "WinHttp.WinHttpRequest.5.1". :?

Still need to perform more tests.
Last edited by Drugwash on 13 Jun 2021, 20:13, edited 2 times in total.
Part of my AHK work can be found here.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

13 Jun 2021, 20:01

Session cookies like this:

Code: Select all

DllCall("wininet\InternetSetCookie", "str", "https://youtube.com", "ptr", 0, "str", "CONSENT=YES+EN")
As for GdipCreateBitmapFromStream I think that You do something wrong.
I suggest You each gdi function test for return error.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

13 Jun 2021, 20:44

Just checked and GdipCreateBitmapFromStream() returns OK (zero) according to this page. Still pImg is zero. Again, the very same code as a whole when XmlHttp is used returns a valid pointer and image is being built from the stream. It's a matter of flipping a flag (useXml) at the beginning of the script.

Here's the script, maybe you can spot the issue:
FixVideoLink1335-test.zip
(34.84 KiB) Downloaded 96 times
Part of my AHK work can be found here.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

13 Jun 2021, 20:51

For me (Win-10) it works with any value of useXML.
May be here is Your error
https://support.microsoft.com/en-us/top ... 268bb10392
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

13 Jun 2021, 21:32

Theoretically it's possible but there's a problem: I'm running this script in Linux Mint under Wine, and that's a slightly older version - 5.14 devel- due to breaking bugs in all newer versions. However I believe the Gecko used to emulate IE might already have TLS 1.2 enabled. And remember the issue only started after the implementation of the consent roadblock, which theoretically is removed by setting the cookie.

So it may be a glitch in Wine or something else we haven't thought about. Glad it works for you though. I do have a friend I built this for in the beginning and he's also using Linux (Ubuntu) so the same issue may happen to him - haven't asked yet, wanted to get it working here by me first).

Let me check with the XP I got in a VBox, see if that one works with both request versions. AFAIK XP doesn't know TLS 1.2 and I didn't install USP4 on it (yet).

EDIT:
Didn't get to fire up the XP, first I checked with the compiled script and... it worked. :o Which made me check deeper and it turned out AutoHotkey.exe was set to override the built-in gdiplus with the native one which apparently is not fully supported here. As soon as I removed the override the image appeared. So it all seems to be fine for now... until they decide to screw us over again in some way.

Well thank you very much for your help and enjoy the script. :wave:
Part of my AHK work can be found here.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

18 Feb 2022, 02:33

Hi guys, back at this topic because the wise heads at Google did it again: since recently the IE engine is fully blocked on YouTube and probably on any and all Google-pertaining domains. As such my FixVideoLink script (linked to above) stopped working again. :(
I checked with Wine's own Gecko implementation of iexplore.exe and YouTube only returns the incompatibility message:
Screenshot from 2022-02-08 23-51-02.png
Screenshot from 2022-02-08 23-51-02.png (122.66 KiB) Viewed 2216 times
Considering this breaking change does anyone know how to cheat the browser fingerprinting in order to restore functionality? Ashamed to say but I became quite rusty, forgot how to deal with certain subtle/complex issues in AHK and Windows generally. :oops:

EDIT:
By the way @garry I tried your youtube-dl script exactly as it appears above and it returned errors:

Code: Select all

=========================== START ===================================
youtube-dl https://www.youtube.com/watch?v=iR0w0mWB3uA --encoding UTF-8 -e --get-duration --get-description =
-------------------------------
Traceback (most recent call last):
  File "__main__.py", line 19, in <module>
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\__init__.py", line 475, in main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\__init__.py", line 442, in _real_main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\YoutubeDL.py", line 422, in __init__
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\YoutubeDL.py", line 2395, in _setup_opener
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\utils.py", line 2297, in make_HTTPS_handler
  File "C:\Python\Python34\lib\ssl.py", line 439, in create_default_context
  File "C:\Python\Python34\lib\ssl.py", line 390, in load_default_certs
  File "C:\Python\Python34\lib\ssl.py", line 382, in _load_windows_store_certs
ValueError: Empty certificate data

================================ ENDXX ================================
Part of my AHK work can be found here.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

18 Feb 2022, 04:38

I think it is time to forget about using ie and start using another approaches.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

18 Feb 2022, 07:02

When it comes to AHK code it would be best to use its own capabilities and if possible those native of the OS - in this case WinHttpRequest and/or XMLHTTP. My script has been using those succesfully before the first break - the cookies acceptance overlay - and even after that although the real problem had never been solved (it still needed the cookies to be present) but now both methods yield error.
It may simply be a matter of faking User Agent, at least for now. Unfortunately I forgot how to do it in the code. It's a chance anyway.

Otherwise I did find an alternative way by using cURL and its wrapper created by RaptorX, and it works fine, but that means an additional DLL that needs embedded in the compiled executable. Latest one (7.81.0) isn't even fully compatible with my older Wine - missing API in msvcrt - and is over 4MB! The one bundled with the wrapper is only ~422kB but still is an additional "weight". :?
Part of my AHK work can be found here.
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: an HTTP GET or POST call to URL

18 Feb 2022, 07:29

@Drugwash same script cmdret() from user @teadrinker
new with yt-dlp.exe
browser chrome / win11

Code: Select all

;- an HTTP GET or POST call to URL - Page 2 
;- https://www.autohotkey.com/boards/viewtopic.php?p=446309#p446309 / user drugwash romania
;- Could someone, anyone, please help me with reaching youtube from AHK? All I need is get some details from the video page in order to format a link.
;-
;- test for youtube: get TITLE DURATION DESCRIPTION  with yt-dlp.exe
;-
;- https://github.com/yt-dlp/yt-dlp#update
;- https://github.com/yt-dlp/yt-dlp
;- https://write.corbpie.com/downloading-youtube-videos-and-playlists-with-yt-dlp/
;- https://youtube-dl.org/latest/youtube-dl.exe      ( replaced with yt-dlp )
;- https://ffmpeg.org/download.html#build-windows    ( needed for MP3 / 7zip-file)
;-
;-
;- modified=20220318  ;- yt-dlp.exe
;- modified=20210613
;- created =20210613

;--- output : -------------------------------------------------------
/*
=========================== START ===================================
yt-dlp https://www.youtube.com/watch?v=iR0w0mWB3uA --encoding UTF-8 -e --get-duration --get-description =
李香蘭  Li Xiang Lan   1920 - 2014
An unforgettable and irreplaceable Li Xiang Lan.  A legendary Mandarin songs singer from the Shanghai era and later HK in the 1950s.
I am truly saddened by her passing at an old age of 94 years in Japan.
I grew up with her songs as far as I can remembered when still a very young child in Malaysia, my original country. Her songs are part of me !
May her soul rest in peace and her songs be eternally treasured in the Chinese peoples heart !
3:12
================================ ENDXX ================================
*/

;--------- this command start for test ------------------------------------
url:="https://www.youtube.com/watch?v=iR0w0mWB3uA"
cmdx=yt-dlp %url% --encoding UTF-8 -e --get-duration --get-description
;cmdx=yt-dlp -U  ;- update youtube-dl.exe
;cmdx=yt-dlp -h  ;- HELP   youtube-dl.exe
;------------------------------------------------
;-
youtubedl:=a_scriptdir . "\yt-dlp.exe"
ifexist,%youtubedl%
 goto,guitest
else
 {
 run,https://github.com/yt-dlp/yt-dlp#update
 exitapp
 }
;-
;-----------------------------------------------------------------
GUITEST:
#warn
#noenv
name1:="YOUTUBE_TEST"
FileEncoding, UTF-8
global name1
e:=""
;CPX:="cp" . DllCall("GetOEMCP", "UInt")        ;- get CODEPAGE e.g. CP850
;cpx:="cp65001"
setworkingdir,%a_scriptdir%
Gui,1:default
Gui,1: -DPIScale 
Gui,1:Color,Black,Black                        ; GUI black   / EDIT is BLACK
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
;- maybe change fontsize
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,1:Font,s12 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,1:Font,s10 cYellow,Lucida Console
else
 Gui,1:Font,s8 cYellow,Lucida Console
;=============================================================
x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*72)/xx,h:=(ha*60)/xx
Gui, Add, Edit, x%x%   y%y%  w%w% h%h% readonly vED1                  ;- here the output
x:=(wa*1)/xx,y:=(ha*63)/xx,w:=(wa*65)/xx,h:=(ha*6)/xx
Gui, Add, Edit, x%x%   y%y% w%w%  h%h% vED2,%cmdx%                    ;- add CMDx command above
x:=(wa*67)/xx,y:=(ha*63)/xx,w:=(wa*5)/xx,h:=(ha*2.2)/xx
Gui, add, Edit, x%x%  y%y% w%w%  h%h% vED3,
x:=(wa*67)/xx,y:=(ha*66)/xx,w:=(wa*5)/xx,h:=(ha*2.2)/xx
Gui,add,button, x%x%  y%y% w%w%  h%h% gPrintx, PRINT
x:=(wa*2)/xx,y:=(ha*2)/xx,w:=(wa*75)/xx,h:=(ha*75)/xx
Gui, Show,x%x% y%y% w%w% h%h%,%name1%
gosub,a0
GuiControl,1: Focus,ED2
;send,^{end}
return
;-------------------------
Guiclose:
Exitapp
esc::exitapp
;-------------------------
A0:
Gui,1:submit,nohide
Guicontrol,1:,ED3,running...
cpx:="cp65001"
ed2a:="cmd /c " . cmdx
xxc:=cmdret(ED2a,,CPX)
sleep,400
e .="`r`n=========================== START ===================================`r`n" . cmdx . " =`r`n-------------------------------`r`n" . xxc . "`r`n================================ ENDXX ================================`r`n"
sleep,100
Guicontrol,1:,ED1,%e%
Guicontrol,1:,ED3,ENDED
return
;--------------------------
printx:
Gui,1:submit,nohide
File1 =%a_now%_Youtube-TEST_cmdret.txt
if e<>
 {
 e:=Trim(RegExReplace(e, "`am)^(?!.*[[:alnum:]]).*\R+"), "`r`n")
 fileappend,%e%,%File1%,UTF-8
 try
  run,%File1%
 e:=""
 }
return
;==========================
;================= function from user teadrinker ========================================
;- https://www.autohotkey.com/boards/viewtopic.php?p=369467#p369467
CmdRet(sCmd, callBackFuncObj := "", encoding := "CP0")
{
   static HANDLE_FLAG_INHERIT := 0x00000001, flags := HANDLE_FLAG_INHERIT
        , STARTF_USESTDHANDLES := 0x100, CREATE_NO_WINDOW := 0x08000000
   hPipeRead:=""
   hPipeWrite:=""
   sOutput:=""
   DllCall("CreatePipe", "PtrP", hPipeRead, "PtrP", hPipeWrite, "Ptr", 0, "UInt", 0)
   DllCall("SetHandleInformation", "Ptr", hPipeWrite, "UInt", flags, "UInt", HANDLE_FLAG_INHERIT)
   
   VarSetCapacity(STARTUPINFO , siSize :=    A_PtrSize*4 + 4*8 + A_PtrSize*5, 0)
   NumPut(siSize              , STARTUPINFO)
   NumPut(STARTF_USESTDHANDLES, STARTUPINFO, A_PtrSize*4 + 4*7)
   NumPut(hPipeWrite          , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*3)
   NumPut(hPipeWrite          , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*4)
   
   VarSetCapacity(PROCESS_INFORMATION, A_PtrSize*2 + 4*2, 0)
   if !DllCall("CreateProcess", "Ptr", 0, "Str", sCmd, "Ptr", 0, "Ptr", 0, "UInt", true, "UInt", CREATE_NO_WINDOW
                              , "Ptr", 0, "Ptr", 0, "Ptr", &STARTUPINFO, "Ptr", &PROCESS_INFORMATION)
   {
      DllCall("CloseHandle", "Ptr", hPipeRead)
      DllCall("CloseHandle", "Ptr", hPipeWrite)
      throw Exception("CreateProcess is failed")
   }
   DllCall("CloseHandle", "Ptr", hPipeWrite)
   VarSetCapacity(sTemp, 4096), nSize := 0
   while DllCall("ReadFile", "Ptr", hPipeRead, "Ptr", &sTemp, "UInt", 4096, "UIntP", nSize, "UInt", 0) {
      sOutput .= stdOut := StrGet(&sTemp, nSize, encoding)
      ;sOutput .= stdOut := StrGet(&sTemp, nSize)
      ;sOutput .= stdOut := StrGet(&sTemp, nSize, CPX)
      ( callBackFuncObj && callBackFuncObj.Call(stdOut) )
   }
   DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION))
   DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, A_PtrSize))
   DllCall("CloseHandle", "Ptr", hPipeRead)
   Return sOutput
}
;================= END SCRIPT ========================================================================
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

18 Feb 2022, 07:59

Drugwash, it depends on what You need.
All that can be done with curl, can be done with winhttprequest.
Cause winhttprequest != ie browser.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

18 Feb 2022, 08:06

garry wrote:
18 Feb 2022, 07:29
same script cmdret() from user @teadrinker
new with yt-dlp.exe
browser chrome / win11
Thanks but as mentioned above I'd like to get it work natively without any extra Dlls if possible.
malcev wrote:
18 Feb 2022, 07:59
it depends on what You need.
All that can be done with curl, can be done with winhttprequest.
The script is attached in a previous post above, you can see what it's about. Practically it's page scraping, gathering a few metadata, then setting up a formatted link based on that metadata.
Part of my AHK work can be found here.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

18 Feb 2022, 08:16

I dont see any attachments.
Post Your short code with winhttprequests only and what do You want to get.
May be look at it later.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: an HTTP GET or POST call to URL

18 Feb 2022, 08:20

Your settings probably display fewer items per page. Here's the post: link.
Part of my AHK work can be found here.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: an HTTP GET or POST call to URL

18 Feb 2022, 08:54

Post Your code with winhttprequests only and what do You want to get.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: an HTTP GET or POST call to URL

05 Aug 2022, 00:25

@Albireo - Probably of interest: https://rapidapi.com/hashamaly/api/sms151/ (100SMS/Month are free (AFAICS)) you can use its API think: (or its Website: https://sms.an-holdings.com) where an HTTP 1.1 GET request would look like this... (there are a ton of other language/request options too)

Code: Select all

GET /send/index.php?username=username&password=password&message=this%20is%20the%20sms%20to%20send%20to%20the%20end%20user.%20&number=(xxx)yyy-zzzz&send_at=2021-12-31%2011%3A59%3A59 HTTP/1.1
X-Rapidapi-Key: <your rapid api key here>
X-Rapidapi-Host: sms151.p.rapidapi.com
Host: sms151.p.rapidapi.com
OR an XMLHtmlRequest like this... (that is easy to convert into an AHK ComObjCreate() script, like I've done here: viewtopic.php?f=10&t=88660)

Code: Select all

const data = null;

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
	if (this.readyState === this.DONE) {
		console.log(this.responseText);
	}
});

xhr.open("GET", "https://sms151.p.rapidapi.com/send/index.php?username=username&password=password&message=this%20is%20the%20sms%20to%20send%20to%20the%20end%20user.%20&number=(xxx)yyy-zzzz&send_at=2021-12-31%2011%3A59%3A59");
xhr.setRequestHeader("X-RapidAPI-Key", "<your rapid api key here>");
xhr.setRequestHeader("X-RapidAPI-Host", "sms151.p.rapidapi.com");

xhr.send(data);

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 248 guests