Jump to content

WinActivate same title?


Recommended Posts

Hey guys. I have problem with my script.

It's code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <Array.au3>
HotKeySet("{TAB}","_ChangeWindows")
Global $Files, $i, $File = 0
#Region ### START Koda GUI section ### Form=D:\Moje - informatyka\AutoIT\AutoSwitchForm.kxf
$Form1 = GUICreate("AutoSwitch", 279, 288, 239, 157)
$Group1 = GUICtrlCreateGroup("Auto Switch", 8, 0, 265, 281)
$Label1 = GUICtrlCreateLabel("First File", 24, 24, 81, 17)
$Label2 = GUICtrlCreateLabel("Second File", 24, 56, 68, 17)
$Label3 = GUICtrlCreateLabel("Third File", 24, 88, 74, 17)
$Label4 = GUICtrlCreateLabel("Fourth File", 24, 120, 77, 17)
$Label5 = GUICtrlCreateLabel("Fifth File", 24, 152, 63, 17)
$Label6 = GUICtrlCreateLabel("Sixth File", 24, 184, 71, 17)
$Label7 = GUICtrlCreateLabel("Seventh File", 24, 216, 74, 17)
$Input1 = GUICtrlCreateInput("", 144, 24, 121, 21)
$Input2 = GUICtrlCreateInput("", 144, 56, 121, 21)
$Input3 = GUICtrlCreateInput("", 144, 88, 121, 21)
$Input4 = GUICtrlCreateInput("", 144, 120, 121, 21)
$Input5 = GUICtrlCreateInput("", 144, 152, 121, 21)
$Input6 = GUICtrlCreateInput("", 144, 184, 121, 21)
$Input7 = GUICtrlCreateInput("", 144, 216, 121, 21)
$Button1 = GUICtrlCreateButton("Save", 25, 248, 231, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetData($Input1, IniRead("config.ini","Files","First",'0'))
GUICtrlSetData($Input2, IniRead("config.ini","Files","Second",'0'))
GUICtrlSetData($Input3, IniRead("config.ini","Files","Third",'0'))
GUICtrlSetData($Input4, IniRead("config.ini","Files","Fourth",'0'))
GUICtrlSetData($Input5, IniRead("config.ini","Files","Piąta",'0'))
GUICtrlSetData($Input6, IniRead("config.ini","Files","Sixth",'0'))
GUICtrlSetData($Input7, IniRead("config.ini","Files","Seventh",'0'))
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _Save()

    EndSwitch
WEnd

Func _ChangeWindows()
    Local $Files[7] = [GUICtrlRead($Input1), GUICtrlRead($Input2), GUICtrlRead($Input3), GUICtrlRead($Input4), GUICtrlRead($Input5), GUICtrlRead($Input6), GUICtrlRead($Input7)]
    if $Files[$File] = "" then
        $File = 0
        WinActivate($Files[0])
    else
        WinActivate($Files[$File])
        $File = $File + 1
    endif
    tooltip("File: "&$File,0,0)
EndFunc

Func _Save()
    IniWrite("config.ini", "Files", "First", GUICtrlRead($Input1))
    IniWrite("config.ini", "Files", "Second", GUICtrlRead($Input2))
    IniWrite("config.ini", "Files", "Third", GUICtrlRead($Input3))
    IniWrite("config.ini", "Files", "Fourth", GUICtrlRead($Input4))
    IniWrite("config.ini", "Files", "Piąta", GUICtrlRead($Input5))
    IniWrite("config.ini", "Files", "Sixth", GUICtrlRead($Input6))
    IniWrite("config.ini", "Files", "Seventh", GUICtrlRead($Input7))
    GUICtrlSetData($Button1,"Saved")
    sleep(800)
    GUICtrlSetData($Button1,"Save") 
EndFunc

And made 2 files for example note and save as:

first file - test

second file - testing

run script and write on input 1 and 2 this name of file. open this note and click tab.. Always note with "testing" are open... But if you change name first, all works.. Why that function not work with program title which are similar?

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