Hi David, I've noticed that when MSHTML turns up as the module name for the focused window, you often get a program specific module name just by using the active window's module name instead of the focused window.
In addition, you can actually get the full path to the running program with: focusedwindow.Process.ExecutablePath maybe either of these will help you determine more about the running program. hth, Chip > -----Original Message----- > From: David [mailto:eleph...@tele2.no] > Sent: Sunday, March 11, 2012 7:55 AM > To: gw-scripting@gwmicro.com > Subject: Re: How to know - setfile questions > > Listers, > I just made yet a new discovery. Any ideas for a workaround? > > I was suggested to hook onto the ModuleName. I so did, under > the FocusedWindow object, like this: > Speak FocusedWindow.ModuleName > > In most cases I have tested it, it works just fine. When in > Notepad, I am told "Notepad". In Outlook Express - in the > Inbox for instance - I am told "MSOE"; Which I can live with. > > The problem arises when I open a website, an Email, or any > other stuff of that nature. I then am told "MSHtml". > > My app, which will be acting slightly different in Notepad, > from what it will in Internet explorer, do save settings in > different files. That is, it will make a file called > Notepad.xxx, another called MSOE.xxx, and so forth. > In all of the cases, this works flawlessly now. That is, > except from those cases, where the FocusedWindow.ModuleName > returns the "MSHtml" phrase. In those cases, even if the file > MSHtml.xxx does exist, I can't get the info to load. OK, I am > not asking you to tell me why it won't load. But is there any > other info I can hook onto, as an alternative to the > FocusedWindow.ModuleName, so as to get a more reliable > string, that reflects the actual running program in the html > cases? I.e, I would have been happy to get just the Internet > explorer, or Firefox info. Hope my question makes sense. In > other words, which method or property could I hook on to, > which would give me a string like "IExplorer", instead of > just "MSHtml"? > > Thanks for any feedback. > > ----- Original Message ----- > From: "David" <eleph...@tele2.no> > To: <gw-scripting@gwmicro.com> > Sent: Sunday, March 11, 2012 12:16 AM > Subject: Re: How to know - setfile questions > > > > Thanks Ralph, > > That helped me a bit on the way. Also, I made a discovery. > Not sure, > > exactly what was going on, but I'd leave it here, in case > it might prove > > helpful to others. Sorry, I can't bring the full code here, > since it is > > more like 450 lines. > > > > Thing is, I called the ConnectEvent, and more or less right > after that, I > > defined my personal sub for the Event. Further down, I had > some more code, > > that would not necessarily have affected this set of lines > - from what I > > can see. Still, out of some reason, the app insisted on > hanging on me, > > throwing the same low-explanatory error message on me. > > > > In the end, I moved the ConnectEvent line, to the very > bottom of my code. > > And, guess what - all the sudden, everything works flawlessly. > > > > So, for the rest of you, it seems to be an idea, to place your > > ConnectEvent lines, at the bottom of the code. Don't know, > if this would > > be a general suggestion, or why my app did not behave until > this had been > > done. But at least, if anyone experience a similar case - > where you cannot > > get the ConectEvent to work - it might be worth a try to > move it to the > > end of your code. > > > > Well, just wanted to let you all know, in case it would > benefit anyone. > > > > Thanks for all assistance. > > > > ----- Original Message ----- > > From: "Ralf Kefferpuetz" <rkefferpu...@elra-consulting.de> > > To: <gw-scripting@gwmicro.com> > > Sent: Saturday, March 10, 2012 7:51 PM > > Subject: RE: How to know - setfile questions > > > > > >> David, in the sub section you might need a variable like: > >> Sub MyOnChildActivate(Variable) > >> ' some more code. > >> End Sub > >> > >> Ralf Heinrich Kefferpuetz > >> Web: http://www.keffi.eu > >> Facebook: http://www.facebook.com/Keffi.eu > >> Germany > >> > >> -----Original Message----- > >> From: David [mailto:eleph...@tele2.no] > >> Sent: Saturday, March 10, 2012 2:04 PM > >> To: gw-scripting@gwmicro.com > >> Subject: Re: How to know - setfile questions > >> > >> Hello Chip, and rest of gang. > >> Thanks Chip, for your ideas. I think you are right, and I will try > >> hooking > >> my script to the ModuleName of the Window object, as you suggested. > >> > >> I ran into a snake here though - it seems. You suggested > for me, to look > >> out > >> for the OnChildActivate event of the DesktopWindow - if I > got you right. > >> So, > >> I tried the following line in my code, but got the message that the > >> object doesn't support this property or method. > >> Not sure, which property or method it is referring to, but > have a clear > >> feeling I am missing an important step. Any corrections > will be greatly > >> appriciated. > >> > >> ---Code snip---- > >> > >> ConnectEvent DesktopWindow, "OnChildActivate", "MyOnChildActivate" > >> 'Yep, this is the line that throws the error. > >> > >> > >> Sub MyOnChildActivate > >> ' some more code. > >> End Sub > >> ---End of snip--- > >> > >> From: Chip Orange <mailto:lists3...@comcast.net> > >> To: gw-scripting@gwmicro.com > >> Sent: Monday, February 20, 2012 12:34 AM > >> Subject: RE: How to know - setfile questions > >> > >> Hi David, > >> > >> You asked how to make your global app act differently depending on > >> which program had the active window at the moment? > Looking at the active > >> set file isn't a bad idea, however, because some programs > are so complex, > >> they can end up having many set files, any of which might > be in use at > >> the > >> moment (I think I recall MS Word maybe having around 10?). > So, if you > >> just > >> test on the name of the primary set file, and one of these > secondary ones > >> is > >> active, your app may not work as you want. > >> > >> There is something else you can test on: that would be the name of > >> the program associated with the active window. The way I > do this, and > >> the > >> one I've seen used most often, is to test on the > moduleName property of > >> the > >> activeWindow object. I think for MS Word, or any other > program, this > >> module > >> name should always remain constant, regardless of which of > it's set files > >> is > >> loaded. > >> > >> Unfortunately, there is no event to tell you when the module has > >> changed, so you would need to capture the window event for > when a new > >> window > >> becomes the activeWindow, and when that happens see if the > module name > >> has > >> changed (you would have to use the desktopWindow object, and the > >> onChildActivate event to know when a new window has become active). > >> > >> I think this is better than testing on set file names, but if it's > >> not, I'm sure you'll hear back from GW or someone. > >> > >> hth, > >> > >> Chip > >> > >> > >> > >> > >> ________________________________ > >> > >> From: David [mailto:eleph...@tele2.no] > >> Sent: Friday, February 17, 2012 10:57 PM > >> To: gw-scripting@gwmicro.com > >> Subject: How to know - setfile questions > >> > >> > >> I am in the planning process of a new app. Since this is all > >> on the slate, I am not sure exactly what info to give, so > my questions > >> would > >> be all in general. I did have a scroll look in the > App-reference, but > >> without luck; hence my questions go to the listers. > >> > >> 1. Is there a way for my app, to retrieve info, as to which > >> setfile is currently active? Something like an > >> ActiveSetFile > >> method? > >> > >> 2. Is there any event, that fires whenever the setfile > >> changes? I.e, if I am in the Explorer window, and I > alt-tab to Firefox. > >> Or, > >> will I have to retrieve the activeSetfile at any given > point, making my > >> system loaded with a watching routine. > >> > >> At the planning state, where I am right now, I thought > >> hooking on to the currently active setfile - at any given > moment - might > >> be > >> the best way of handling my project. Specially so, since > it will be > >> behaving > >> slightly differently from one application to the other. Is > there any > >> other > >> method, that might be easier, if one wants to have a global app act > >> differently in Explorer, than what it does in Firefox, or > Outlook, or any > >> other application? > >> > >> Thanks for any tips. Since I still am in a basic line of app > >> developing for WE, I'd greatly appreciate if you could try > to be as > >> simple > >> as possible in your reply. Thanks alot! > >> > >> > >> > > >