Jump to content

Someone want to make a function?


Achilles
 Share

Recommended Posts

To be more specific, it arrays all the open windows of one type. So lets say for notepad.exe you had 5 windows open. Each one called something different. I would like it to array them... I would do this but for one I'm not sure if it's possible and for two I only ever written one function that had more then one parameter...

I'm using this for a MSN autoreply (which isn't really useful thanks to windows live messenger but I like version 7.5 more so I'm still trying to make it) and obviously if more then one person tries to contact you it will need to know both title names...

I attached what I have so far... it works for one name... (note to those who try using it, remember that when a person contacts you for the first time the window isn't set ontop, that complicates things slightly)

Any help greatly appreciated,

Piano_Man

MSN_away.au3

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

  • Moderators

To be more specific, it arrays all the open windows of one type. So lets say for notepad.exe you had 5 windows open. Each one called something different. I would like it to array them... I would do this but for one I'm not sure if it's possible and for two I only ever written one function that had more then one parameter...

I'm using this for a MSN autoreply (which isn't really useful thanks to windows live messenger but I like version 7.5 more so I'm still trying to make it) and obviously if more then one person tries to contact you it will need to know both title names...

I attached what I have so far... it works for one name... (note to those who try using it, remember that when a person contacts you for the first time the window isn't set ontop, that complicates things slightly)

Any help greatly appreciated,

Piano_Man

I helped vicks with something similar yesterday.

Edit:

http://www.autoitscript.com/forum/index.ph...st&p=230366

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I helped vicks with something similar yesterday.

Edit:

http://www.autoitscript.com/forum/index.ph...st&p=230366

I assume that this:

#include <Date.au3>
Global $window = IniReadSection('Friends list.ini', 'Friends')
While 1
    For $iCC = 1 To $window[0][0]
        If WinExists($window[$iCC][1]) Then
            WinActivate($window[$iCC][1])
            Sleep(500)
            _sendit($window[$iCC][1])
            ;_exit()
        EndIf
    Next
    Sleep(100)
WEnd

was what you were talking about (if I'm wrong please say so)... and after looking through Vicks script it looks like you would have to enter all you friends names in (and since that changes all the time that would be very inconvenient). I just need to know if there is a way to list the open windows (and what the function name is if it exists)...

@Smoke_N: please let me know if I didn't understand your script right, I'm still kind of new at this so I might have missed something (and when does the third Spiderman come out? I think that everytime I see your picture)

@Everone: Any help appreciated

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

  • Moderators

Yay, that looks like exactly what I wanted... It also explains why I didn't fully understand your help before... thanks for that

Piano_man

See if this helps... only took a few mins so thought it might help you:
$aArray = _ReturnExeWins('msnmsgr.exe')
If IsArray($aArray) Then
    For $iCC = 1 To $aArray[0]
        MsgBox(64, 'Info:', 'Window Name: ' & $aArray[$iCC])
    Next
EndIf

Func _ReturnExeWins($hExe)
    Local $aPList = ProcessList(), $aWList = WinList(), $sHold
    For $iCC = 1 To $aPList[0][0]
        If $aPList[$iCC][0] = $hExe Then
            For $xCC = 1 To $aWList[0][0]
                If WinGetProcess($aWList[$xCC][1]) = $aPList[$iCC][1] And _
                    BitAND(WinGetState($aWList[$xCC][1]), 2) And _
                    $aWList[$xCC][0] <> '' Then
                    $sHold &= $aWList[$xCC][0] & Chr(01)
                EndIf
            Next
        EndIf
    Next
    If $sHold Then
        Return StringSplit(StringTrimRight($sHold, 1), Chr(01))
    EndIf
    Return ''
EndFunc
It returns the windows that are visible and have an actual title based on it's executable.

Edit: Noticed I had the wrong delimeter for the stringsplit.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

See if this helps... only took a few mins so thought it might help you:

$aArray = _ReturnExeWins('msnmsgr.exe')
If IsArray($aArray) Then
    For $iCC = 1 To $aArray[0]
        MsgBox(64, 'Info:', 'Window Name: ' & $aArray[$iCC])
    Next
EndIf

Func _ReturnExeWins($hExe)
    Local $aPList = ProcessList(), $aWList = WinList(), $sHold
    For $iCC = 1 To $aPList[0][0]
        If $aPList[$iCC][0] = $hExe Then
            For $xCC = 1 To $aWList[0][0]
                If WinGetProcess($aWList[$xCC][1]) = $aPList[$iCC][1] And _
                    BitAND(WinGetState($aWList[$xCC][1]), 2) And _
                    $aWList[$xCC][0] <> '' Then
                    $sHold &= $aWList[$xCC][0] & Chr(01)
                EndIf
            Next
        EndIf
    Next
    If $sHold Then
        Return StringSplit(StringTrimRight($sHold, 1), @LF)
    EndIf
    Return ''
EndFunc
It returns the windows that are visible and have an actual title based on it's executable.
Thanks a lot... that was exactly what I was looking for... I think I even understand how it works mostly... I'll probably use that in other programs too

Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

  • Moderators

Thanks a lot... that was exactly what I was looking for... I think I even understand how it works mostly... I'll probably use that in other programs too

Piano_Man

You may want to check the edit I made, I had the wrong delimeter for string split.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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