Make Process w/ Window get Set Focus.

Just starting out? Need help? Post your questions and find answers here.
armixeight
New User
New User
Posts: 9
Joined: Sun Sep 13, 2009 4:34 am

Make Process w/ Window get Set Focus.

Post by armixeight »

I wanted to ask a question on how to make a window get focus via it system process name.

Theory:
#1 FilePath_Name.s gets set from a read of an INI file

#2 The first segment of the loop starts reading all windows that are open and gives them to Temp.s

Code: Select all

Temp.s=WindowsEnum()
  If Temp=""
    Break
  EndIf
#3 Then AutoFocusRead.s gets a result and AutoFocusResult.l is set by how many times FilePath_Name.s is found in AutoFocus Read.s

Code: Select all

AutoFocusRead.s   = Temp+" "+HandleToFileName(GetHandle(Temp))
AutoFocusResult.l = CountString(AutoFocusRead.s, FilePath_Name.s)
#4 If AutoFocusResult is 1 or higher, then it breaks the loop and sets temp = HandleOn.s

Code: Select all

If AutoFocusresult = >1 or 1
  Temp = HandleOn.s
  Break
EndIf
Please note that I used user library: Droopy Library v1.30.9

#5 Set the Foreground Window to the name of the window HandleOn.s

Code: Select all

ForegroundWindowSet(HandleOn.s)
This is the complete code:

Code: Select all


FilePath_Name.s = IniRead("C:\File.ini","FilePath","Name")

Repeat
    Temp.s=WindowsEnum()
    If Temp=""
      Break
    EndIf
    AutoFocusRead.s   = Temp+" "+HandleToFileName(GetHandle(Temp))
    AutoFocusResult.l = CountString(AutoFocusRead.s, FilePath_Name.s)
    If AutoFocusresult = >1 or 1
      Temp = HandleOn.s
      Break
    EndIf
  ForEver

ForegroundWindowSet(HandleOn.s)

Please could you see if this works.

Big thanks to anyone that does.