| View previous topic :: View next topic |
| Author |
Message |
ddk
Joined: 28 Dec 2009 Posts: 43
|
Posted: Fri Jun 18, 2010 12:21 am Post subject: |
|
|
So, how I can get the active controls value in IE?  |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Fri Jun 18, 2010 2:56 am Post subject: |
|
|
what presicely is an active controls value ???? i seem to iliterate to understand
 _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
ddk
Joined: 28 Dec 2009 Posts: 43
|
Posted: Fri Jun 18, 2010 12:57 pm Post subject: |
|
|
| tank wrote: | what presicely is an active controls value ???? i seem to iliterate to understand
 |
Apologies for being rough.
Well.. Explanatory picture:
I just want my script get the value like iWebBrowser2 Learner does.  |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Fri Jun 18, 2010 2:28 pm Post subject: |
|
|
There are several tutorials in the forum covering this, not to mention one outdated tutorial by tank covering almost this exact example. Start here. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
ddk
Joined: 28 Dec 2009 Posts: 43
|
Posted: Fri Jun 18, 2010 3:39 pm Post subject: |
|
|
| sinkfaze wrote: | | There are several tutorials in the forum covering this, not to mention one outdated tutorial by tank covering almost this exact example. Start here. | Ive been reading that tutorial (as you can see from last page), but couldn't find it. I'll read that once again and keep looking. |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jun 25, 2010 5:09 pm Post subject: |
|
|
Not sure who's dealt with ADO using the latest AutoHotKey_COM but I seem to be running into an issue.
This Function Works fine before compiling but afterward I get an error that says the variable rs.EOF contains an illegal character.
Maybe I missed something but I'm not sure since, like I said, it works when it's not compiled. (It compiles with no errors either) | Code: | MySQL_Query_RS(connection, query)
{
;If it is not a SELECT statement, assume there is no need for an RS as it is a modifier
if (SubStr(query, 1, 6) != "SELECT")
return connection.Execute(query)
rs := ComObjCreate("ADODB.RecordSet")
rs.Open(query, connection)
If (rs.EOF)
Msgbox, No Data returned by this query`n`n%query%
return rs
} |
Here is the code to generate a connection:
| Code: | CreateMySQLConnection(username, password, databaseName, hostIP)
{
local dsn
dsn := "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" . hostIP . ";DATABASE=" . databaseName . ";USER=" . username . ";PASSWORD=" . password . ";OPTION=3;"
connection := ComObjCreate("ADODB.Connection")
connection.Open(dsn)
return connection
} |
There are other functions as well that are all part of a wrapper class as I have numerous programs that access my database. |
|
| Back to top |
|
 |
fincs
Joined: 05 May 2007 Posts: 1163 Location: Seville, Spain
|
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jun 25, 2010 5:26 pm Post subject: |
|
|
Fincs, I wasn't using that file but even after doing so I get the same thing.
Edit: Scratch that, I compiled it with Compile_AHK using Compile with options. When I just used Compile from the context menu it works fine. Any idea why that is? I would like to be able to compile with options. Sorry, when it comes to compiling and all of that stuff I have no idea what's going on. At least with writing applications I am somewhat capable. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 1199
|
Posted: Thu Jul 22, 2010 2:29 pm Post subject: |
|
|
I'm using ahk_l and the latest com version, both ansi.
Using the following function in a folder with ~40 files I get about 2-3 COM errors saying this:
| Quote: | Function Name: "Name"
ERROR: No COM Dispatch Object! |
| Code: | SelectFiles(Select,Clear=1,Deselect=0,MakeVisible=1,focus=1, hWnd=0)
{
If hWnd||(hWnd:=WinActive("ahk_class CabinetWClass"))||(hWnd:=WinActive("ahk_class ExploreWClass"))
{
sa := Com_CreateObject("Shell.Application")
;Find hwnd window
wins := sa.Windows
loop % wins.count
{
window:=wins.Item(A_Index-1)
If Not InStr( window.FullName, "steam.exe" ) ; ensure pwb isn't IE
if(window.Hwnd=hWnd)
break
}
doc:=window.Document
value:=!Deselect
value1:=!Deselect+focus*16+MakeVisible*8
if(Clear)
value1+=clear*4
Loop % Select.len()
{
filter := Select[A_Index]
If filter <>
{
If(InStr(filter, "*"))
{
filter := "\Q" StringReplace(filter, "*", "\E.*\Q", 1) "\E"
filter := strTrim(filter,"\Q\E")
Loop % doc.Folder.Items.Count
{
item := doc.Folder.Items.Item(A_Index)
if(RegexMatch(item.Name,"i)" filter))
{
COM_Invoke(doc,"SelectItem",item,index=1 ? value1 : value) ;http://msdn.microsoft.com/en-us/library/bb774047(VS.85).aspx
index++
}
}
}
else
COM_Invoke(doc,"SelectItem",doc.Folder.ParseName(filter),(A_Index=1 ? value1 : value)) ;http://msdn.microsoft.com/en-us/library/bb774047(VS.85).aspx
}
}
}
} |
The function expects Select to be an array object from Temp01's array library: http://www.autohotkey.com/forum/topic49736.html
The values may contain * as placeholders, so you can use *.jpg etc.
Any idea why I'm seeing those errors? I've also noticed them at some other functions involving COM, but they're only happening sometimes and haven't disturbed me yet since I could just turn them off and they wouldn't disturb functionality much. I would like to get rid of them here though, since this function will not select all files in its current state. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Jul 22, 2010 11:52 pm Post subject: |
|
|
| I'm not sure why you posted in this thread. Have you pinned down the origin of your errors? Is it a bug in COM.ahk, or a bug in Windows' shell etc, or a bug in your code or just your system? I failed to see any COM.ahk related errors in this but I could spot an error in your code. So, what are you expecting from me by only saying you got errors with your code? |
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 403
|
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 1199
|
Posted: Fri Jul 23, 2010 5:28 pm Post subject: |
|
|
Sean, you are right, I did not realize that I needed to use zero based index for the folderitems, but this is not the cause of this error.
I noticed that if I add a sleep 10 after each SelectItem call, it works fine, so I can only suspect that there is an issue in COM or explorer shell. My knowledge of COM is not good enough to figure anything out on that level, which is why I'm asking here.
Do I need to release any resources? I was thinking that COM_Release was not needed anymore? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Sat Jul 24, 2010 2:08 am Post subject: |
|
|
| i3egohan wrote: | | Can someone show example to call function from the following OCX. | You better consult the documentation of the app. Not many users may like to install a foreign app. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Sat Jul 24, 2010 2:22 am Post subject: |
|
|
| fragman wrote: | | I noticed that if I add a sleep 10 after each SelectItem call, | This is understandable. Some shell operations don't wait until all needed underlying procedures are completed, probably/mainly for performance reason. It's similar to Navigate(2) in IWebBrowser2. The simplest solution to this may be to add sufficient sleep as you did. Or you could utilize the event SelectionChanged in DShellFolderVeiwEvents. Or you may call directly the function SelectItem in the interface IFolderView.
| Quote: | | Do I need to release any resources? I was thinking that COM_Release was not needed anymore? | It's no longer needed with COM_L/AHK_L. BTW, I strongly recommend UNICODE build over ANSI build. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 1199
|
Posted: Sat Jul 24, 2010 8:58 am Post subject: |
|
|
Hmm, I'll have to try finding a good sleep ammount, sleeping after every call makes it quite slow, maybe with the method mentioned in docs for shorter sleep.
I'm planning to switch to Unicode at some point, but I'm not sure if I'm going to do it before IronAHK is ready.
Just for information, it appears that the calls to doc.Folder.Items.Item or to item.Name are causing the problems. I've separated the loop that queries the name and the loop for file selection, and SelectItem works fine without sleeps. |
|
| Back to top |
|
 |
|