Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

what's IMPOSSIBLE with AHK?


  • Please log in to reply
43 replies to this topic
tic
  • Members
  • 1934 posts
  • Last active: May 30 2018 08:13 PM
  • Joined: 22 Apr 2007
Mmmm it doesnt quite fit with what I want though.....

#Persistent
#SingleInstance, Force
OnExit, CleanUp

Gui, 1: Add, Edit, x10 y10 w500 h200 vEdit1
Gui, 1: Add, Edit, xp+0 y+10 w500 h200 vEdit2
Gui, 1: Add, Edit, xp+0 y+10 w500 h200 vEdit3
Gui, 1: Show

COM_Init()
pwhr := COM_CreateObject("WinHttp.WinHttpRequest.5.1")
psink := ConnectIWinHttpRequestEvents(pwhr)

COM_Invoke(pwhr, "Open", "GET", "http://www.rlslog.net/", "True")
COM_Invoke(pwhr, "Send")
Sleep, 1000
COM_Invoke(pwhr, "Open", "GET", "http://n-europe.com/", "True")
COM_Invoke(pwhr, "Send")
Sleep, 1000
COM_Invoke(pwhr, "Open", "GET", "http://next-episode.net/", "True")
COM_Invoke(pwhr, "Send")
Return

CleanUp:
COM_Unadvise(NumGet(psink+8), NumGet(psink+12))
COM_Release(NumGet(psink+8))
COM_Release(pwhr)
COM_Term()
ExitApp

IWinHttpRequestEvents(This, nStatus="", pType="")
{
    Global
	Critical
	
	;Tooltip, %A_EventInfo%
    If (A_EventInfo = 0)
    NumPut(This, pType+0)
    Else If (A_EventInfo = 5)
	{
		Gui, 1: Submit, NoHide
		GuiControl,, % !Edit1 ? "Edit1" : !Edit2 ? "Edit2" : "Edit3", % COM_Invoke(NumGet(this+4), "ResponseText")	;%
	}
    Return, 0
}

ConnectIWinHttpRequestEvents(pwhr)
{
	Static IWinHttpRequestEvents
   
	If !VarSetCapacity(IWinHttpRequestEvents)
	{
		VarSetCapacity(IWinHttpRequestEvents, 28, 0), nParams=3113213
		Loop, Parse, nParams
		NumPut(RegisterCallback("IWinHttpRequestEvents", "", A_LoopField, A_Index-1), IWinHttpRequestEvents, 4*(A_Index-1))
	}
	pconn := COM_FindConnectionPoint(pwhr, IID_IWinHttpRequestEvents:="{F97F4E15-B787-4212-80D1-D380CBBF982E}")
	psink := COM_CoTaskMemAlloc(16), NumPut(pwhr, NumPut(&IWinHttpRequestEvents, psink+0))
	NumPut(COM_Advise(pconn, psink), NumPut(pconn, psink+8))
	Return, psink
}

Just a quick test.
Note: All the above code is Sean's. I copied and pasted it :p

You see that those Sleep, 1000 are necessary and sometimes not adequate. The sleep needs to be increased and I sometimes (rarely) dont get all 3 results back with sleep 3000
It must depend on the system, so isnt really a very good example of asynchronous downloading, if such a massive gap is needed between files.
I need it to be quick, thats why I would want to download more than 1 file at once. Any ideas why it needs that massive sleep?

Also this still wouldnt work as how could I parse the information and have the listview usable on the gui? the info would need to be constantly parsing as fast as possible

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I assume each "request" object can only handle one request at a time... Create a WinHttpRequest object for each concurrent request, rather than trying to reuse the same object.

Also this still wouldnt work as how could I parse the information and have the listview usable on the gui?

Try explaining that again, without using a question as a "reason."

What I'd like to know is how could you parse the information and not have the ListView usable. Since AutoHotkey checks for messages every 5 ms by default, the ListView should remain responsive while script is running (but maybe not during a DllCall.) Anyway, assuming you are parsing search results, the parsing function should be lightning fast compared to the actual download.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

what's IMPOSSIBLE with AHK?

Not much really. What's not practical to do in AHK code compared to alternatives might be a better way to phrase the question. Tasks that might require a lot of AHK code and/or workarounds can sometimes be accomplished easily in other languages, using command line utilities, etc... and then added to an AHK script using a relatively small amount of AHK code... For example, writing a dll (or using an existing one) to do various tasks then calling the dll from an AHK script can be very handy sometimes compared to writing long winded workarounds in AHK code ;) .

ManaUser
  • Members
  • 1121 posts
  • Last active: Dec 07 2016 04:24 PM
  • Joined: 24 May 2007
Aside from things you can't do in any language (like peel potatoes), I think an OS is about the only think you absolutely couldn't make. (Which didn't stop someone from asking, I recall.)

ChalamiuS
  • Moderators
  • 176 posts
  • Last active:
  • Joined: 04 Jun 2006

I think an OS is about the only think you absolutely couldn't make. (Which didn't stop someone from asking, I recall.)

:roll: Remember im still here :wink:

imapow
  • Members
  • 155 posts
  • Last active: Oct 13 2009 08:35 AM
  • Joined: 13 Mar 2008

Lets see whats impossible... World domination (Atleast I think so :shock: )


create a program to hack usa's, uk's and china's nuke siloes and rocet navigasjon satelittes. take the world by force and dominate
-._.-¨¯¨[email protected]ΩW-._.-¨¯¨-._.-

ChalamiuS
  • Moderators
  • 176 posts
  • Last active:
  • Joined: 04 Jun 2006

create a program to hack usa's, uk's and china's nuke siloes and rocet
navigasjon satelittes. take the world by force and dominate


*Adde_P Starts scripting :twisted:

Deller
  • Members
  • 239 posts
  • Last active: Dec 08 2011 08:36 PM
  • Joined: 21 Nov 2007

I don't think AHK can be used to peel potatos and make smoothies.

at lease yet. there are always updates :p

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
apart from jokes, does anybody have succeed on using Dllcall()
that requires pointer in arrays like this API? http://msdn.microsof...529(VS.85).aspx
when an WinAPI requires array i don't really know how to get it working.
will it be possible with olegbl's REAL ARRAY?
anyone have tried it?

[ Moderator!: MSDN link fixed ]
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com

m^2
  • Members
  • 100 posts
  • Last active: Mar 01 2011 09:31 AM
  • Joined: 28 Feb 2008
Didn't try it, but you can use DllCall to allocate memory and then use this memory in subsequent API calls.

Anyone who trades liberty for security deserves neither liberty nor security.


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

does anybody have succeed on using Dllcall()
that requires pointer in arrays like this API?

Arrays are no different to any other structure. A WORD is 2 bytes, so "three arrays of 256 WORD elements" = 3 * 256 * 2 = 1536 bytes.
VarSetCapacity(array, 1536)
; array_index: zero-based index of array (0-2)
; item_index: zero-based index of item within the array (0-255).
NumPut(value, array, array_index*256 + item_index*2, "short")

will it be possible with olegbl's REAL ARRAY?

That's a list in a string, not really an array.

reft
  • Guests
  • Last active:
  • Joined: --
It would be weird if this site dinged and mewoed like my computer. :lol: :shock:

Scorge
  • Members
  • 10 posts
  • Last active: Feb 24 2010 12:34 AM
  • Joined: 28 Aug 2007

Multi-threading would be pretty awesome. I'm not fond of using infinite loops to monitor state changes, but I'm even less fond of using timer objects for the same thing.

If it were possible to create infinite loops with a so-called "Do Events" command, I'd be happy.


I do "simulate" a multitreathing, opening 2 ahk, 1 opening the other, and comunicating with the help of file, read lines, title windows, etc...

Its very unpractic but it works, just make shure to fileinstall all the .ahk you use... and thats all :D
Posted Image

m^2
  • Members
  • 100 posts
  • Last active: Mar 01 2011 09:31 AM
  • Joined: 28 Feb 2008

Multi-threading would be pretty awesome. I'm not fond of using infinite loops to monitor state changes, but I'm even less fond of using timer objects for the same thing.

If it were possible to create infinite loops with a so-called "Do Events" command, I'd be happy.


I do "simulate" a multitreathing, opening 2 ahk, 1 opening the other, and comunicating with the help of file, read lines, title windows, etc...

Its very unpractic but it works, just make shure to fileinstall all the .ahk you use... and thats all :D

I don't agree that it's not practical. Often communication between threads is not needed. In such case you just run another instance of yourself with appropriate parameters and forget about it. Or create several other ones and wait for them.
When communication is needed, then indeed it's not too nice, but I believe there are still uses when it's worth the effort.

Anyone who trades liberty for security deserves neither liberty nor security.