Clicking one application's buttons from another application

Hello,

I'd like to write an application that can click the 
buttons of another application running on the same 
machine.  All my application knows about the target 
application is its name, the name of the window containing 
the buttons, and the name of the buttons.  Can someone 
further my education in this matter in some way.

Thanks,
Ray Mitchell
0
7/9/2003 9:36:09 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
616 Views

Similar Articles

[PageSpeed] 35

This is tricky, but possible. I actually do it in a little utility I wrote to move Outlook
filters down, since the "Move Down" button doesn't autorepeat and when you have 850
anti-spam filters it becomes a bit unwieldy.

What you need to get is the HWND of the dialog containing the button. You more likely want
to look for the button ID, not the button name, which you can easily discover using Spy++.
What I did was SendMessage to the dialog a WM_COMMAND message for a BN_CLICKED event for
the button whose HWND and ID I had. One of the few times I really used GetDlgItem.
void CRulesHelperDlg::FindRuleWindow()
    {
     CString caption;
     caption.LoadString(IDS_RULES_WIZARD_CAPTION);
     HWND h = ::FindWindow(NULL, caption);
     if(h != NULL)
	{ /* keep it */
	 if(rules != NULL)
	    delete rules;
	 rules = (CDialog *)CWnd::FromHandle(h);
	} /* keep it */
    } // CRulesHelperDlg::FindRuleWindow

void CRulesHelperDlg::RuleMove(int distance)
    {
     WORD control;
     if(distance < 0)
	control = IDC_MOVE_DOWN;
     else
	control = IDC_MOVE_UP;

     CWnd * wnd = rules->GetDlgItem(control);
     for(int i = 0; i < abs(distance); i++)
	rules->SendMessage(WM_COMMAND, MAKELONG(control, BN_CLICKED),
(LPARAM)wnd->m_hWnd); 
     updateControls();
    } // CRulesHelperDlg::RuleMove

					joe
On Wed, 9 Jul 2003 14:36:09 -0700, "Ray Mitchell" <ray.mitchell@navy.mil> wrote:

>Hello,
>
>I'd like to write an application that can click the 
>buttons of another application running on the same 
>machine.  All my application knows about the target 
>application is its name, the name of the window containing 
>the buttons, and the name of the buttons.  Can someone 
>further my education in this matter in some way.
>
>Thanks,
>Ray Mitchell

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15977)
7/9/2003 10:08:24 PM
Thanks for the detained information.  Strange coincidence 
though.  The application I want to click is also Outlook.  
In reality, I'm actually running Outlook from a server 
rather than on my local machine.  However, since the GUI 
actually appears on my local machine, I assume that it 
doesn't really matter (or does it?).  To be specific, I'd 
like to click the Send/Receive button periodically so I 
don't get kicked off the network due to a network 
inactivity timeout.  Maybe there's a simpler approach to 
simply avoiding a timeout.


>-----Original Message-----
>This is tricky, but possible. I actually do it in a 
little utility I wrote to move Outlook
>filters down, since the "Move Down" button doesn't 
autorepeat and when you have 850
>anti-spam filters it becomes a bit unwieldy.
>
>What you need to get is the HWND of the dialog containing 
the button. You more likely want
>to look for the button ID, not the button name, which you 
can easily discover using Spy++.
>What I did was SendMessage to the dialog a WM_COMMAND 
message for a BN_CLICKED event for
>the button whose HWND and ID I had. One of the few times 
I really used GetDlgItem.
>void CRulesHelperDlg::FindRuleWindow()
>    {
>     CString caption;
>     caption.LoadString(IDS_RULES_WIZARD_CAPTION);
>     HWND h = ::FindWindow(NULL, caption);
>     if(h != NULL)
>	{ /* keep it */
>	 if(rules != NULL)
>	    delete rules;
>	 rules = (CDialog *)CWnd::FromHandle(h);
>	} /* keep it */
>    } // CRulesHelperDlg::FindRuleWindow
>
>void CRulesHelperDlg::RuleMove(int distance)
>    {
>     WORD control;
>     if(distance < 0)
>	control = IDC_MOVE_DOWN;
>     else
>	control = IDC_MOVE_UP;
>
>     CWnd * wnd = rules->GetDlgItem(control);
>     for(int i = 0; i < abs(distance); i++)
>	rules->SendMessage(WM_COMMAND, MAKELONG(control, 
BN_CLICKED),
>(LPARAM)wnd->m_hWnd); 
>     updateControls();
>    } // CRulesHelperDlg::RuleMove
>
>					joe
>On Wed, 9 Jul 2003 14:36:09 -0700, "Ray Mitchell" 
<ray.mitchell@navy.mil> wrote:
>
>>Hello,
>>
>>I'd like to write an application that can click the 
>>buttons of another application running on the same 
>>machine.  All my application knows about the target 
>>application is its name, the name of the window 
containing 
>>the buttons, and the name of the buttons.  Can someone 
>>further my education in this matter in some way.
>>
>>Thanks,
>>Ray Mitchell
>
>Joseph M. Newcomer [MVP]
>email: newcomer@flounder.com
>Web: http://www.flounder.com
>MVP Tips: http://www.flounder.com/mvp_tips.htm
>.
>
0
7/9/2003 10:47:14 PM
Ray Mitchell wrote:
> 
> Thanks for the detained information.  Strange coincidence
> though.  The application I want to click is also Outlook.
> In reality, I'm actually running Outlook from a server
> rather than on my local machine.  However, since the GUI
> actually appears on my local machine, I assume that it
> doesn't really matter (or does it?).  To be specific, I'd
> like to click the Send/Receive button periodically so I
> don't get kicked off the network due to a network
> inactivity timeout.  Maybe there's a simpler approach to
> simply avoiding a timeout.

That depends on what "running it from a server" means.  It does not
matter where the disk is that contains Outlook.  The Outlook program
must be executing on your machine for the FindWindow to work.

--
Scott McPhillips [VC++ MVP]
0
scottmcp (342)
7/9/2003 11:31:37 PM
outlook supports "check for new mesages every X minuites", this can be as
low as 1 minuite, which does a send/receive action.

Not sure if this will save you time programming - as you dont need to do it
programicly.

joe
#

"Ray Mitchell" <ray.mitchell@navy.mil> wrote in message
news:9f2501c3466c$0acfaae0$a401280a@phx.gbl...
> Thanks for the detained information.  Strange coincidence
> though.  The application I want to click is also Outlook.
> In reality, I'm actually running Outlook from a server
> rather than on my local machine.  However, since the GUI
> actually appears on my local machine, I assume that it
> doesn't really matter (or does it?).  To be specific, I'd
> like to click the Send/Receive button periodically so I
> don't get kicked off the network due to a network
> inactivity timeout.  Maybe there's a simpler approach to
> simply avoiding a timeout.
>
>
> >-----Original Message-----
> >This is tricky, but possible. I actually do it in a
> little utility I wrote to move Outlook
> >filters down, since the "Move Down" button doesn't
> autorepeat and when you have 850
> >anti-spam filters it becomes a bit unwieldy.
> >
> >What you need to get is the HWND of the dialog containing
> the button. You more likely want
> >to look for the button ID, not the button name, which you
> can easily discover using Spy++.
> >What I did was SendMessage to the dialog a WM_COMMAND
> message for a BN_CLICKED event for
> >the button whose HWND and ID I had. One of the few times
> I really used GetDlgItem.
> >void CRulesHelperDlg::FindRuleWindow()
> >    {
> >     CString caption;
> >     caption.LoadString(IDS_RULES_WIZARD_CAPTION);
> >     HWND h = ::FindWindow(NULL, caption);
> >     if(h != NULL)
> > { /* keep it */
> > if(rules != NULL)
> >     delete rules;
> > rules = (CDialog *)CWnd::FromHandle(h);
> > } /* keep it */
> >    } // CRulesHelperDlg::FindRuleWindow
> >
> >void CRulesHelperDlg::RuleMove(int distance)
> >    {
> >     WORD control;
> >     if(distance < 0)
> > control = IDC_MOVE_DOWN;
> >     else
> > control = IDC_MOVE_UP;
> >
> >     CWnd * wnd = rules->GetDlgItem(control);
> >     for(int i = 0; i < abs(distance); i++)
> > rules->SendMessage(WM_COMMAND, MAKELONG(control,
> BN_CLICKED),
> >(LPARAM)wnd->m_hWnd);
> >     updateControls();
> >    } // CRulesHelperDlg::RuleMove
> >
> > joe
> >On Wed, 9 Jul 2003 14:36:09 -0700, "Ray Mitchell"
> <ray.mitchell@navy.mil> wrote:
> >
> >>Hello,
> >>
> >>I'd like to write an application that can click the
> >>buttons of another application running on the same
> >>machine.  All my application knows about the target
> >>application is its name, the name of the window
> containing
> >>the buttons, and the name of the buttons.  Can someone
> >>further my education in this matter in some way.
> >>
> >>Thanks,
> >>Ray Mitchell
> >
> >Joseph M. Newcomer [MVP]
> >email: newcomer@flounder.com
> >Web: http://www.flounder.com
> >MVP Tips: http://www.flounder.com/mvp_tips.htm
> >.
> >


0
joey
7/9/2003 11:43:31 PM
Why would you get kicked off of your network because of perceived
inactivity?

"Ray Mitchell" <ray.mitchell@navy.mil> wrote in message
news:9f2501c3466c$0acfaae0$a401280a@phx.gbl...
> Thanks for the detained information.  Strange coincidence
> though.  The application I want to click is also Outlook.
> In reality, I'm actually running Outlook from a server
> rather than on my local machine.  However, since the GUI
> actually appears on my local machine, I assume that it
> doesn't really matter (or does it?).  To be specific, I'd
> like to click the Send/Receive button periodically so I
> don't get kicked off the network due to a network
> inactivity timeout.  Maybe there's a simpler approach to
> simply avoiding a timeout.


0
7/10/2003 1:10:27 PM
Reply:

Similar Artilces:

Linking a one Presentation to Another Presentation
I have several presentations that are linked to my main presentation so when you click a link the secondary presentation opens up. My problem is that everytime I click a link that new presentation opens, which is good, but it doesn't close when I link back to the "home page". Is it possible to have a presentation close when you click the link back to the home page? This sounds like a PowerPoint question? On Mar 17, 8:49=A0am, ElizabethS <Elizabe...@discussions.microsoft.com> wrote: > I have several presentations that are linked to my main presentation so...

Copy a string text to cell if another cell not empty
Hi. I appreciate your help. I need to run a macro to do this Start the cursor in the cell x3 and paste a string text then 2 cells down and past again and this untill ... (but if find the word "lic" in some cell in other column like column B stops to paste the text. I really need your help. Thanks. ...

How to distinguish right click from left click forNIN_BALLOONUSERC
Hi, In OnTrayIconNotify, my program process NIN_BALLOONUSERCLICK. According to msdn, NIN_BALLOONUSERCLICK was sent when the balloon is dismissed because of a mouse click. Is it possible to distinguish right mouse click from left mouse click for this message? I want my program to open a new window when user left click on the balloontip but pop up the context menu when user right click on the trayicon. Any help would be greatly appreciated. Richard -- Nothing impossible, Nothing easy If you handle it fast enough you could just look at the state of the mouse button when you get the me...

cancel another user's appointments : is it possible?
Let's say a secretary has rights to her boss's calendar in her Outlook (2000). Is there a way she can cancel appointments that were created by him? Right now she can only cancel the ones she created. Thanks in advance. What permissions does she have? I've never tried this, so I can't say for sure that it will send out the 'cancel' notifications for meetings he's set up himself even if she has sufficient privileges in his calendar....but it's where I'd check first. johndoe wrote: > Let's say a secretary has rights to her boss's calendar in h...

how do I out all my data into one row
I have data fro a las file which i have opened in excel. due to the number of columns the las file grouped the data line by line instead of column by colmn. Due to the amount of data it is impractical to change all the data by copy & paste: eg of data what it is like and what I need: -999.25 -999.25 -999.25 -999.25 -999.25 29.5625 -999.25 -999.25 145.7 51.1411 -999.25 -999.25 51.1411 28.5625 2.4043 1.8379 -999.25 -999.25 -999.25 -999.25 -999.25 -999.25 2.4043 1.8379 -999.25 2.1426 -85.1875 need: -999.25 -999.25 -999.25 -999.25 -999.25 29.5625 -999.25 -999.25 145.7 51.1411 -999.25 ...

Count and Reset Button Clicks
Hello Experts. I have a Yahtzee game with 2 buttons/2 macros. One button (Roll Dice) rolls the dice (Calculate) and the second button (Next Player) clears all checkboxes on the sheet. However, I'd like to know if there's a way to disable the first button after it's been clicked 3 times, then re-enable it once the second button is clicked and start the count over... Please advise. I thank you for your time. We can use a Global variable to communicate between the two macros: Dim IAmTheCount As Integer Sub FirstButton() If IsEmpty(IAmTheCount) Then I...

Merging 3 sheets based on one variable
Hi, I have three sheets with 188 to 211 countries using a unique three aletter code for each country. These country codes are then followed by columns of data for different variables. I want to create one big sheet with only countries that are present in all three sheets. Is there an easy way to do this? I'm clueless about programming of any sort. Thanks, Sophal Hi have a look at http://www.cpearson.com/excel/duplicat.htm#ExtractingCommon -- Regards Frank Kabel Frankfurt, Germany Sophal wrote: > Hi, > > I have three sheets with 188 to 211 countries using a unique three >...

invitation goes to more than one person
When I send an invitation to a user(A) it goes to another user(B) also. B happens to have their account disabled so naturally postmaster sends back an undeliverable message. I can only find one thing with mention to user B in user A's settings. That is user B is listed as a "Direct Report" in the "Organization" tab. I can't edit this field directly and all I have read is that it is populated when you assign a manager. The weird thing is that the manager isn't the same as the user B in this field. Does this field have anything to do with the invitati...

i made one spreadsheet but when i try to print two sheets print,
i made a spreadsheet but every time i try to print 2 sheets print i want to cut the seond page so i could save and print one sheet Try File > Page Setup, under scaling click fit to 1 page wide by 1 pag tall Pau -- Paul Sheppar ----------------------------------------------------------------------- Paul Sheppard's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2478 View this thread: http://www.excelforum.com/showthread.php?threadid=39562 ...

Creating a form that can be dragged from any click within the 'Detail' section
Hi all, I'm trying to create a dashboard and I want the form to be moveable, however I have removed the control box and I don't want the form to have a border (hence no title row that can be used to drag the form). How do I allow a click from either a control or the detail section to enable the form to be dragged? Any help would be appreciated. Cheers, Bob Phil I agree with your suggestions to stick with the standard Window UI. But if the OP really must have this interface it is possible using the Form's MouseMove etc. events. I and others have posted code how to do this ov...

Right mouse click not working
I seem to have turned off my ability to use my right mouse click in Excel. My right mouse button works fine in all other apps (Word, Windows, etc). Any suggestions - I am lost without it. Thanks, Rita See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "Rita" <heidkampr@alyeska-pipeline.com> wrote in message news:0e8701c49c1d$cd1c5ff0$a301280a@phx.gbl... >I seem to have turned off my ability to use my right > mouse click in Excel. My right mouse button works fine > in all other apps (Word, Windows, etc). > > Any suggestions - I am l...

Address Book
Just transferred from Eudora 5.2 to Outlook 2003, so I have a string of questions on how the address book works in Outlook. Is the Address Book that can be accessed from the START button (then programs>accessories) a stand alone program, or should it be just another way of seeing the Address Book used in Outlook when its working properly? Having other problems... I'll post them as separate question Basically the address book used by outlook 2003 is called "Outlook address book" its not a physicall address book and it does not contain any data of its own and you cannot...

Radio Button Bug?
Hi, I have 6 radio buttons (control array) on a form, the user selects the option and click the OK button and there are two procedures in my code to enable and disable all controls until the process is complete. but when I disable all the radio buttons the last radio button gets automatically selected. I dont know why its happening. there is no other code for the radio buttons except in the DisableControls procedure. Private Sub DisableControls() Dim i As Integer For i = 0 To optFormat.Count - 1 optFormat(i).Enabled = False Next End Sub anyone ex...

calculating based on the U of M of another item
Hello: SOP10200.QUANTITY * IV40202.EQUOMQTY What the client needs is for the second field above (the equivalent unit of measure quantity field) to reference a unit of measure in a different item altogether. This field would, then, represent the equivalent unit of measure from the U of M Schedule. And, this schedule again is in this other item (i.e parent item) as follows: 09999 (parent item) 09999-4.5UOFM (the item that this formula calculates on--i.e. the child item) The second item’s U of M in the Schedule of the first item is “4.5UOFM”. How can I modify the formula above to refe...

One database and multiple requested totals
I have one database of people and 4 types of dates. I am trying to get a total for all records for the person, and if one date field is between x and y, give that count. and if another field is between a and b, give this count.... looking for one report that says : Total records : xx, Item A between date1 and date 2 = xx, and so on... suggestions? Thank you in advance My suggestion is to provide some table and field names, data types, sample records, and desired display in the report. -- Duane Hookom Microsoft Access MVP "Keven" wrote: > I have one database of peopl...

application unexpectedly quite
I have just installed the Mac:Office update for OS X and when I try to=20 launch the application I get the message "Application unexpectedly=20 quits." I uninstalled the suite and installed it again, but I can't get it to = work.=20 Microsoft 2001 for the Mac that I upgraded from does work, but not=20 the upgrade for OS X. It did work at one time, but not now. Any suggestions? In article <0e1501c3b358$7606b1b0$a401280a@phx.gbl>, "Robin Gudgel" <rgudgel@ballhort.com> wrote: > I have just installed the Mac:Office update for OS X and when I try to >...

Double Click To Calculate
I have a field where I sometimes need to manually enter an amount but sometimes I need it to calculate an amount based on 2 other fields. I know this is not normalized data but this is how we need to run this particular field. I would like to setup the field to allow me to manually enter data most of the time, but then calculate when I double click. The calculation would be [totalpartsCost]/0.8. I just don't know how to create the code it in the event procedure. In the double click event of the textbox, add the code: me.[yourtextboxname]= [totalpartsCost]/0.8 This assumes totalpartsc...

Recipient Policies with more than one condition #2
Hi Guys, Listen i just had a server crash and i now need to resetup the Recipient policys for the various domains, I need to make a custom filter for anyone in a spefiic security group, and if possible i also would like it to contain a attribute of 1 for the distribution groups? I had is setup before for Description and and group attribute 1? but i think the first one would be better? please let me know as i can't recall the custom script???? Thanks in advance. Greg Remer Can you post what you want to do? Members of SecurityGroup1 OR Members of DistributionGroup1?? -- Bharat Sunej...

Identities makes my drive go click, click, click
One of my Office 2001 users cannot launch an Office application=20 without her drive making a strange, recurring sequence of three clicks.=20 Entourage will not open at all, giving the user and I/O error instead.=20 Other Office apps will eventually open. In an effort to move her to Office for OS X, I've tried to copy the = Office=20 2001 Identities folder to another Mac, but it fails to copy both under=20 Mac OS 9.2.2 and Jaguar. It seems to hang on the Database file=20 particularly. If it were simply a corrupted file, I would not expect the odd drive = noise=20 (click, click, click.......

Remove contents of one list from a second list
This seems so basic, but it is eluding me still....I have a list of all registered users to our website. I have a list of all the users who logged in for an event. I want to e-mail those who did NOT attend. How can I easily subtract one list from a larger one? Hi see: http://www.cpearson.com/excel/duplicat.htm#InOneNotOther -- Regards Frank Kabel Frankfurt, Germany RicMurray wrote: > This seems so basic, but it is eluding me still....I have a list of > all registered users to our website. I have a list of all the users > who logged in for an event. I want to e-mail those who did ...

Linking errors with MFC Dialog Based application and Crypto++
Hi, For quite long now I've been trying to get the Crypto++ ([url]www.cryptopp.com[/url]) library working with a simple MFC Dialog Based application. The strange thing is that a Win32 console application links and works fine with the same settings :-| Here are the errors I'm getting: > > --------------------Configuration: dialog - Win32 > Debug-------------------- > Linking... > LINK : warning LNK4049: locally defined symbol ""public: __thiscall > std::ios_base::Init::Init(void)" (??0Init@ios_base@std@@QAE@XZ)" > imported > LINK : warni...

Why does one have to click on the cmd button twice
PPT 2003 on Vista .. I have two CMD buttons that I click on one to display new numbers and the second to show the correct answer. I have to click on the second buttoon twice. I don't why becasue on slides from previous files it takes one click to display the data. I tried to match the properties thinking it is a focus issue, but all the properties seem to be the same. I can post the code if it is important. Thanks ... Phil Yes, the code you are using will be helpful. Also, check to see if there is an entrance animation added to the shape you show for the correct ans...

2 statements for one if
I need to join two statements in an if and check if they are both tru to continue (this is in a cell, not VBA) =IF(COUNT(F9)=1 & COUNT(BK9)=1,"A","B") I know i can do this: =IF(COUNT(F9)=1,IF(COUNT(BK9)=1,"A","B"),"B") But that doesnt apply here because I have to do this many times in cell, and I will reach my limit on number of embedded if -- Message posted from http://www.ExcelForum.com I found it::: Sorry I posted before exhausting my search of help... =IF(AND(COUNT(F9)=1,COUNT(BK9)=1),"A","B") Thanks though!! ...

crm 4.0 application exams
I took the CRM 4.0 Applications exams today, but I failed. I didn't expected it to be tricky. Anyone passed this exam? On Jun 3, 11:19=A0am, "Benjamin Fallar III" <bfall...@hotmail.com> wrote: > I took the CRM 4.0 Applications exams today, but I failed. I didn't expect= ed > it to be tricky. Anyone passed this exam? General consensus on the web is it is very difficult and experienced consultants who have worked with CRM for years are getting tripped up by it and the other two new CRM exams. My recommendation is wait for the braindumps. Leon Tribe I'm a...

Owner-draw checkbox and Double-click
Hello, I have an owner drawn checkbox (see my post "Checkboxes: SetCheck() and BS_OWNERDRAW", 8/18/2003). It works great whether the user clicks on it or hits the space bar when it has the focus. However, when the user double-clicks the checkbox and tabs to another control, a heavy black rectangle is left behind. I noticed that this related to my usage of DrawFocusRect() in my DrawItem() function, but I cannot figure out how to properly address the problem. DrawFocusRect is called in two different places in DrawItem(): if( lpDrawItemStruct->itemAction == ODA_DRAWENTIRE ) { ...