0

I'm trying to write a piece of code to minimize an application based on the text displaying in the title bar (any application running on the system, not just my own). I've been able to perform the task in an AHK but the desired result isn't ideal and I'd definitely rather it be an active piece of my application then an external one. The AHK is:

#Persistent
#SingleInstance

SetTimer, NoCashierOrHEM, 300
return

NoCashierOrHEM:
IfWinExist , Cashier
WinClose , Cashier
IfWinExist , Hold’em + Omaha Manager
WinMinimize , Hold’em + Omaha Manager
return

Which will minimize any window that has the title bar "Hold'em + Omaha Manager" and close any window that has the title "Cashier". What direction should I be looking in for solving this problem in C#?

Michael A
  • 9,480
  • 22
  • 70
  • 114
  • Have you seen [this](http://stackoverflow.com/questions/785054/minimizing-all-open-windows-in-c) question? – Nils Magne Lunde Apr 12 '11 at 06:11
  • I have but I didn't think it was in line with what I was asking (since I want to specify the window title and not minimize everything across the board). Could you help me to understand (or point me in the right direction) how I would modify this to suit this purpose? – Michael A Apr 12 '11 at 09:09

1 Answers1

1

You will need to use a combination of Windows API functions, like

GetClassName
GetWindowsText
GetWindow

and write a method that goes through open forms and searches for the text.

An example in vb6 can be found here. I believe that code should be fairly easy to convert to c#.

Nils Magne Lunde
  • 1,794
  • 1
  • 13
  • 21