foo_spider_monkey_panel icon indicating copy to clipboard operation
foo_spider_monkey_panel copied to clipboard

XHR support

Open a1waysbeta opened this issue 7 years ago • 11 comments
trafficstars

Can you add interface HttpRequestEx & ESLyric related functions from wsh plus? Porting a UI (like foobox) to smp requires these two features.

eslyric_set_text_color_normal eslyric_set_text_color_highlight eslyric_set_background_color eslyric_set_text_font eslyric_set_text_titleformat_fallback eslyric_set_text_fallback eslyric_set_background_image /*example windows.NotifyOthers("eslyric_set_background_image",gdi.CreateImage(44,22)); windows.NotifyOthers("eslyric_set_background_color",RGB(25,50,100)); */

a1waysbeta avatar Oct 06 '18 01:10 a1waysbeta

As far as I could find, WshModPlus does not contain such callbacks. It has only one leftover file, which is not even included in the .vcxproj.

Regardless, these callbacks sound very component specific (probably has smth to do with catching messages from ESLyric component), which I'd very like to avoid.

Regarding HttpRequestEx: I took a quick look at the code and it doesn't look like it brings something that ActiveXObject('Microsoft.XMLHTTP') can't achieve. Am I missing something?

TheQwertiest avatar Oct 06 '18 12:10 TheQwertiest

Eslyrics has its own ActiveXObject that can be used in any script for the requested callbacks.

https://www.dropbox.com/s/1voh96segidvnnn/automation.js?dl=0

smoralis avatar Oct 06 '18 21:10 smoralis

Can not return real-time download speed, download progress.

interface IHttpRequestEx { Properties: [r,w]String SavePath;//文件保存路径,默认为%profile_path%\cache

Methods: String Run(url, verb = "GET"); UINT RunAsync(id, url, fn = "", verb = "GET"); }

interface IHttpRequestExCallbackInfo { Properties: [r] UINT Status;//StatusHeadersAvailable = 1 << 0, StatusDataReadComplete = 1 << 1 [r] UINT Error;//不为0时出现错误 [r] UINT ID;//IHttpRequestEx.RunAsync中传入的ID [r] String URL;//当前请求的url [r] String Path;//文件保存路径 [r] UINT Length;//已保存数据大小 [r] UINT ContentLength;//文件总大小,可能为无穷大 [r] double ElapsedTime;//耗时 }

interface IWSHUtils { Methods: [new] IHttpRequestEx CreateHttpRequestEx(window_id); }

//回调函数,状态或数据读取完后调用 //param : info = IHttpRequestExCallbackInfo object function on_http_ex_run_status(info){}

//examples var StatusHeadersAvailable = 1 << 0; var StatusDataReadComplete = 1 << 1;

client = Utils.CreateHttpRequestEx(window.ID); client.SavePath = "D:\Temp";

client.RunAsync(0, "http://this/is/first/one.mp3", "filename"); client.RunAsync(1, "http://second/second.mp4", "filename");

client.AbortAsync(id,url = ""); // url is optional, but is preferred. If there is a url, it will match the url first. If the id is not unique, the first one is cancelled. (Like: 0 1 2 3 work, 0 0 1 2 will not work. If 0012 is downloading at the same time, but only id0 is specified when you cancel, the first 0 is canceled.)

function on_http_ex_run_status(info) { if(info.Status & StatusDataReadComplete)//文件下载完成 { if(info.ID == 0)fb.trace("one.mp3"); else if(info.ID == 1)fb.trace("second.mp4") } else { if(info.ID == 0){ fb.trace(info.ID + “ Downloaded Bytes : ” + info.Length); fb.trace(info.ID + “ Total Bytes : ” + info.ContentLength); } if(info.ID == 1){ fb.trace(info.ID + “ Downloaded Bytes : ” + info.Length); fb.trace(info.ID + “ Total Bytes : ” + info.ContentLength); } } }

a1waysbeta avatar Oct 07 '18 02:10 a1waysbeta

Uhm... But what is the use case scenario? Why would you need to download such big files in panel, that the download progress display is required? =)

TheQwertiest avatar Oct 07 '18 10:10 TheQwertiest

With the web search script, I can download mp3 and so on. Maybe a picture is easier to explain. https://imgur.com/a/MYHX1UR

a1waysbeta avatar Oct 07 '18 12:10 a1waysbeta

Eslyrics has its own ActiveXObject that can be used in any script for the requested callbacks.

https://www.dropbox.com/s/1voh96segidvnnn/automation.js?dl=0

These two methods fail. SetPanelBackgroundImage(IGdiBitmap img, String panel_guid = ""); SetPanelTextFont(IGdiFont, String panel_guid = "");

Error: Spider Monkey Panel v1.0.2 ({3C4F1994-6BC2-43E0-AC4E-DA05C99DD605}) 'ActiveX_Run' failed: ActiveXObject: Parameter 0 type mismatch

File:

Line: 15, Column: 1

Stack trace: @

:15:1

The other methods with UINT or String work.

smoralis avatar Oct 08 '18 17:10 smoralis

These two methods fail.

This is expected behaviour: IGdiBitmap and IGdiFont objects are part of the old WSH/JSP interface (i.e. COM interface), which is no longer available due to the JS engine switch.

SMP can still use COM/ActiveX interface from other dll's, but other dll's can't use SMP in the same way as before: it just does not have a COM interface anymore.

TheQwertiest avatar Oct 08 '18 19:10 TheQwertiest

Thank you for the clarification.

smoralis avatar Oct 08 '18 19:10 smoralis

Download functionality will be implemented with XHR interface in v2

TheQwertiest avatar Jul 30 '22 11:07 TheQwertiest

Note to self: use https://github.com/libcpr/cpr , does not require ossl for https (supports winssl)

TheQwertiest avatar Jul 30 '22 13:07 TheQwertiest

Note to self: alternative lib https://github.com/chmike/CxxUrl

TheQwertiest avatar May 10 '23 17:05 TheQwertiest