Jump to content
Sign in to follow this  

Ways to focus windows

Recommended Posts

Hey guys, I have another newb question. So far, the only way I know of focusing a window is by using it's title. So if I have a window named "ABC" and then I want to focus a window called "AB" I have a problem, becayse substring "AB" is contained within "ABC".

To fix this I tried using the command:

Opt("WinTitleMatchMode", 3)

API for this command can be seen here:


However, I still get the same problem. If I focus "ABC" first, I can't focus "AB" after.

Here is my script so far:

; AutoIt Version: 1.0
; Language:    English
; Platform:    Windows 7
; Author:        Fl4m3Ph03n1x
; Script Function:
;   Opens MTGT, goes to the Auctions house and then loops infinetly to get it's data.

;Alters the method used to search window titles. For more info see also:
Opt("WinTitleMatchMode", 3)

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
Local $answer = MsgBox(4, "MTGT looper", "This script will run MTGT and then, go to the Auctions House and then run an infinite loop actualizing the trades.dat file.  Run?")

; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "AutoIt", "OK.  Bye!")

Local $launcherName = "Magic The Gathering Tactics"
Local $gameExeName = "Magic Tactics"

; Run Launcher
ShellExecute("C:\Users\Public\Sony Online Entertainment\Installed Games\Magic The Gathering Tactics\LaunchPad.exe")

; Wait for the Firefox become active
MouseMove ( 900, 600)
MouseClick ( "left")

MouseMove ( 900, 600)
MouseClick ( "left")

; Finished!

What am I doing wrong? Why can't I focus $gameExeName?

Thanks in advance!

Share this post

Link to post
Share on other sites

My UDFs and Tutorials:


Active Directory (NEW 2020-10-10 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

ADO - Wiki, WebDriver - Wiki


Share this post

Link to post
Share on other sites


The last time I looked, "Magic The Gathering Tactics" is a game. If you read the Forum Rules you will see we do not help automate games - so this thread will now be locked. ;)

Please read those rules and follow them when you post in future. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...