Magikarp7

How do I detect a new IE instance with the same title and class? I'm new on Autoit. Please help me.

9 posts in this topic

I am currently working on a program for work that when you open a specific page, a timer starts and records your progress. Its just that I was prompted to make the program able to track/detect multiple instances of same processes.

For example the window class is "MozillaWindowClass"(i use IE of course. This is just for example.) and the Title is "Create New Topic". I need to detect a new instance with the same title and class!

I can see on the autoit window info a different handle. how do I track them? I need help. Anyone please. I'm going crazy. when I try to tweek the code the 2nd timer starts at the same time as the first timer. im gonna go crazy!

Share this post


Link to post
Share on other sites



You already mention a different handle, so use that.

you can grab a list of all windows with the same class, then get the handle and go from there.

What have you done so far?


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites
2 minutes ago, careca said:

You already mention a different handle, so use that.

you can grab a list of all windows with the same class, then get the handle and go from there.

What have you done so far?

Thank you for the reply! Unfortunately I could not post the code since It's saved in my office PC. Do you have any ideas how I could call the handle? I use WinGetHandle but it only prompts me to give the "title" and "text". can you give me general ideas? Im sorry Im still new to this language.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes, it prompts for title, but you can put the class.

WinGetHandle("[CLASS:Notepad]")

text is optional

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites
6 minutes ago, careca said:

Yes, it prompts for title, but you can put the class.

WinGetHandle("[CLASS:Notepad]")

text is optional

I'm getting the idea now! the problem is that the Window info generates a unique handle for each open browser. Do you have any idea how i can call those new instances? its making my head spin. calling only one instance is easy since I only have to call it by title and class. but another one just hurts my head.

Share this post


Link to post
Share on other sites

Let me try to understand what you're trying to do.

So the program detects a window with a certain title, and starts a timer

you open another window, same title, different handle, it starts another timer, and keeps the first one running

when one window closes, outputs the time the window was open.

Is it close?

 


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites
40 minutes ago, careca said:

Let me try to understand what you're trying to do.

So the program detects a window with a certain title, and starts a timer

you open another window, same title, different handle, it starts another timer, and keeps the first one running

when one window closes, outputs the time the window was open.

Is it close?

 

yess! that's what i'm trying to do! basically for example I am making a presentation on one IE instance.

I plan to make another one on a separate IE instance to make my work faster. And my program needs to track the progress of that "new" IE window I open. The current program only tracks one work at a time so it's a hassle. I want to be able to do 2 or 3 at a time. but i need to know how to detect the newly opened windows. :(

Share this post


Link to post
Share on other sites
;#RequireAdmin ;No console
#Region ;Wrapper
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Run_Debug_Mode=n
;#AutoIt3Wrapper_Icon=
;#pragma compile(CompanyName, '')
;#pragma compile(ProductVersion, )
;#pragma compile(FileVersion, )
#pragma compile(x64, false)
;#AutoIt3Wrapper_Res_Comment=
;#AutoIt3Wrapper_Res_Icon_Add=
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#EndRegion ;Wrapper
;======================================================================================
#include <Misc.au3>
#include <Timers.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
;=============================================================================
Opt("MustDeclareVars", 1)
Opt("TrayIconDebug", 1)
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUIOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("MouseCoordMode", 2)
;=============================================================================
Local $Winlist, $IniRead, $ExitItem
;=============================================================================
$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")
AdlibRegister('time', 1000)
;=============================================================================
While 1
    If WinExists("[CLASS:MozillaWindowClass]") Then
        $Winlist = WinList("[CLASS:MozillaWindowClass]")
        For $t = 1 To $Winlist[0][0]
            If StringInStr($Winlist[$t][0], 'Mozilla Firefox') <> 0 Then
                If FileExists(@ScriptDir & '\temp.ini') Then
                    $IniRead = IniReadSection(@ScriptDir & '\temp.ini', 'Windows')
                    If Not @error Then
                        If $IniRead[0][0] <> 0 Then
                            For $w = 1 To $IniRead[0][0]
                                If $IniRead[$w][1] = $Winlist[$t][1] Then
                                    ConsoleWrite(' - ' & @MSEC & @CRLF)
                                Else
                                    IniWrite(@ScriptDir & '\temp.ini', 'Windows', $Winlist[$t][1], $Winlist[$t][0])
                                EndIf
                            Next
                        EndIf
                    Else
                        IniWrite(@ScriptDir & '\temp.ini', 'Windows', $Winlist[$t][1], $Winlist[$t][0])
                    EndIf
                Else
                    IniWrite(@ScriptDir & '\temp.ini', 'Windows', $Winlist[$t][1], $Winlist[$t][0])
                EndIf
            EndIf
        Next
    EndIf
    Sleep(400)
WEnd
;=============================================================================
Func Time() ;WIP
    If FileExists(@ScriptDir & '\temp.ini') Then
        $IniRead = IniReadSection(@ScriptDir & '\temp.ini', 'Windows')
        If Not @error Then
            If $IniRead[0][0] <> 0 Then
                For $w = 1 To $IniRead[0][0]
                    ;$IniRead[$w][0]
                Next
            EndIf
        EndIf
    EndIf
EndFunc   ;==>Time
;======================================================================================
Func Quit()
    FileDelete(@ScriptDir & '\temp.ini')
    Exit
EndFunc   ;==>Quit
;======================================================================================

A work in progress, detects new windows, but doesn't have any timer yet.

1 person likes this

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites
48 minutes ago, careca said:
;#RequireAdmin ;No console
#Region ;Wrapper
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Run_Debug_Mode=n
;#AutoIt3Wrapper_Icon=
;#pragma compile(CompanyName, '')
;#pragma compile(ProductVersion, )
;#pragma compile(FileVersion, )
#pragma compile(x64, false)
;#AutoIt3Wrapper_Res_Comment=
;#AutoIt3Wrapper_Res_Icon_Add=
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#EndRegion ;Wrapper
;======================================================================================
#include <Misc.au3>
#include <Timers.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
;=============================================================================
Opt("MustDeclareVars", 1)
Opt("TrayIconDebug", 1)
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUIOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("MouseCoordMode", 2)
;=============================================================================
Local $Winlist, $IniRead, $ExitItem
;=============================================================================
$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")
AdlibRegister('time', 1000)
;=============================================================================
While 1
    If WinExists("[CLASS:MozillaWindowClass]") Then
        $Winlist = WinList("[CLASS:MozillaWindowClass]")
        For $t = 1 To $Winlist[0][0]
            If StringInStr($Winlist[$t][0], 'Mozilla Firefox') <> 0 Then
                If FileExists(@ScriptDir & '\temp.ini') Then
                    $IniRead = IniReadSection(@ScriptDir & '\temp.ini', 'Windows')
                    If Not @error Then
                        If $IniRead[0][0] <> 0 Then
                            For $w = 1 To $IniRead[0][0]
                                If $IniRead[$w][1] = $Winlist[$t][1] Then
                                    ConsoleWrite(' - ' & @MSEC & @CRLF)
                                Else
                                    IniWrite(@ScriptDir & '\temp.ini', 'Windows', $Winlist[$t][1], $Winlist[$t][0])
                                EndIf
                            Next
                        EndIf
                    Else
                        IniWrite(@ScriptDir & '\temp.ini', 'Windows', $Winlist[$t][1], $Winlist[$t][0])
                    EndIf
                Else
                    IniWrite(@ScriptDir & '\temp.ini', 'Windows', $Winlist[$t][1], $Winlist[$t][0])
                EndIf
            EndIf
        Next
    EndIf
    Sleep(400)
WEnd
;=============================================================================
Func Time() ;WIP
    If FileExists(@ScriptDir & '\temp.ini') Then
        $IniRead = IniReadSection(@ScriptDir & '\temp.ini', 'Windows')
        If Not @error Then
            If $IniRead[0][0] <> 0 Then
                For $w = 1 To $IniRead[0][0]
                    ;$IniRead[$w][0]
                Next
            EndIf
        EndIf
    EndIf
EndFunc   ;==>Time
;======================================================================================
Func Quit()
    FileDelete(@ScriptDir & '\temp.ini')
    Exit
EndFunc   ;==>Quit
;======================================================================================

A work in progress, detects new windows, but doesn't have any timer yet.

Thanks so much! you've been a big help!

Share this post


Link to post
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