dmercanti Posted July 28, 2020 Posted July 28, 2020 Hi I'm trying to use a compiled script to run another process and get its status bar text. The problem is that if I use a user different from the current logged user (i.e IIS_USR or anything else) the compiled script can't return status text bar. I've tried with different "window 's scheduled task" settings but it runs ok only if the user is the same user that is logged. Any ideas ? Thank you
Nine Posted July 28, 2020 Posted July 28, 2020 Hard to say without any code. And what it the other process in question ? Could you also show the task scheduler screens of your task ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
BigDaddyO Posted July 28, 2020 Posted July 28, 2020 If two different people are logged into the same server, you can't see someone else's screens can you? Then AutoIt couldn't either.
Nine Posted July 28, 2020 Posted July 28, 2020 @BigDaddyO If it is a scheduled task, you need to provide a owner of the task which can be started even if the owner is not logged in. I think it is the problem OP is facing, I think... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 the owner of the task is not the owner that is conncted but the both the compiledscript.exe and the second.exe are called with the same user, but it hangs in "$Contatore=SY_StatusMessageFoundFail(1800,"loaded in","Fail")" because can't reader status bar text . expandcollapse popup#include <Constants.au3> #include <MsgBoxConstants.au3> #include <GuiToolbar.au3> #include <WinAPIFiles.au3> #include <Date.au3> Const $VEAWinTitle="[CLASS:E3_Explorer_3d]" Const $VEAWinTollBarOptimize="[CLASS:E3_Toolbar;INSTANCE:5]" Const $waitDefault=3000 ;attesa di default Local $sCommandFileName="" ;file di elenco comandi Local $sCommandFileNameOUT="" ;file di status uscita Local $sCommandFileNamePING="" ;file di stato corrente (ora attuale) Local $winHndl=0 ;hWin di VEA Local $winHndlTMP=0 ;hWin di VEA temp Local $winHndl_PID=0 ;hWin di VEA temp ;variabili per VEA.TXT Local $VEAPID=0 ;riga Process ID VEA Local $sCmdLineVEA="" ;riga di comando di VEA Local $sInFile="" ;file da convertire (se contiene | allora ;file da convertire|sostituzioni|sessionid Local $sFileType="" ;tipo file di uscita da generare (per il 9 sempre V!) Local $sOutFile="" ;percorso di uscita Local $sRepFile="" ;file per le sostituzioni (non usato) Local $sessionID="" ;stringa di sessione (riportata in $sCommandFileNameOUT) ;Variabili geriche Local $StartTime ;data ora inizio procedura (scritta in $sCommandFileNamePING) Local $CurrentTime ;data ora attuale (scritta in $sCommandFileNamePING) Local $Contatore=0 Local $currentStatus="" if ($CmdLine[0]=1) Then $sCommandFileName=$CmdLine[1]&"\VEA_RUN.txt" Else $sCommandFileName=@TempDir&"\VEA_RUN.txt" EndIf $sCommandFileNameOUT=$sCommandFileName & ".OUT" $sCommandFileNamePING=$sCommandFileName & ".PING" FileDelete($sCommandFileNameOUT) ;elimino i file di uscita FileDelete($sCommandFileNamePING) ;elimino il file di stato corrente Local $hFileOpen = FileOpen($sCommandFileName, $FO_READ) ;apro file file VEA_RUN If $hFileOpen = -1 Then MainClose(1) ;se non lo trovo esco EndIf ;leggo le 4 righe dal file VEA_RUN.TXT $sCmdLineVEA=FileReadLine($hFileOpen) $sInFile=FileReadLine($hFileOpen) $sFileType=FileReadLine($hFileOpen) $sOutFile=FileReadLine($hFileOpen) FileClose($hFileOpen) ;chiudo i l file $StartTime= _DateTimeFormat(_NowCalc(), 0) ;imposto data e ora inizio ;verifico se la riga del file da converire contiene | ;e li decodifico: file da convertire|sostituzioni|sessionid if StringInStr ($sInFile,"|") Then Local $flds = StringSplit($sInFile, "|") $sInFile= $flds[1] $sRepFile= $flds[2] $sessionID= $flds[3] EndIf $currentStatus="OPENING VEA" writePING("") ;scrivo $sCommandFileNamePING $VEAPID=Run( $sCmdLineVEA & " " & $sInFile) ;ESEGUO LA CMDLINE DI VEA! Sleep($waitDefault) ;Attendo un po $winHndl_PID=_GetHwndFromPID($VEAPID); ; ;inizio la ricerca della finestra principale di VEA ; $winHndlTMP=WinExists($VEAWinTitle) ; $Contatore=0; ; While ($winHndlTMP=0) and ($Contatore<=10) ; Sleep(1000) ; $winHndlTMP=WinExists($VEAWinTitle) ; writePING() ; $Contatore=$Contatore+1 ; WEnd ; ;se dopo 10 secondi non si è ancora aperto ; ; esco con il messaggio FAILOPENVEA ; if ($winHndlTMP=0) Then ; SY_writeLOG($sCommandFileNameOUT,"FAILOPENVEA") ; MainClose(1) ; EndIf ; ;a questo punto la finestra è aperta ; ; e mi salvo il suo handle $winHndl ; $winHndl =WinWait($VEAWinTitle) $winHndl=$winHndl_PID Sleep($waitDefault) ;Attendo un po AutoItSetOption("SendKeyDelay", 350) ;imposto ripetizione di tasti ;Local $msgb=""; ;$msgb=ControlGetText ( $winHndl,"" ,"[CLASS:msctls_statusbar32; INSTANCE:1; ID:3002]" ) ;MsgBox($MB_SYSTEMMODAL, "Messaggio satus bar",$msgb & ".." & StatusbarGetText($winHndl,"",2) & ".." & StatusbarGetText($winHndl,"",1)) ;<ATTENDO LA CONVERSIONE DEL 3D ...> ; LEGGENDO LA STATUS BAR DI VEA ; INTERCETTANDO : ; "LOADED IN" (RITORNO 1) ; "FAIL" (RITORNO 1) ; TIMEOUT CIRCA 30 MINUTI (RITORNO 0) $currentStatus="LOADING FILE" $Contatore=SY_StatusMessageFoundFail(1800,"loaded in","Fail") if $Contatore=-1 then ;ERRORE IN APERTURA DEL FILE ! SY_writeLOG($sCommandFileNameOUT,"FAILOPEN") MainClose(1) endif if $Contatore=0 then ;TIMEOUT APERTURA DEL FILE ! SY_writeLOG($sCommandFileNameOUT,"FAILOPENTIMEOUT") MainClose(1) endif $currentStatus="LOADING DONE" writePING("") ;<IL 3D DOVREBBE ESSERE CONVERTITO> Sleep($waitDefault); AutoItSetOption("SendKeyDelay", 550) writePING("") ; INVIO IL COMANDO SAVE AS ;File=>Save AS ControlSend ($winHndl,"","[ID:3022]","!F") Sleep(250) ControlSend ($winHndl,"","[ID:3022]","A") Sleep(1000) ;ATTENDO LA COMPARSA DELLA FINESTRA "SAVE AS" Local $winHndlSAVEAS=0 $winHndlSAVEAS=WinWait("[TITLE:Save As;CLASS:#32770]") Sleep(1000) ;SCRIVO IL NOME DEL FILE NELLA CASELLA FILE NAME ControlSend ($winHndlSAVEAS,"","[CLASS:Edit; INSTANCE:1]",$sOutFile) Sleep(250) ;PREMO IL TASTO SALVA ControlSend ($winHndlSAVEAS,"","[CLASS:Edit; INSTANCE:1]","!S") Sleep(1000) ;SE COMPARE LA RICHIESTA DI SOVRASCRITTURA, PERMO Y If WinExists("[TITLE:Confirm Save As;CLASS:#32770]") Then ControlSend ("[TITLE:Confirm Save As;CLASS:#32770]","","","!Y") Endif $currentStatus="SAVING" ;ATTENDO IL SALVATAGGIO (5 MINUTI) if SY_StatusMessageFound(300,"File saved") then SY_writeLOG($sCommandFileNameOUT,"OK") Else SY_writeLOG($sCommandFileNameOUT,"FAILSAVE") endif MainClose(0) exit ;=================== FUNZIONI AGGIUNTIVE ======================== ;CHIUSURA / USCITA VEA Func MainClose($errNo) WinClose($VEAWinTitle) ;chiudo la finestra WinWaitClose($VEAWinTitle) FileDelete($sCommandFileNamePING) ;cancello il file di ping Exit($errNo) ;restituisco la funzione exit EndFunc ;ATTENDO X SECONDI X IL MESSAGGIO DI STATO NELLA BARRA Func SY_StatusMessageFound($nSec,$msg) Local $cnt=0 Local $sText="" Local $iPosition =0 While ($cnt <= $nSec) and ($iPosition=0) Sleep(1000) $sText=SY_getStatusBarMessage() writePING($sText) ;MsgBox($MB_SYSTEMMODAL, $sText, "Messaggio satus bar") $cnt = $cnt + 1 $iPosition = StringInStr($sText, $msg) WEnd Return ($iPosition<>0) EndFunc ;ATTENDO X SECONDI X IL MESSAGGIO DI OK $MSG OPPURE DI FAIL $MSGFAIL NELLA BARRA Func SY_StatusMessageFoundFail($nSec,$msg,$msgFail) Local $cnt=0 Local $sText="" Local $sTextFail="" Local $iPosition =0 Local $iPositionFail =0 While ($cnt <= $nSec) and ($iPosition=0) and ($iPositionFail=0) Sleep(1000) $sText=SY_getStatusBarMessage() $sTextFail=SY_getStatusBarMessageFail() writePING($sText & "§" & $sTextFail) ;MsgBox($MB_SYSTEMMODAL, $sText, "Messaggio satus bar") $cnt = $cnt + 1 $iPosition = StringInStr($sText, $msg) $iPositionFail = StringInStr($sTextFail, $msgFail) WEnd if ($iPosition<>0) Then Return 1 EndIf if ($iPositionFail<>0) Then Return -1 EndIf Return 0 EndFunc ;ritorno il testo della barra di stato nella posizione 2 Func SY_getStatusBarMessage() ;Local $msgb=""; ;$msgb=ControlGetText ( $winHndl, "text", "[CLASS:msctls_statusbar32; INSTANCE:1]" ) Return StatusbarGetText($winHndl,"",2) EndFunc ;ritorno il testo della barra di stato nella posizione 1 Func SY_getStatusBarMessageFail() ;Local $msgb=""; ;$msgb=ControlGetText ( $winHndl, "text", "[CLASS:msctls_statusbar32; INSTANCE:1]" ) Return StatusbarGetText($winHndl,"",1) EndFunc ;scrivo il file di log Func SY_writeLOG($sFileName,$msg) if ($sessionID<>"") Then $msg=$msg & "|" & $sessionID & "|" & $VEAPID & "|" & @AutoItPID EndIf FileWriteLine($sFileName,$msg) EndFunc ;scrivo il file di ping Func writePING($agg) $CurrentTime= _DateTimeFormat(_NowCalc(), 0); FileWriteLine($sCommandFileNamePING, $StartTime & "|" & $CurrentTime & "|" & $currentStatus & "|" & $VEAPID & "|" & @AutoItPID & "|" & $winHndl & "|" & $agg) EndFunc Func ReplaceVeaCode($winVEAHndl ,$Origine,$Destinazione) Local $FileQueryPath=@TempDir&"\VEA_RUN_Query.txt" Local $FileQuery="everything()" & @CRLF & "show()" & @CRLF & "partial_match($name,""" & $Origine & """,false)" & @CRLF & "select()" FileWriteLine($FileQueryPath,$FileQuery) ControlSend ($winVEAHndl,"","","{F3}") Local $winHndQry=0 $winHndQry=WinWait("[TITLE:Find and Select Objects;CLASS:#32770]") WinMove($winHndQry, "", 0,0) ; MouseMove(150, 110, 0) ControlClick($winHndQry, "", "[CLASS:Qt5QWindowIcon; INSTANCE:1]","left",1,133,52) Local $winOpenAndRun=0 $winOpenAndRun=WinWait("[TITLE:Open and Run Query;CLASS:#32770]") ControlSend ($winOpenAndRun,"","[CLASS:Edit; INSTANCE:1]",$FileQueryPath) ControlSend ($winOpenAndRun,"","[CLASS:Edit; INSTANCE:1]","!O") WinClose ($winHndQry) FileDelete($FileQueryPath) ControlFocus($winVEAHndl, "", "[CLASS:E3_TreeView; INSTANCE:1]") ControlClick($winVEAHndl, "", "[CLASS:E3_TreeView; INSTANCE:1]","middle",1,0,0) ControlSend ($winVEAHndl,"","[CLASS:E3_TreeView; INSTANCE:1]","{F2}") ControlSend ($winVEAHndl,"","","{F2}") ControlSend ($winVEAHndl,"","[CLASS:E3_TreeView; INSTANCE:1]",$Destinazione) Sleep(500) ControlSend ($winVEAHndl,"","[CLASS:E3_TreeView; INSTANCE:1]","{ENTER}") Sleep(500) ControlClick($winVEAHndl, "", "[CLASS:E3_TreeView; INSTANCE:1]","left",1,0,0) Sleep(500) ControlClick($winVEAHndl, "", "[CLASS:E3_View3d; INSTANCE:1]","left",1,0,0) Sleep(500) EndFunc ;Function for getting HWND from PID Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() Do For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd <> 0 Return $hWnd EndFunc;==>_GetHwndFromPID
Developers Jos Posted July 28, 2020 Developers Posted July 28, 2020 (edited) Maybe you need to use "Return ControlGetText($winHndl, "", "Find proper name and put it here")" in stead of "Return StatusbarGetText($winHndl,"",1)". Jos Edited July 28, 2020 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 may be but I can't get the status text with a call like this $msgb=ControlGetText ( $winHndl,"" ,"[CLASS:msctls_statusbar32; INSTANCE:1; ID:3002]" ) while the simple call to StatusbarGetText($winHndl,"",2) runs ok with the same user logged
seadoggie01 Posted July 28, 2020 Posted July 28, 2020 (edited) This is a 64 bit application... have you tried running with AutoIt x64? (by default AutoIt runs with 32 bit). I use this leading line when I compile my scripts... #AutoIt3Wrapper_UseX64=y Edited July 28, 2020 by seadoggie01 Dyslexia strikes again... wanted 64 lol All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 tried with no luck (with Y) #AutoIt3Wrapper_UseX64=n
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 ControlGetText I think that If this is the right choice , why also autoit info window report "blank Text" in his capture in the "control" tab, but shows correct values in "status bar" tab?
seadoggie01 Posted July 28, 2020 Posted July 28, 2020 Because a StatusBar, according to MS, can be made of multiple Controls. And it doesn't have a text property, the internal controls may, however. The Au3Info tool checks the statusbar's internal control's text values. (Jos may have been checking that the control wasn't a StatusBar, but something that looks similar to one, like a disabled Edit control) All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Developers Jos Posted July 28, 2020 Developers Posted July 28, 2020 7 minutes ago, seadoggie01 said: (Jos may have been checking that the control wasn't a StatusBar, but something that looks similar to one, like a disabled Edit control) Nah... just saw the comment in the helpfile which indicates it doesn't always works and it suggest this solution. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 maybe _WinAPI_EnumChildWindows ? But I don't know how to work with it Local $hWndSB = ControlGetHandle ($winHndl,"", "[CLASS:msctls_statusbar32; INSTANCE:1; ID:3002]") Local $aData = _WinAPI_EnumChildWindows($hWndSB) I get the status bar control handle.... right... and now I would like to enum its childs...
Developers Jos Posted July 28, 2020 Developers Posted July 28, 2020 Shouldn't that be?: Local $aData = _WinAPI_EnumChildWindows($winHndl) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 I want the status bar children not main windows children...
dmercanti Posted July 28, 2020 Author Posted July 28, 2020 This status bar seems to be composed by a progress (hidden) and "E3_Dock_frame" ... I can get text of "E3_Dock_frame" but it says "status"...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now