Jump to content

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:

http://www.autoitscript.com/autoit3/docs/functions/AutoItSetOption.htm

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:
;http://www.autoitscript.com/autoit3/docs/functions/AutoItSetOption.htm
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!")
    Exit
EndIf

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
WinWaitActive($launcherName)
MouseMove ( 900, 600)
MouseClick ( "left")

WinWaitActive($gameExeName)
WinActivate($gameExeName)
MouseMove ( 900, 600)
MouseClick ( "left")

; Finished!

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

Thanks in advance!

Link to comment
Share on other sites

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

Fl4m3Ph03n1x,

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. :)

M23

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:

Spoiler

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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...