Sign in to follow this  
Followers 0
shmuelw1

WinWaitActive not working? use WinSetOnTop instead

2 posts in this topic

I have a script to open a bunch of programs when I start the computer. I was using WinWaitActive to activate a window then type some text, but it was not working. It could be I was opening too many things at the same time. So I found an alternative to use WinSetOnTop, type the text, then use WinSetOnTop again to make it not be on top anymore.

Just thought I'd mention that alternative in case it helps someone out there in AutoIt-land.

Share this post


Link to post
Share on other sites



If you just need to type some text you can use ControlSend and don't even need to activate the window.


When the words fail... music speaks

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • AnonymousX
      By AnonymousX
      Hello,
      I'm wondering if there is a way to remove all windows with the status set on top? 
      I know this can be easily done if you know the title or have the window as an active window, but I'm wondering if there is something that will apply to all windows at once to remove this status?
      Thanks
    • trademaid
      By trademaid
      ;WinWaitActive intermittently fails to find the "Exit Session Setting" window.
      ;If the window is moved my the mouse, it will then work.
      ;can anyone help?
      ; this changes the tws logout time to be a minute earlier than the pc clock time
      Opt("TrayAutoPause", 0)
      Opt("MouseCoordMode", 0)
      Opt("WinTitleMatchMode", 2)
      #include <File.au3>
      $logfile = "c:\log\twslogin2" & @YEAR & @MON & @MDAY & ".txt"
      TraySetIcon("Shell32.dll", 180)
      _FileWriteLog($logfile, "Starting")
      ; Live mode
      While 1
          ;If (((@HOUR = 3 And (@MIN > 15 Or @MIN < 31))) Or (@HOUR = 15 And (@MIN > 15 Or @MIN < 31))) Then
          If 1 Then
              ConsoleWrite("tp0 " & @CRLF);
              Sleep(2000)
              Opt("SendKeyDelay", 500) ;150
              ConsoleWrite("waiting for jave window " & @HOUR & @MIN & @SEC & @CRLF);
              WinWaitActive("[CLASS:SunAwtFrame]", "")
              ConsoleWrite("found for jave window, waiting for exit window " & @HOUR & @MIN & @SEC & @CRLF);
              _FileWriteLog($logfile, "Exit :Session Setting")
              $ret = WinWaitActive("Exit Session Setting", "", 6)
              ConsoleWrite("tp1 " & @CRLF);
              Sleep(2000)
              If ($ret > 0) Then
                  ConsoleWrite("found exit window " & @HOUR & @MIN & @SEC & @CRLF);
                  If WinExists("Exit Session Setting") Then
                      ConsoleWrite("moving windoW " & @HOUR & @MIN & @SEC & @CRLF);
                      WinMove("Exit Session Setting", "", 0, 0, 320, 170, 100)
                      $hr = @HOUR ;
                      If @HOUR > 12 Then
                          Beep(3000, 200);
                          $hr = @HOUR - 12 ;
                      EndIf
                      $minutes = @MIN
                      ;If ($minutes > 55) Then $minutes = 20;
                      If ($minutes < 20) Then $minutes = 55;
                      ConsoleWrite("right digit " & @CRLF);
                      MouseClick("left", 126, 60, 1); right most digit
                      Beep(3900, 200);
                      Sleep(1000)
                      Send("{backspace}" & "{backspace}" & "{backspace}" & "{backspace}" & "{backspace}" & "{backspace}" & "{backspace}" & $hr & ":" & $minutes - 1 & "{enter}");
                      MouseClick("left", 131, 150, 1); update
                      MouseClick("left", 196, 150, 1); close
                      ConsoleWrite("done " & @CRLF);
                      Sleep(1000)
                      WinMinimizeAll()
                  Else
                      Beep(1500, 20);
                      ConsoleWrite("tp4 " & @CRLF);
                      Sleep(1000)
                      ;MsgBox($MB_SYSTEMMODAL, "", "Window does not exist", 2)
                      _FileWriteLog($logfile, "Window does not exist")
                      ;Beep(1500, 500);
                  EndIf
              EndIf
          EndIf
          Sleep(2000)

      WEnd;
       
       
       
       
      tws_login.au3

    • algiuxas
      By algiuxas
      Hello,
      I'm trying to make cursor for my program, and I need to make it on top but not active when pressed on start menu, taskbar or etc. (cursor appears behind taskbar/start menu).
      Somebody could help me with this problem?
      ; A bit of my script #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <GuiListBox.au3> Global $Bitmap_Mouse_Pic_Dir = @ScriptDir&"\Cursor.png" Global $Bitmap_Mouse_Pic = _GetWHI($Bitmap_Mouse_Pic_Dir) Global $Bitmap_Mouse_PicSel_Dir = @ScriptDir&"\Selection.png" Global $Bitmap_Mouse_PicSel = _GetWHI($Bitmap_Mouse_PicSel_Dir) Global $Bitmap_Mouse_Opt = 255 ; ... For $i = 0 to 0 $GP_guicur[$i] = GUICreate("GP Cursor", 64, 64, $POS[$i][0], $POS[$i][1], $WS_POPUP, $WS_EX_LAYERED, $GUI) WinSetOnTop($GP_curgui[$i],"",1) SetBitmap($GP_curgui[$i], $Bitmap_Mouse_Pic, $Bitmap_Mouse_Opt) GUISetState(@SW_SHOW) Next ; ... For ; ... Sleep(1000) MouseClick("left",5,@DesktopHeight-5) ; ... Next Exit ;______________________________________________________________________; ; Original program by Ejoc ; ; Improved by Adam1213 (autoit 3.2 compatiblity + improved labels; ;______________________________________________________________________; ; $sImage = Path to your image ; Returns = Array[3] ; $Array[0] = Width ; $Array[1] = Height ; $Array[2] = handle to a HBITMAP ; when the image is no longer needed use _WinAPI_DeleteObject($Array[2]) Func _GetWHI($sImage) Local $hImage, $aBitmap[3] _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $aBitmap[0] = _GDIPlus_ImageGetWidth($hImage) $aBitmap[1] = _GDIPlus_ImageGetHeight($hImage) $aBitmap[2] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return $aBitmap EndFunc ;==>_GetWHI ; I changed this so I could shutdown gdiplus once an image has been loaded by _GetWHI() ; just pass it the array returned by _GetWHI() Func SetBitmap($hGUI, $aBitmap, $iOpacity) Local Const $AC_SRC_ALPHA = 1 Local $hScrDC, $hMemDC, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $aBitmap[2]) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $aBitmap[0]) DllStructSetData($tSize, "Y", $aBitmap[1]) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap
      Thanks
    • ur
      By ur
      How to use winwaitactive to search for multiple titles at a time.?
      Like in my code I am searching for the window with title "Windows Security" and passing credentials automatically.
      WinWaitActive("Windows Security")
      But there is another window also where I need to pass credentials with title "User Account Control".
      How to modify the below code so that it will wait for any of the above windows and send the credentials.
       
      While 1 WinWaitActive("Windows Security") ;ANy option to keep or condition logic here Send($CmdLine[1]) Send("{TAB}") Send($CmdLine[2]) Send("{ENTER}") WEnd