Hey every one
Please help .. i cannot make this script to work ... what it should do is to detect a log off and then save the title of the open windows in a text file, and then when the user logs in again it reads the txt file and restores the windows.
the first part of the script ( detecting the log off and writing the file ) is working fine
the second part of the script ( reading the txt file and running the programs ) are working fine
But i cannot get them combined to work ( in one file )
Please any suggestions ?
Code:
#SingleInstance, Force
#NoEnv
DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x4FF, UInt, 0)
OnMessage(0x11, "WM_QUERYENDSESSION")
return
WM_QUERYENDSESSION(wParam, lParam)
{
ENDSESSION_LOGOFF = 0x80000000
if (lParam & ENDSESSION_LOGOFF)
{
ifexist F:\test_out.txt
{
FileDelete F:\test_out.txt
}
SendMode, Input
SetTitleMatchMode, Regex
WinGet, lst, List, .+ ahk_class ^(?!tooltips_class32$|Shell_TrayWnd$),, Start menu|Program
Manager|Start|System Monitor
loop % lst
{
WinGetTitle, title, % "ahk_id" lst%A_Index%
info .= title "`n"
}
FileAppend, %info%, F:\test_out.txt
}
}
;............................................
ifexist F:\test_out.txt
{
Loop, Read, F:\test_out.txt
{
if A_LoopReadLine contains Program1
{
Run, Path_to_Program1
WinWait Program1
WinActivate
sleep 1000
Send username1{tab}password1{Enter} ; real password and username here ( not encrypted ! )
}
if A_LoopReadLine contains program2
{
Run, Path_to_program2
WinWait program2
WinActivate
sleep 1000
sendUsername2{tab}password2{Enter}
}
if A_LoopReadLine contains program3
{
Run, Path_to_program3
WinWait program3
WinActivate
sleep 1000
send Username3{tab}Password3{Enter}
}
if A_LoopReadLine contains Program4
{
Run, path_to_program4
}
if A_LoopReadLine contains Program5
{
Run, Path_to_program5
WinWait program5
WinActivate
sleep 1000
send Username4{tab}Password4{Enter}
}
}
return
}