Jump to content

[Help]Can't change window title using autoit script!


aphex
 Share

Recommended Posts

Hi guys,i'm not a programmer and i would like to modify an autoit script,any help?

The script

#include <Date.au3> 
;защита от запуска двух копий 
If WinExists(@ScriptName) Then Exit 
AutoItWinSetTitle(@ScriptName)
$my_title = "DT Loader v.0.4 (29.12.2009) for DAEMON Tools Pro"
$MsgBox1 = "Unable to locate the file 'DTImgEditor.exe'."
$MsgBox2 = "DAEMON Tools Pro Image Editor is already running!"
; если ini файла нет, создаём его
If Not FileExists(@ScriptDir & "\dt_loader.ini") Then
$first_time = _NowCalc() ; в формате: ГГГГ/ММ/ДД ЧЧ:ММ:СС
$inifile = FileOpen (@ScriptDir & "\dt_loader.ini", 32+2); режим Unicode UTF16 и запись с удалением имеющегося
; пишем в ини файл текущие дату и время 
FileWrite ($inifile, "[time]"&@CRLF&"installtime="&$first_time)
FileClose ($inifile)
EndIf
$ini_time = IniRead (@ScriptDir & "\dt_loader.ini", "time", "installtime", "" )
; проверяем где мы находимся. 
If Not FileExists(@ScriptDir & "\DTImgEditor.exe") Then 
MsgBox(16, $my_title, $MsgBox1&@CRLF&"Please copy 'DTImgEditor Loader.exe' to your DAEMON Tools Pro installation directory.") 
Exit 
EndIf
If ProcessExists ("DTImgEditor.exe") Then 
MsgBox( 64, $my_title, $MsgBox2) 
Exit 
EndIf

; добавляем к времени из ини файла +10 минут 
$New_time_string = _DateAdd ( 'n', 10, $ini_time)
;разбиваем на части... 
$new_year = StringMid($New_time_string, 1, 4); выделяем Год. 
$new_month = StringMid($New_time_string, 6, 2); выделяем Месяц. 
$new_day = StringMid($New_time_string, 9, 2); выделяем День 
$new_hour = StringMid($New_time_string, 12, 2); выделяем Час 
$new_minute = StringMid($New_time_string, 15, 2); выделяем Минуту 
$new_second = StringMid($New_time_string, 18, 2); выделяем Секунду 

; фиксируем текущие системные время и дату 
$current_time = _NowCalc() ; в формате: ГГГГ/ММ/ДД ЧЧ:ММ:СС 
$timer_begin = TimerInit() ; врубаем таймер 
; меняем системную дату на дату из ини файла +10 минут 
;--------------важно ---------- 
_SetDate($new_day,$new_month,$new_year)
_SetTime($new_hour, $new_minute, $new_second); время
;--------------важно ---------- 
; запускаем демона 
Run (@ScriptDir & "\DTImgEditor.exe") 
Sleep(100)

WinWait("DAEMON Tools Pro Image Editor", "", 20)
If WinExists("DAEMON Tools Pro Image Editor", "") Then
_timeback()
WinSetTitle ("DAEMON Tools Pro Image Editor", "", "DAEMON Tools Pro Image Editor 123")
Else
_timeback()
EndIf 
 
;---------- Функция возврата времени ------------- 
Func _timeback() 
$timer_end = Ceiling (TimerDiff ($timer_begin)); читаем сколько натикало в таймере и сразу же округляем 
$timer_end /= 1000 ; переводим из милисекунд в секунды 
Global $timer_end_s = Ceiling ($timer_end); опять округляем 
Global $new_current_time = _DateAdd ( 's', $timer_end_s, $current_time); формируется новая текущая дата: ГГГГ/ММ/ДД ЧЧ:ММ:СС 
; разбиваем полученную строку на переменные... 
$year = StringMid( $new_current_time, 1, 4); выделяем Год. 
$month = StringMid( $new_current_time, 6, 2); выделяем Месяц. 
$day = StringMid( $new_current_time, 9, 2); выделяем День 
$hour = StringMid( $new_current_time, 12, 2); выделяем Час 
$minute = StringMid( $new_current_time, 15, 2); выделяем Минуту 
$second = StringMid( $new_current_time, 18, 2); выделяем Секунду 
_SetDate($day, $month, $year); дата 
_SetTime($hour, $minute, $second); время 
EndFunc 
;---------- Функция возврата времени -------------

The script is launching 'DTImgEditor.exe' but the window title is not changed.

Posted Image

Edited by aphex
Link to comment
Share on other sites

there's a cool tool called [AutoIt Window Info] "C:\Program Files\AutoIt3\Au3Info.exe"

And try this

Opt("WinTitleMatchMode", 1)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Now try this and see if it works.

Opt("WinTitleMatchMode", 4)
;
$title='DAEMON Tools Pro Image Editor'
;
WinWait($title, "", 20)
If WinExists($title, "") Then
    MsgBox(0, '', 'WinExists')
    WinSetTitle($title, "", "DAEMON New Title")
Else
    MsgBox(0, '', 'WinNotExists')
EndIf

Best Regards.

.

Edited by DCCD
Link to comment
Share on other sites

there's a cool tool called [AutoIt Window Info] "C:\Program Files\AutoIt3\Au3Info.exe"

And try this

Opt("WinTitleMatchMode", 1)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Best Regards.

.

Window info screen

Posted Image

Can't do it,i'm using the same script with another executable and the title is succesfully changed.

But no luck with this one.

This could be the problem?

DAEMON Tools Pro Image Editor - NewImage [Trial period: 17 day(s) left]

NewImage is a dynamic text,is changed with the name of the img file.

sorry for my bad english. Edited by aphex
Link to comment
Share on other sites

is this a question?, do you know what you're doing!?

not really,i just want to know how to solve this problem.

I told you,i'm using the same script with another executable and everything is fine.

This executable 'DT Pro image Editor' has a dynamic title,i think this is the problem.

Link to comment
Share on other sites

I don't know what to say, Good luck anyway!

#include <Date.au3>
;
Opt("WinTitleMatchMode", 4)
;
;защита от запуска двух копий 
If WinExists(@ScriptName) Then Exit 
AutoItWinSetTitle(@ScriptName)
$my_title = "DT Loader v.0.4 (29.12.2009) for DAEMON Tools Pro"
$MsgBox1 = "Unable to locate the file 'DTImgEditor.exe'."
$MsgBox2 = "DAEMON Tools Pro Image Editor is already running!"
; если ini файла нет, создаём его
If Not FileExists(@ScriptDir & "\dt_loader.ini") Then
$first_time = _NowCalc() ; в формате: ГГГГ/ММ/ДД ЧЧ:ММ:СС
$inifile = FileOpen (@ScriptDir & "\dt_loader.ini", 32+2); режим Unicode UTF16 и запись с удалением имеющегося
; пишем в ини файл текущие дату и время 
FileWrite ($inifile, "[time]"&@CRLF&"installtime="&$first_time)
FileClose ($inifile)
EndIf
$ini_time = IniRead (@ScriptDir & "\dt_loader.ini", "time", "installtime", "" )
; проверяем где мы находимся. 
If Not FileExists(@ScriptDir & "\DTImgEditor.exe") Then 
MsgBox(16, $my_title, $MsgBox1&@CRLF&"Please copy 'DTImgEditor Loader.exe' to your DAEMON Tools Pro installation directory.") 
Exit 
EndIf
If ProcessExists ("DTImgEditor.exe") Then 
MsgBox( 64, $my_title, $MsgBox2) 
Exit 
EndIf

; добавляем к времени из ини файла +10 минут 
$New_time_string = _DateAdd ( 'n', 10, $ini_time)
;разбиваем на части... 
$new_year = StringMid($New_time_string, 1, 4); выделяем Год. 
$new_month = StringMid($New_time_string, 6, 2); выделяем Месяц. 
$new_day = StringMid($New_time_string, 9, 2); выделяем День 
$new_hour = StringMid($New_time_string, 12, 2); выделяем Час 
$new_minute = StringMid($New_time_string, 15, 2); выделяем Минуту 
$new_second = StringMid($New_time_string, 18, 2); выделяем Секунду 

; фиксируем текущие системные время и дату 
$current_time = _NowCalc() ; в формате: ГГГГ/ММ/ДД ЧЧ:ММ:СС 
$timer_begin = TimerInit() ; врубаем таймер 
; меняем системную дату на дату из ини файла +10 минут 
;--------------важно ---------- 
_SetDate($new_day,$new_month,$new_year)
_SetTime($new_hour, $new_minute, $new_second); время
;--------------важно ---------- 
; запускаем демона 
Run (@ScriptDir & "\DTImgEditor.exe") 
Sleep(100)

WinWait("DAEMON Tools Pro Image Editor", "", 20)
If WinExists("DAEMON Tools Pro Image Editor", "") Then
_timeback()
WinSetTitle ("DAEMON Tools Pro Image Editor", "", "DAEMON Tools Pro Image Editor 123")
Else
_timeback()
EndIf 
 
;---------- Функция возврата времени ------------- 
Func _timeback() 
$timer_end = Ceiling (TimerDiff ($timer_begin)); читаем сколько натикало в таймере и сразу же округляем 
$timer_end /= 1000 ; переводим из милисекунд в секунды 
Global $timer_end_s = Ceiling ($timer_end); опять округляем 
Global $new_current_time = _DateAdd ( 's', $timer_end_s, $current_time); формируется новая текущая дата: ГГГГ/ММ/ДД ЧЧ:ММ:СС 
; разбиваем полученную строку на переменные... 
$year = StringMid( $new_current_time, 1, 4); выделяем Год. 
$month = StringMid( $new_current_time, 6, 2); выделяем Месяц. 
$day = StringMid( $new_current_time, 9, 2); выделяем День 
$hour = StringMid( $new_current_time, 12, 2); выделяем Час 
$minute = StringMid( $new_current_time, 15, 2); выделяем Минуту 
$second = StringMid( $new_current_time, 18, 2); выделяем Секунду 
_SetDate($day, $month, $year); дата 
_SetTime($hour, $minute, $second); время 
EndFunc 
;---------- Функция возврата времени -------------
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...