Jump to content

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

COM Standard Library


  • Please log in to reply
669 replies to this topic
ddk
  • Members
  • 43 posts
  • Last active: Oct 12 2010 11:03 PM
  • Joined: 28 Dec 2009
So, how I can get the active controls value in IE? :?

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
what presicely is an active controls value ???? i seem to iliterate to understand
:shock:
Never lose.
WIN or LEARN.

ddk
  • Members
  • 43 posts
  • Last active: Oct 12 2010 11:03 PM
  • Joined: 28 Dec 2009

what presicely is an active controls value ???? i seem to iliterate to understand
:shock:

:D :D Apologies for being rough.
Well.. Explanatory picture:
Posted Image
I just want my script get the value like iWebBrowser2 Learner does. :(

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
There are several tutorials in the forum covering this, not to mention one outdated tutorial by tank covering almost this exact example. Start here.

ddk
  • Members
  • 43 posts
  • Last active: Oct 12 2010 11:03 PM
  • Joined: 28 Dec 2009

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.

ribbs2521
  • Members
  • 279 posts
  • Last active: Feb 23 2012 05:58 PM
  • Joined: 28 Sep 2007
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)
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:
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.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
@ribbs2521: Make sure you're using my custom AutoHotkey build (AHK_COM was merged into it) instead of the regular AutoHotkey.exe.
The file you want is AutoHotkey_La.exe (which is the 32-bit ANSI version).

ribbs2521
  • Members
  • 279 posts
  • Last active: Feb 23 2012 05:58 PM
  • Joined: 28 Sep 2007
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.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
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:

Function Name: "Name"
ERROR: No COM Dispatch Object!


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: <!-- m -->http://www.autohotke...topic49736.html<!-- m -->

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.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
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?

i3egohan
  • Members
  • 403 posts
  • Last active: Feb 15 2012 12:07 PM
  • Joined: 18 Jul 2006
Can someone show example to call function from the following OCX.

<!-- m -->http://www.freedownl... ... Crypt.html<!-- m -->

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
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?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

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.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

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.

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.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
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.