ror thank u for u help. the only problem is not that that my timer2 is not doing it job !! It does not click exist confirmation &Yes button !!!i be happy if u tell me what i am doing wrong.Thanks

VB Code:
  1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  2. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  3.  
  4. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  5. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
  6.                 ByVal hwnd As Long, _
  7.                 ByVal wMsg As Long, _
  8.                 ByVal wParam As Long, _
  9.                 ByVal lParam As Long) As Long
  10. Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
  11. Private Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
  12. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  13.  Const WM_COMMAND = &H111
  14.  
  15.  Private iTime As Integer
  16.  
  17.  Private Const WM_CLOSE As Long = &H10
  18.  Private Const WM_KEYDOWN = &H100
  19. Private Const WM_KEYUP = &H101
  20.  Private Const VK_SPACE = &H20
  21.  
  22. Private Sub Command2_Click()
  23. Dim window As Long
  24.  
  25. window = FindWindow("SEINFELD_SUPERMAN", vbNullString)
  26. PostMessage window, WM_COMMAND, 32831, 0
  27.  
  28.  
  29. End Sub
  30.  
  31. Private Sub Timer1_Timer()
  32. [B]Dim x As Long, editx As Long ====> this block does not get executed at all!
  33. Dim button As Long
  34.  
  35.  x = FindWindow("#32770", "Exit?")
  36.    button = FindWindowEx(x, 0&, "Button", "&Yes")
  37.    Call SendMessageLong(button, WM_KEYDOWN, VK_SPACE, 0&)
  38.    Call SendMessageLong(button, WM_KEYUP, VK_SPACE, 0&)[/B]
  39. End Sub
  40.  
  41.  
  42.  
  43. Private Sub Command1_Click()
  44.     Timer2.Interval = 1000
  45.     Timer2.Enabled = True
  46.    
  47. [B]    Timer1.Enabled = True[/B]
  48. End Sub
  49.  
  50.  
  51.  
  52. Private Sub Timer2_Timer()
  53.   iTime = iTime + 1
  54.     Debug.Print iTime
  55.     If iTime >= 20 Then
  56.         Debug.Print "END!"
  57.        [B] Command2_Click[/B]
  58.         Timer2.Interval = 0
  59.         Timer2.Enabled = False
  60.     End If
  61. End Sub