![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Capture window caption of "this" program in XO Pro? I'm an absolute novice at scripting. I'd like to see if a simple script could capture the caption I see in the top-most colored border of the window of a certain program. For instance, my Outlook caption is "Inbox - Microsoft Outlook", and my IE window has "microsoft.public.scripting.vbscript | Google Groups - Windows Internet Explorer". If I feed the script the program name, can this be accomplished? My ultimate goal is to parse this string for a coule of elements to build some strings. Any pointers are greatly appreciated. Ed |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? "Ed from AZ" <prof_ofwhat@xxxxxx> wrote in message news:5d86d454-c1e0-4247-8f89-485ad5763c33@xxxxxx Quote: > I'm an absolute novice at scripting. I'd like to see if a simple > script could capture the caption I see in the top-most colored border > of the window of a certain program. For instance, my Outlook caption > is "Inbox - Microsoft Outlook", and my IE window has > "microsoft.public.scripting.vbscript | Google Groups - Windows > Internet Explorer". > > If I feed the script the program name, can this be accomplished? My > ultimate goal is to parse this string for a coule of elements to build > some strings. > > Any pointers are greatly appreciated. > Ed Set cTasks = CreateObject("Word.Application").Tasks For Each oTask In cTasks If InStr(1, oTask, "Outlook", 1) then WScript.echo oTask.name Next The script will show you the name of each process that is currently running and that has the word "Outlook" it its name. You should invoke the script with cscript.exe. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? Hi, Pegasus. Thanks for responding. I copied your code and saved it into a script file named FindTasks.vbs. I invoked it from Start >> Run using cscript // C:\Documents and Settings\MyUserName\Desktop\New Folder \FindTasks.vbs I think it worked, because I saw a Command Prompt window flash up on the screen very briefly. I do have Outlook open at the time and the window is open. But nothing stayed on the screen long enough to see what it was! How do you keep the Echo open long enough to read it? (And why invoke a new Word process?) Ed On Feb 11, 4:18*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "Ed from AZ" <prof_ofw...@xxxxxx> wrote in messagenews:5d86d454-c1e0-4247-8f89-485ad5763c33@xxxxxx > Quote: > > I'm an absolute novice at scripting. *I'd like to see if a simple > > script could capture the caption I see in the top-most colored border > > of the window of a certain program. *For instance, my Outlook caption > > is "Inbox - Microsoft Outlook", and my IE window has > > "microsoft.public.scripting.vbscript | Google Groups - Windows > > Internet Explorer". Quote: > > If I feed the script the program name, can this be accomplished? *My > > ultimate goal is to parse this string for a coule of elements to build > > some strings. Quote: > > Any pointers are greatly appreciated. > > Ed > Here is something to get you started: > > Set cTasks = CreateObject("Word.Application").Tasks > For Each oTask In cTasks > *If InStr(1, oTask, "Outlook", 1) then WScript.echo oTask.name > Next > > The script will show you the name of each process that is currently running > and that has the word "Outlook" it its name. You should invoke the script > with cscript.exe. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? If you launch console commands from the Start/Run box then you're punishing yourself because you'll see the messages flashing by, nothing else. Much better to do things properly by using a Command Prompt: 1. Click Start / Run 2. Type the letters cmd 3. Click the OK button. 4. Type this command: cscript //nologo "%UserProfile%\Desktop\New Folder\FindTasks.vbs" 5. Press the Enter button on your keyboard. "Ed from AZ" <prof_ofwhat@xxxxxx> wrote in message news:4acf32c0-a546-4495-a2a2-baecfef0b338@xxxxxx Hi, Pegasus. Thanks for responding. I copied your code and saved it into a script file named FindTasks.vbs. I invoked it from Start >> Run using cscript // C:\Documents and Settings\MyUserName\Desktop\New Folder \FindTasks.vbs I think it worked, because I saw a Command Prompt window flash up on the screen very briefly. I do have Outlook open at the time and the window is open. But nothing stayed on the screen long enough to see what it was! How do you keep the Echo open long enough to read it? (And why invoke a new Word process?) Ed On Feb 11, 4:18 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "Ed from AZ" <prof_ofw...@xxxxxx> wrote in > messagenews:5d86d454-c1e0-4247-8f89-485ad5763c33@xxxxxx > Quote: > > I'm an absolute novice at scripting. I'd like to see if a simple > > script could capture the caption I see in the top-most colored border > > of the window of a certain program. For instance, my Outlook caption > > is "Inbox - Microsoft Outlook", and my IE window has > > "microsoft.public.scripting.vbscript | Google Groups - Windows > > Internet Explorer". Quote: > > If I feed the script the program name, can this be accomplished? My > > ultimate goal is to parse this string for a coule of elements to build > > some strings. Quote: > > Any pointers are greatly appreciated. > > Ed > Here is something to get you started: > > Set cTasks = CreateObject("Word.Application").Tasks > For Each oTask In cTasks > If InStr(1, oTask, "Outlook", 1) then WScript.echo oTask.name > Next > > The script will show you the name of each process that is currently > running > and that has the word "Outlook" it its name. You should invoke the script > with cscript.exe. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? I agree that it is much better to do things properly by using a command prompt. I disagree on the method of navigating to the folder containing the script to be executed. My lazy old fingers don't want to type that long 'cscript //nologo "%UserProfile%\...\FindTasks.vbs" '; they usually screw it up once or twice. It is much easier to just right click in the white space of the folder that FindTasks.vbs resides in, and choose CMD Prompt, which opens a cmd prompt navigated to the proper folder. Then I just type cscript //nologo "FindTasks.vbs". The "s are only needed if the file name contains spaces. The tool to add the "CMD Prompt" to the context menu of the white space of a folder window is available at: http://www.roggel.com/NGNeer/BackgroundCMD/index.shtml I have used in on my WXP SP2 system for about two months with no apparent problems. Note that this is completely different from the 'command prompt here' context menu item commonly found elsewhere. -Paul Randall "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:e3RL41SjJHA.4860@xxxxxx Quote: > If you launch console commands from the Start/Run box then you're > punishing yourself because you'll see the messages flashing by, nothing > else. Much better to do things properly by using a Command Prompt: > 1. Click Start / Run > 2. Type the letters cmd > 3. Click the OK button. > 4. Type this command: > cscript //nologo "%UserProfile%\Desktop\New Folder\FindTasks.vbs" > 5. Press the Enter button on your keyboard. > > > "Ed from AZ" <prof_ofwhat@xxxxxx> wrote in message > news:4acf32c0-a546-4495-a2a2-baecfef0b338@xxxxxx > Hi, Pegasus. Thanks for responding. > > I copied your code and saved it into a script file named > FindTasks.vbs. > > I invoked it from Start >> Run using > cscript // C:\Documents and Settings\MyUserName\Desktop\New Folder > \FindTasks.vbs > > I think it worked, because I saw a Command Prompt window flash up on > the screen very briefly. I do have Outlook open at the time and the > window is open. But nothing stayed on the screen long enough to see > what it was! How do you keep the Echo open long enough to read it? > (And why invoke a new Word process?) > > Ed > > > On Feb 11, 4:18 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: >> "Ed from AZ" <prof_ofw...@xxxxxx> wrote in >> messagenews:5d86d454-c1e0-4247-8f89-485ad5763c33@xxxxxx >> Quote: >> > I'm an absolute novice at scripting. I'd like to see if a simple >> > script could capture the caption I see in the top-most colored border >> > of the window of a certain program. For instance, my Outlook caption >> > is "Inbox - Microsoft Outlook", and my IE window has >> > "microsoft.public.scripting.vbscript | Google Groups - Windows >> > Internet Explorer". Quote: >> > If I feed the script the program name, can this be accomplished? My >> > ultimate goal is to parse this string for a coule of elements to build >> > some strings. Quote: >> > Any pointers are greatly appreciated. >> > Ed >> Here is something to get you started: >> >> Set cTasks = CreateObject("Word.Application").Tasks >> For Each oTask In cTasks >> If InStr(1, oTask, "Outlook", 1) then WScript.echo oTask.name >> Next >> >> The script will show you the name of each process that is currently >> running >> and that has the word "Outlook" it its name. You should invoke the script >> with cscript.exe. > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? What you say is, of course, entirely correct. On the other hand I assumed that the OP had a reasonable understanding of folders, working directories and paths, considering that he now wishes to start writing scripts. If this is not the case then he should either acquire some basic console skills or limit himself to GUI tools and applications. "Paul Randall" <paulr90@xxxxxx> wrote in message news:Og1XpUTjJHA.4880@xxxxxx Quote: >I agree that it is much better to do things properly by using a command >prompt. I disagree on the method of navigating to the folder containing >the script to be executed. > > My lazy old fingers don't want to type that long 'cscript //nologo > "%UserProfile%\...\FindTasks.vbs" '; they usually screw it up once or > twice. > It is much easier to just right click in the white space of the folder > that FindTasks.vbs resides in, and choose CMD Prompt, which opens a cmd > prompt navigated to the proper folder. Then I just type > cscript //nologo "FindTasks.vbs". > The "s are only needed if the file name contains spaces. > > The tool to add the "CMD Prompt" to the context menu of the white space of > a folder window is available at: > http://www.roggel.com/NGNeer/BackgroundCMD/index.shtml > I have used in on my WXP SP2 system for about two months with no apparent > problems. > > Note that this is completely different from the 'command prompt here' > context menu item commonly found elsewhere. > > -Paul Randall > > > "Pegasus (MVP)" <I.can@xxxxxx> wrote in message > news:e3RL41SjJHA.4860@xxxxxx Quote: >> If you launch console commands from the Start/Run box then you're >> punishing yourself because you'll see the messages flashing by, nothing >> else. Much better to do things properly by using a Command Prompt: >> 1. Click Start / Run >> 2. Type the letters cmd >> 3. Click the OK button. >> 4. Type this command: >> cscript //nologo "%UserProfile%\Desktop\New Folder\FindTasks.vbs" >> 5. Press the Enter button on your keyboard. >> >> >> "Ed from AZ" <prof_ofwhat@xxxxxx> wrote in message >> news:4acf32c0-a546-4495-a2a2-baecfef0b338@xxxxxx >> Hi, Pegasus. Thanks for responding. >> >> I copied your code and saved it into a script file named >> FindTasks.vbs. >> >> I invoked it from Start >> Run using >> cscript // C:\Documents and Settings\MyUserName\Desktop\New Folder >> \FindTasks.vbs >> >> I think it worked, because I saw a Command Prompt window flash up on >> the screen very briefly. I do have Outlook open at the time and the >> window is open. But nothing stayed on the screen long enough to see >> what it was! How do you keep the Echo open long enough to read it? >> (And why invoke a new Word process?) >> >> Ed >> >> >> On Feb 11, 4:18 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: >>> "Ed from AZ" <prof_ofw...@xxxxxx> wrote in >>> messagenews:5d86d454-c1e0-4247-8f89-485ad5763c33@xxxxxx >>> >>> > I'm an absolute novice at scripting. I'd like to see if a simple >>> > script could capture the caption I see in the top-most colored border >>> > of the window of a certain program. For instance, my Outlook caption >>> > is "Inbox - Microsoft Outlook", and my IE window has >>> > "microsoft.public.scripting.vbscript | Google Groups - Windows >>> > Internet Explorer". >>> >>> > If I feed the script the program name, can this be accomplished? My >>> > ultimate goal is to parse this string for a coule of elements to build >>> > some strings. >>> >>> > Any pointers are greatly appreciated. >>> > Ed >>> >>> Here is something to get you started: >>> >>> Set cTasks = CreateObject("Word.Application").Tasks >>> For Each oTask In cTasks >>> If InStr(1, oTask, "Outlook", 1) then WScript.echo oTask.name >>> Next >>> >>> The script will show you the name of each process that is currently >>> running >>> and that has the word "Outlook" it its name. You should invoke the >>> script >>> with cscript.exe. >> > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? Sorry if I have opened a can of worms here. I have a reasonable understanding of Word and Excel VBA, in which I have invoked the FSO a few times. Other than that, my understanding of folders, files and directories is generally limited to the Windows Explorer interface! 8> { We are faced with a situation where we need to get some users to copy files belonging to a certain program from one folder into another as a backup. To get them to navigate to one folder, find the file and copy, open the other folder and copy, is "too much" and will not be done. I am trying to see if my limited knowledge and much Google searching can cobble together something to automate this to the point where they only need to double-click a script file to launch it and accomplish the action. I guess I do need to explore this much further. My original request was based on the assumption that the caption of the program window always carried the file path inclusing the user name. This would make building the strings for a file copy action much simpler. Unfortunately, it now looks like I'm going to have to ask for user input (akin to a VBA InputBox), and that may also be regarded as "too much". Thanks all for chiming in. There is so much I do not know and I would love to learn more. Unfortunately, since it's not my actual job description, there's not a lot of time allotted to work through and learn it all. So I ask questions that have answers I don't understand because there's huge gaps in my knowledge. Thank you all for being so very patient and willing to give. Ed On Feb 12, 10:29*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > What you say is, of course, entirely correct. On the other hand I assumed > that the OP had a reasonable understanding of folders, working directories > and paths, considering that he now wishes to start writing scripts. If this > is not the case then he should either acquire some basic console skills or > limit himself to GUI tools and applications. > > "Paul Randall" <paul...@xxxxxx> wrote in message > > news:Og1XpUTjJHA.4880@xxxxxx > > > Quote: > >I agree that it is much better to do things properly by using a command > >prompt. *I disagree on the method of navigating to the folder containing > >the script to be executed. Quote: > > My lazy old fingers don't want to type that long 'cscript //nologo > > "%UserProfile%\...\FindTasks.vbs" '; they usually screw it up once or > > twice. > > It is much easier to just right click in the white space of the folder > > that FindTasks.vbs resides in, and choose CMD Prompt, which opens a cmd > > prompt navigated to the proper folder. *Then I just type > > cscript //nologo "FindTasks.vbs". > > The "s are only needed if the file name contains spaces. Quote: > > The tool to add the "CMD Prompt" to the context menu of the white spaceof > > a folder window is available at: > >http://www.roggel.com/NGNeer/BackgroundCMD/index.shtml > > I have used in on my WXP SP2 system for about two months with no apparent > > problems. Quote: > > Note that this is completely different from the 'command prompt here' > > context menu item commonly found elsewhere. Quote: > > -Paul Randall Quote: > > "Pegasus (MVP)" <I....@xxxxxx> wrote in message > >news:e3RL41SjJHA.4860@xxxxxx Quote: > >> If you launch console commands from the Start/Run box then you're > >> punishing yourself because you'll see the messages flashing by, nothing > >> else. Much better to do things properly by using a Command Prompt: > >> 1. Click Start / Run > >> 2. Type the letters * cmd > >> 3. Click the OK button. > >> 4. Type this command: > >> * *cscript //nologo "%UserProfile%\Desktop\New Folder\FindTasks.vbs" > >> 5. Press the Enter button on your keyboard. Quote: Quote: > >> "Ed from AZ" <prof_ofw...@xxxxxx> wrote in message > >>news:4acf32c0-a546-4495-a2a2-baecfef0b338@xxxxxx > >> Hi, Pegasus. *Thanks for responding. Quote: Quote: > >> I copied your code and saved it into a script file named > >> FindTasks.vbs. Quote: Quote: > >> I invoked it from Start >> Run using > >> cscript // C:\Documents and Settings\MyUserName\Desktop\New Folder > >> \FindTasks.vbs Quote: Quote: > >> I think it worked, because I saw a Command Prompt window flash up on > >> the screen very briefly. *I do have Outlook open at the time and the > >> window is open. *But nothing stayed on the screen long enough to see > >> what it was! *How do you keep the Echo open long enough to read it? > >> (And why invoke a new Word process?) Quote: Quote: > >> Ed Quote: Quote: > >> On Feb 11, 4:18 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: > >>> "Ed from AZ" <prof_ofw...@xxxxxx> wrote in > >>> messagenews:5d86d454-c1e0-4247-8f89-485ad5763c33@xxxxxx Quote: Quote: > >>> > I'm an absolute novice at scripting. I'd like to see if a simple > >>> > script could capture the caption I see in the top-most colored border > >>> > of the window of a certain program. For instance, my Outlook caption > >>> > is "Inbox - Microsoft Outlook", and my IE window has > >>> > "microsoft.public.scripting.vbscript | Google Groups - Windows > >>> > Internet Explorer". Quote: Quote: > >>> > If I feed the script the program name, can this be accomplished? My > >>> > ultimate goal is to parse this string for a coule of elements to build > >>> > some strings. Quote: Quote: > >>> > Any pointers are greatly appreciated. > >>> > Ed Quote: Quote: > >>> Here is something to get you started: Quote: Quote: > >>> Set cTasks = CreateObject("Word.Application").Tasks > >>> For Each oTask In cTasks > >>> If InStr(1, oTask, "Outlook", 1) then WScript.echo oTask.name > >>> Next Quote: Quote: > >>> The script will show you the name of each process that is currently > >>> running > >>> and that has the word "Outlook" it its name. You should invoke the > >>> script > >>> with cscript.exe.- Hide quoted text - > - Show quoted text - |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? Since the caption of a process window does NOT show the path of the executable behind it, you appear to have started this thread by asking the wrong question. Perhaps the right question is: "How can I find out the path + name of an executable that launched a certain program?". If so then this script might be a first step in the right direction. Again it is a console script that must be executed from a Command Prompt, using cscript.exe. Note the double/single quotes in the first line of code. sProgram = "'Outlook.exe'" Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Process where Name = " & sProgram,,48) For Each objItem In colItems WScript.Echo "Command line=" & objItem.CommandLine Next I suggest you test the code, then review your requirements and post again. "Ed from AZ" <prof_ofwhat@xxxxxx> wrote in message news:ff3ae745-0586-44a8-bf54-abd13412cd8d@xxxxxx Sorry if I have opened a can of worms here. I have a reasonable understanding of Word and Excel VBA, in which I have invoked the FSO a few times. Other than that, my understanding of folders, files and directories is generally limited to the Windows Explorer interface! 8> { We are faced with a situation where we need to get some users to copy files belonging to a certain program from one folder into another as a backup. To get them to navigate to one folder, find the file and copy, open the other folder and copy, is "too much" and will not be done. I am trying to see if my limited knowledge and much Google searching can cobble together something to automate this to the point where they only need to double-click a script file to launch it and accomplish the action. I guess I do need to explore this much further. My original request was based on the assumption that the caption of the program window always carried the file path inclusing the user name. This would make building the strings for a file copy action much simpler. Unfortunately, it now looks like I'm going to have to ask for user input (akin to a VBA InputBox), and that may also be regarded as "too much". Thanks all for chiming in. There is so much I do not know and I would love to learn more. Unfortunately, since it's not my actual job description, there's not a lot of time allotted to work through and learn it all. So I ask questions that have answers I don't understand because there's huge gaps in my knowledge. Thank you all for being so very patient and willing to give. Ed |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? On Feb 12, 1:37*pm, Ed from AZ <prof_ofw...@xxxxxx> wrote: Quote: > Sorry if I have opened a can of worms here. *I have a reasonable > understanding of Word and Excel VBA, in which I have invoked the FSO a > few times. *Other than that, my understanding of folders, files and > directories is generally limited to the Windows Explorer interface! *8> > { > > We are faced with a situation where we need to get some users to copy > files belonging to a certain program from one folder into another as a > backup. *To get them to navigate to one folder, find the file and > copy, open the other folder and copy, is "too much" and will not be > done. *I am trying to see if my limited knowledge and much Google > searching can cobble together something to automate this to the point > where they only need to double-click a script file to launch it and > accomplish the action. > > I guess I do need to explore this much further. *My original request > was based on the assumption that the caption of the program window > always carried the file path inclusing the user name. *This would make > building the strings for a file copy action much simpler. > Unfortunately, it now looks like I'm going to have to ask for user > input (akin to a VBA InputBox), and that may also be regarded as "too > much". > > Thanks all for chiming in. *There is so much I do not know and I would > love to learn more. *Unfortunately, since it's not my actual job > description, there's not a lot of time allotted to work through and > learn it all. *So I ask questions that have answers I don't understand > because there's huge gaps in my knowledge. *Thank you all for being so > very patient and willing to give. > > Ed application? Why didn't you ask that in the first place? If you are running XP or later, this should get you what you want ... ' Get path of running processes using WMI sComputer = "." ' Local computer with GetObject("winmgmts:\\" & sComputer & "\root\cimv2") Set cItems = .ExecQuery("Select * From Win32_Process") end with sMatchName = "outlook.exe", for example For Each oItem in cItems if sMatchName = Lcase(oItem.Name) then sPath = Split(Replace(oItem.Commandline, Chr(34), ""), _ sMatchName, -1, 1)(0) s = sCmdLines & oItem.Commandline & ", " & sPath _ & vbNewline end if Next wsh.echo s Tom Lavedas *********** http://there.is.no.more/tglbatch/ |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Capture window caption of "this" program in XO Pro? "Paul Randall" <paulr90@xxxxxx> wrote: Quote: > I agree that it is much better to do things properly by using a command > prompt. I disagree on the method of navigating to the folder containing the > script to be executed. > > My lazy old fingers don't want to type that long 'cscript file://nologo > "%UserProfile%\...\FindTasks.vbs" '; they usually screw it up once or twice. Start->Run, type "%COMSPEC% /K cscript.exe " and then drag the script onto the dialog. Or type "cscript.exe " in any open command prompt and then drag the script into the command prompt windows. Unfortunately MSFT in their finite wisdom choose to disable drag&drop into command prompt windows in Vista. [...] Quote: > The tool to add the "CMD Prompt" to the context menu of the white space of a > folder window is available at: > http://www.roggel.com/NGNeer/BackgroundCMD/index.shtml > I have used in on my WXP SP2 system for about two months with no apparent > problems. > > Note that this is completely different from the 'command prompt here' > context menu item commonly found elsewhere. interpret the registry keys beyond [HKCR\Directory\Background\Shell], [HKCR\Directory\Background\Shell] and [HKCR\Folder\Background\Shell] ... until Vista, AFAIK. Stefan |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Shortcut changes when changing attribute from "Normal window" to "Maximized" | Vista General | |||
| "right click" and "open" on an icon does not start the program! | Vista General | |||
| Can Vista Home Premium capture "still shots" from a family video C | Vista music pictures video | |||
| "Recently Opened Programs" list and "Search for program" fail | Vista installation & setup | |||
| Where are settings for "Confirm after download" & "in same window" | Vista performance & maintenance | |||