Closed dmtr99 closed 2 years ago
Map supports case sensitivity, while object is not case sensitive, although it is rare to have keys with different cases at the same time.
And run Map.Prototype.DefineProp('__get', {call: Map.Prototype.Get})
, you can use map just like object.
Interesting trick, thanks a lot. Strange how it stays case sensitive, or you need to set the CaseSense Off before filling the object. in some strange cases you would indeed lose data and that is indeed a disadvantage to this approach, and maybe it is better to keep the code cleaner.
oMap := Map()
oMap.CaseSense := "Off"
oMap.Set("Red", "ff0000" , "Green", "00ff00", "Deep Blue", "0000ff")
oMap.DefineProp('__get', { call: oMap.Get })
MsgBox("oMap.red:" oMap.red "`noMap.Red:" oMap.Red)
I however have another question, I want to connect to chrome without opening a new tab, but it seems this version always opens a new tab.
If I remember correctly, I used to connect to Chrome with:
PageInst := Chrome.GetPage()
But I now get the error "This value of type ''Class" has no method named "GetPage".
This code seems to work, but always opens a new tab:
ChromeInst := Chrome()
ChromeTab := ChromeInst.GetPage()
Use an existing browser that starts in debug mode?
Yes, I have the habit to run my browser always in debug mode. In the V1 version you could connect to the existing debug window with this code.
This problem has been fixed. Chrome.FindInstances
Tested and approved.
Just for clarity, my previous code still does not work.
this seems to work perfectly:
ChromeInst := Chrome.FindInstances()
ChromeTab := ChromeInst.GetPage()
result := ChromeTab.Evaluate("window.location.href")
msgbox(result["value"])
I tested some v2 Chrome.ahk code, and It seems to be working great, thanks a lot for your amazing and usefull work :D
Currently the JSON is returning a map, but would it not be more logically to return an object? I found it strange to get maps back. I know V1 mixed Maps and Objects. This would make it easier to change some old scripts to v2.
Working example v2:
Normally I would think that result.value should be the correct syntax.