AutoHotkey Community

It is currently May 27th, 2012, 10:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: January 21st, 2011, 11:38 pm 
Offline

Joined: January 15th, 2011, 2:36 pm
Posts: 13
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

}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2011, 12:38 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
Read about the Auto-execute Section of a script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: logg off script
PostPosted: January 22nd, 2011, 11:47 am 
Thanks for the Hint !! .. i removed the return after the OnMessage and it worked !


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, specter333, tomoe_uehara, XstatyK and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group