KusochekDobra wrote:It will be very powerful instrument!
In "Source code (zip)" - link => in "Chrome.ahk" file => in 72 code-line have a one missing letter "t" (...\App Pahs\chrome.exe).
My bad, I'll fix it in the next release. Thanks for pointing it out!
KusochekDobra wrote:Can I ask you to add the name of the function to the constructor of
class Page by the third parameter, which will be called when the connection is broken?
For example:
*snip*
I make a simple wrapper for use in the program and concluded that it would be convenient to remove data about an unused connection from the object of this wrapper because of a disconnection that may occur if the user closes the tab.
Example:
*snip*
I hope this request does not look like impudence.
And thank you very much for your hard work!
Beautiful code and maximum efficiency!

Good idea, I'll try to add it to the next release. Thanks!
KusochekDobra wrote:And another question. Is it possible to replace this exception:
Code: Select all
Call(DomainAndMethod, Params:="", WaitForResponse:=True)
{
if !this.Connected
throw Exception("Not connected to tab")
; ... other code
}
To return a connection to the state "disabled"?
I think that this is logical, if all the tabs are closed, then you need to create a new connection, reinitializing the instance of the
class Chrome. Instead, there is a constant call "Runtime.evaluate" without parameters, and the program terminates its work after the exception message.
Because it throws an exception you can put multiple calls into a single
try-catch block, and use the catch to define something to happen instead of the script terminating. If
Call returned a value to indicate an error instead, you would have to check the result of every
Call individually, and it would make error propagation through wrappers like
Evaluate much more difficult.
KusochekDobra wrote:Sometimes, when creating an instance of a class Chrome, passing an address to the constructor, the method WaitForLoad() returns flow control before the page loads:
*snip*
This can be circumvented by creating an instance of the class without an address, followed by a transition PageInst.Call("Page.navigate", {"url": address}) and PageInst.WaitForLoad(), but is there any way to do without it?
Creating an instance without an address (or with an address like
about:blank then later using
Page.navigate is the recommended way right now. It's likely that, in the future, the library will use this method internally instead of passing in the URLs directly.
KusochekDobra wrote:Is it possible to connect to events such as
Target.targetCreated? This feature would reduce the possibility of errors, telling the ahk-code what him need to create a new connection.
I haven't tested it, but I think if use the
Target.setDiscoverTargets method that you can receive those events using the new callback system.
Stavencross wrote:I really love this library! Just a couple questions as I'd like to work it in deeper into my webapp.
One of the things I have to do is navigate to a url, and which triggers a pdf download. Is there a way for the lib to know when the download is complete? Right now I use a function called watch folder to loop through my downloads folder until a new file is present and grab it.
https://developer.chrome.com/extensions ... -onCreated
Something like this here would be perfect, but it's part of the extensions Api so I don't know that you have access to it.
Secondly, is it possible to launch chrome without the ui buttons, or similar to how in IE we can launch a shell as a gui browser?
I don't think there's a way to do that directly, but there may be a somewhat indirect way to go about it. When using Chrome.ahk you can connect to regular tabs, but also to the pages that make up extensions. If there's an extension with the proper permissions already in place, or if you can get an extension of your own creation installed, you should be able to connect to the extension and manipulate things from there.
Another possibility would be using one of the more hidden targets/pages that you can connect to. There's one listed on this page
http://localhost:9222/json/version separate from all the others (which are listed on just
http://localhost:9222/json) which has some slightly different functionality to it. What that functionality is, though, I'm not sure.
One method you may be interested in, although it's not what your'e asking for, is
Page.setDownloadBehavior which lets you change the folder that the files are saved to.
Final thing on this question. Your method of watching the folder sounds pretty robust, given how chrome downloads as a separate file then renames it to be the final downloaded file once it's complete. There are very efficient methods of watching folders demonstrated elsewhere on the forum. For example,
https://autohotkey.com/boards/viewtopic.php?t=8384 . On the other hand, you may find that complex functions for such a simple problem are unnecessary

. I'm all about informing people of their options, but you're more than free to make your own opinion.
For your second question, I'm pretty sure the answer is not with this library. You could look into something like the
Chrome Embedded Framework for Python and try to copy what it does, but it will be a lot of work.