Jump to content
Sign in to follow this  
meatwad420

Basic RegExp Help

Recommended Posts

meatwad420

I'm wanting to move and resize only windows with "username" in the title. I'm a bit lost on what the best way to accomplish this. I assume RegExp would be the easiest but I can't figure out how to use it. An example would help me greatly.

Here is some code that sorts only windows I have open into an array and counts the number of windows.

What do I need to add to select only windows with a certain text?

$TableList = WinList()
$j = 0
For $i = 1 to $TableList[0][0]
  If $TableList[$i][0] <> "" AND $TableList[$i][0] <> "Program Manager" AND IsVisible($TableList[$i][1]) Then
    $Table[$j] = $TableList[$i][0]
    $j = $j + 1
    $ActiveTables = $j
  EndIf
Next

Thanks

Share this post


Link to post
Share on other sites
BrettF

Hello and welcome to the forums.

From the example you provided, I don't believe you need RegExp. Will this do?

#include <Array.au3>

$sub = "d"; String to find in title.
Dim $output[1][2] 
; Return array in following format.
; [n][0] = Title
; [n][1] = HWND

$count = 1

$titles = WinList()
For $i = 1 To $titles[0][0]
    If $titles[$i][0] <> "" AND BitAND(WinGetState($titles[$i][1]), 2) Then; Windows with a title and that are visible
        If StringInStr($titles[$i][0], $sub) Then; Make sure 
            ReDim $output[$count + 1][2]
            $output[$count][0] = $titles[$i][0]; Title
            $output[$count][1] = $titles[$i][1]; HWND
            $count += 1; Increase Count
        EndIf
    EndIf
Next
$output[0][0] = $count - 1; Set [0][0] to be the number of windows found.
_ArrayDisplay ($output); Show the data

Cheers,

Brett

Share this post


Link to post
Share on other sites
meatwad420

Thanks for the help.

Share this post


Link to post
Share on other sites
PsaltyDS

I'm wanting to move and resize only windows with "username" in the title. I'm a bit lost on what the best way to accomplish this. I assume RegExp would be the easiest but I can't figure out how to use it. An example would help me greatly.

Here is some code that sorts only windows I have open into an array and counts the number of windows.

What do I need to add to select only windows with a certain text?

$TableList = WinList()
$j = 0
For $i = 1 to $TableList[0][0]
  If $TableList[$i][0] <> "" AND $TableList[$i][0] <> "Program Manager" AND IsVisible($TableList[$i][1]) Then
    $Table[$j] = $TableList[$i][0]
    $j = $j + 1
    $ActiveTables = $j
  EndIf
Next

Thanks

All you need is:
Opt("WinTitleMatchMode", -2); -2 = Any string match, case insensitive
$TableList = WinList("username")

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
BrettF

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×