Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/22/2023 in all areas

  1. I don't know if you are like me, but I am always searching for that specific code I wrote over the years, but cannot find it. It was way too exhausting to look at 1k+ scripts. And Windows Explorer is not the best tool to do such exploration. So I made this little script that save me tons of time. Hope you will find it useful too. You can adjust default search folders and type of files you want to search for, but you can also change it at runtime. To use multiple filters separate them with ";" Let me know if you have any suggestion to enhance the tool. Version 2023-12-27 * Code revision : 3.3.16.1 now required Version 2023-05-10 * Sets children flag on first drawn list Version 2021-04-06 * Context menu modified to allow clipping file name and line content Version 2020-11-21 * Allows only 1 running instance of the script * Added right-click support on Tray to exit script Version 2020-06-29 * Added Copy File Name to context menu (helps to copy include files names) Version 2020-04-22 * Added icons to main buttons * Added informative box to describe progress and results of a search * Increased robustness of the GUI * Open Button enabled only under the right conditions * Added Tooltip on filter field to describe how to enter multiple criteria * Forced a minimum Window size Version 2020-04-18 * Added support of Context Menu in Tree View * Added support of Tray * Minimizes on Tray Version 2020-04-12 * Added DPI awareness * Added Enter Key functionality to start a search Version 2020-04-09 * Changed base size of the GUI to make it wider * Made the window resizable * Added Reset button * Shown busy cursor more appropriately * Corrected bug of first line displayed Thanks all for your input. SearchContent.au3
    1 point
  2. Sascha

    Map data from/to file

    @ioa747 Thank you but i think the json version is the best for me.
    1 point
  3. #include <File.au3> #include <Date.au3> #include <Timers.au3> #include <WinAPIFiles.au3> #include <Misc.au3> #include "\Include\HTTP\HTTP.au3" #include "\Include\OpenCV\OpenCV_Match\OpenCV-Match_UDF.au3" #include "\Include\Festivos.au3" ;_Singleton("Mayores_OpenCV", 0) If _Singleton("Mayores_OpenCV", 1) = 0 Then Msgbox(48,"Atención", "Ya se está ejecutando." & @LF & "Esta instancia se cerrará.", 5) Exit EndIf AutoItWinSetTitle("Mayores_OpenCV") ;Esperar ;https://www.autoitscript.com/forum/topic/182398-how-do-i-gracefully-close-an-autoit-script-that-is-running/ While 1 If Not WinExists("Diario") Then ExitLoop EndIf Sleep(1000) WEnd If _Festivos() Then ;ConsoleWrite("Festivo" & @CRLF) Exit EndIf Opt('WinWaitDelay', 250) Opt('WinDetectHiddenText', 1) Opt('MouseCoordMode', 0) Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Opt("SendKeyDelay", 75) Opt("SendKeyDownDelay", Default) Opt("SendCapslockMode", 1) Opt("MustDeclareVars", 1) Opt("TrayIconDebug", 1) ;Be sure to register this to reenable power-saving, screensaver, etc OnAutoItExitRegister("OnAutoItExit") #===== CONFIG ===== Global $mouse, $offset, $iFileExists, $hWnd, $Found, $sFilePath, $sFilePath2, $sFilePath4, $sOpenCVDir, $hFile, $YearA3, $FromC, $ToC, $FromF, $ToF, $Puntear, $Saldos, $sms, $CleanLog, $CheckActive, $RestoreBreak $CheckActive = True ;~ $CheckActive = False $sms = False Global Const $Year = @YEAR Global Const $Mon = @MON ;StringFormat("%02i", @MON - 1) Global Const $Day = @MDAY If $CmdLine[0] = 1 Then $YearA3 = $Year - 1 Else $YearA3 = $Year EndIf $Puntear = True $Saldos = True $FromF = "01/01/" & $YearA3 $ToF = "31/12/" & $YearA3 $FromC = "4000000001" $ToC = "4300999999" $sOpenCVDir = "C:\.........\OpenCV\OpenCV_Match" $sFilePath = "\\...SERVERNAME...\...\EXP\switch" Global $sFilePathLog = @DesktopDir & "\Events.log" $hFile = FileOpen($sFilePathLog, 2) $sFilePath2 = "\\...SERVERNAME...\...\EXP\tmp.rtf" $sFilePath4 = "C:\Users\...\mayores.rtf" #===== OpenCV-Match_UDF ===== ;Desde tarea programada de Windows daba error: Failed loading DLLs FileChangeDir($sOpenCVDir) _OpenCV_Startup();loads opencv DLLs _OpenCV_EnableLogging(True, True, True) ;Logs matches, errors in a log file and autoit console output. If $CheckActive Then ;Comprobar que o usuario está inactivo ;https://stackoverflow.com/questions/3867584/autoit-how-to-get-system-idle-time-or-if-screensaver-is-active ;How to get system idle time, or if screensaver is active? ;The _Timer_GetIdleTime() function uses GetLastInputInfo from user32.dll. While 1 ;use infinite loop since ExitLoop will get called If _DateDiff('n', _NowCalc(), @YEAR & "/" & @MON & "/" & @MDAY & " 20:10:00") > 10 Then If _Timer_GetIdleTime() > 600000 Then ;600000 ExitLoop EndIf Else If _Timer_GetIdleTime() > 300000 Then ;300000 ExitLoop EndIf EndIf Sleep(10000) WEnd ;Otra forma ;Do ;Sleep(10000) ;Until _Timer_GetIdleTime() > 300000 EndIf If _DateDiff('n', _NowCalc(), $Year & "/" & $Mon & "/" & $Day & " 20:16:00") > 1 Then $ToC = "5230999999" ;Introducir pausa: conexión de rede pode tardar en restaurarse cando equipo estaba suspendido For $i = 0 To 30 If FileExists("\\...SERVERNAME...\...\EXP") Then ExitLoop Else If $i < 30 Then Sleep(5000) Else _FileWriteLog($hFile, "Error Acceso a carpeta ...\EXP") Exit EndIf EndIf Next If ProcessExists("thunderbird.exe") Then ; Check if the thunderbird process is running. ProcessClose("thunderbird.exe") EndIf If ProcessExists("EXCEL.exe") Then ; Check if the thunderbird process is running. ProcessClose("EXCEL.exe") EndIf If ProcessExists("mstsc.exe") Then ;Check if the process is running. ProcessClose("mstsc.exe") EndIf ;Pode estar suspendido MouseMove(@DesktopWidth - 100, @DesktopHeight - 100) Sleep(20000) Send("#d") ;https://www.autoitscript.com/forum/topic/97501-auto-mstsc/ ;RunWait('"' & @ComSpec & '" /c MSTSC.EXE C:/yourfile.rdp', '', @SW_HIDE) ;http://support.microsoft.com/kb/941641 Run("C:\windows\system32\mstsc.exe /v:" & "__._._._") $hWnd = WinWait("Conexión a Escritorio remoto", "Errores de certificado", 10) If WinExists($hWnd) Then If Not WinActive($hWnd, "") Then WinActivate($hWnd) WinWaitActive($hWnd, "", 5) ;WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(1000) EndIf If WinActive($hWnd, "") Then If ControlSend($hWnd, "", "", "s") = 1 Then _FileWriteLog($hFile, "OK ControlSend: s [Errores Certificado]") Else _FileWriteLog($hFile, "Error ControlSend: s [Errores Certificado]") Exit EndIf Sleep(5000) EndIf EndIf ;Wait 90 seconds for the window to appear. $hWnd = WinWait("__._._._ - Conexión a Escritorio remoto", "", 90) If WinExists($hWnd) Then If Not WinActive($hWnd, "") Then WinActivate($hWnd) WinWaitActive($hWnd, "", 60000) ;WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(1000) EndIf If WinActive($hWnd, "") Then _FileWriteLog($hFile, "OK Ventana Activa: Conexión a Escritorio") EndIf EndIf ;Test if the window is now activated ;You can use the WinActive() function to check if WinActivate() succeeded. If WinActive($hWnd, "") Then ;WinSetState($hWnd, "", @SW_MAXIMIZE) ;MsgBox(0, "", "Window NOW active") ;DirCreate($sFilePath3) ;por se quedou dunha execución anterior FileRecycle($sFilePath) FileRecycle($sFilePath2) MouseMove(@DesktopWidth - 80, @DesktopHeight - 80) Sleep(10000) Global $sCoords[4] = [1416, 646, 1418, 648] Global $count, $iCheckSum = 1769473 ;black screen $offset = 1 ; how far to move the mouse ;Get initial checksum we will check later ;$iCheckSum = PixelChecksum($sCoords[0], $sCoords[1], $sCoords[2], $sCoords[3]) ;ConsoleWrite($iCheckSum & @CRLF) ;Wait for the region to change, the region is checked every 5000ms to reduce CPU load While $iCheckSum = PixelChecksum($sCoords[0], $sCoords[1], $sCoords[2], $sCoords[3]) Sleep(5000) $mouse = MouseGetPos() MouseMove($mouse[0] + $offset, $mouse[1] + $offset) $offset = -$offset $count += 1 If $count = 1800 Then _FileWriteLog($hFile, "ExitLoop: Black Screen $count = 1800") ExitLoop ;_ScreenCapture_Capture($sFilePath3 & $Day & @HOUR & @MIN & ".png" , $sCoords[0], $sCoords[1], $sCoords[2], $sCoords[3], False) EndIf WEnd ;MsgBox(0, "", "Something in the region has changed!") Sleep(10000) _CheckFullScreen() _ProcessClean(@ScriptLineNumber) Sleep(5000) ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#r") = 1 Then _FileWriteLog($hFile, "OK ControlSend: #r") Sleep(2000) If ControlSend($hWnd, "", "", "C:\a3\A3CONV5\COWMENU.EXE") = 1 Then _FileWriteLog($hFile, "OK ControlSend: command") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Else _FileWriteLog($hFile, "Error ControlSend: command") Exit EndIf Else _FileWriteLog($hFile, "Error ControlSend: #r") Exit EndIf Sleep(7000) $count = 0 For $i = 1 To 10 $count += 1 $offset = 1 ; how far to move the mouse $mouse = MouseGetPos() MouseMove($mouse[0] + $offset, $mouse[1] + $offset) $offset = -$offset Sleep(1000) MouseMove($mouse[0] + $offset, $mouse[1] + $offset) ;Please note that these examples might not work as the match pictures have to be found with the exact same size on your screen. Global $sCoords[4] = [770, 470, 778, 481] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\01.png", 0.70, $sCoords, 30, 1000);Try to find the match picture on the screen. Number of tries: 60, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(2000) MouseClick($MOUSE_CLICK_LEFT, 747, 440) Sleep(1000) If ControlSend($hWnd, "", "", "ABCDEFG") = 1 Then _FileWriteLog($hFile, "OK ControlSend: ABCDEFG") Else _FileWriteLog($hFile, "Error ControlSend: ABCDEFG") Exit EndIf Sleep(1000) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(1000) ExitLoop Else If $count = 10 Then _FileWriteLog($hFile, "No match found: " & $sOpenCVDir & "\Match\a3\01.png") Exit EndIf EndIf Next Sleep(5000) ;Acceso a aplicaciones: a3con Global $sCoords[4] = [302, 238, 365, 276] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\01b.png", 0.70, $sCoords, 60, 1000);Try to find the match picture on the screen. Number of tries: 60, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(1000) Else _FileWriteLog($hFile, "No match found: " & $sOpenCVDir & "\Match\a3\01b.png") Exit EndIf Sleep(10000) $count = 0 For $i = 1 To 10 $count += 1 $offset = 1 ; how far to move the mouse $mouse = MouseGetPos() MouseMove($mouse[0] + $offset, $mouse[1] + $offset) $offset = -$offset Sleep(1000) MouseMove($mouse[0] + $offset, $mouse[1] + $offset) Global $sCoords[4] = [268, 91, 276, 100] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\02.png", 0.70, $sCoords, 30, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) For $i = 0 To 1 If ControlSend($hWnd, "", "", $Day & $Mon & $YearA3) = 1 Then Sleep(500) If ControlSend($hWnd, "", "", "{TAB}") = 1 Then Sleep(200) _FileWriteLog($hFile, "OK ControlSend: {TAB}") Else _FileWriteLog($hFile, "Error ControlSend: {TAB}") Exit EndIf _FileWriteLog($hFile, "OK ControlSend: " & $Day & $Mon & $YearA3) Else _FileWriteLog($hFile, "Error ControlSend: " & $Day & $Mon & $YearA3) Exit EndIf Next Sleep(1000) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(1000) ExitLoop Else If $count = 10 Then _FileWriteLog($hFile, "No match found: " & $sOpenCVDir & "\Match\a3\02.png") Exit EndIf EndIf Next Global $sCoords[4] = [1047, 371, 1057, 378] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\03.png", 0.70, $sCoords, 30, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) ;Avisos con pouco texto pode estar visible ainda Global $sCoords[4] = [1046, 355, 1328, 382] While 1 ;use infinite loop since ExitLoop will get called Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\03b.png", 0.70, $sCoords, 1, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If @error Then Sleep(100) ExitLoop EndIf Sleep(1000) WEnd If ControlSend($hWnd, "", "", "{F10}lcmi") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {F10}lcmi") Else _FileWriteLog($hFile, "Error ControlSend: {F10}lcmi") Exit EndIf Sleep(1000) ;_ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position ;Sleep(1000) Else _FileWriteLog($hFile, "No match found: " & $sOpenCVDir & "\Match\a3\03b.png") Exit EndIf Sleep(1000) Global $sCoords[4] = [33, 138, 41, 145] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\mayores_01.png", 0.70, $sCoords, 30, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(1000) Else _FileWriteLog($hFile, "No match found: " & $sOpenCVDir & "\Match\a3\mayores_01.png") Exit EndIf If WinActive($hWnd, "") Then MouseClick($MOUSE_CLICK_LEFT, 118, 180) _FileWriteLog($hFile, "Click") Sleep(1000) EndIf If ControlSend($hWnd, "", "", $FromF) = 1 Then _FileWriteLog($hFile, "OK ControlSend: " & $FromF) Else _FileWriteLog($hFile, "Error ControlSend: " & $FromF) Exit EndIf Sleep(1000) If ControlSend($hWnd, "", "", "{TAB}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {TAB}") Else _FileWriteLog($hFile, "Error ControlSend: {TAB}") Exit EndIf Sleep(500) If ControlSend($hWnd, "", "", $ToF) = 1 Then _FileWriteLog($hFile, "OK ControlSend: " & $ToF) Else _FileWriteLog($hFile, "Error ControlSend: " & $ToF) Exit EndIf Sleep(1000) If ControlSend($hWnd, "", "", "{TAB}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {TAB}") Else _FileWriteLog($hFile, "Error ControlSend: {TAB}") Exit EndIf Sleep(500) If ControlSend($hWnd, "", "", $FromC) = 1 Then _FileWriteLog($hFile, "OK ControlSend: " & $FromC) Else _FileWriteLog($hFile, "Error ControlSend: " & $FromC) Exit EndIf Sleep(1000) If ControlSend($hWnd, "", "", "{TAB}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {TAB}") Else _FileWriteLog($hFile, "Error ControlSend: {TAB}") Exit EndIf Sleep(500) If ControlSend($hWnd, "", "", $ToC) = 1 Then _FileWriteLog($hFile, "OK ControlSend: " & $ToC) Else _FileWriteLog($hFile, "Error ControlSend: " & $ToC) Exit EndIf Sleep(1000) If ControlSend($hWnd, "", "", "{TAB}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {TAB}") Else _FileWriteLog($hFile, "Error ControlSend: {TAB}") Exit EndIf Sleep(500) If WinActive($hWnd, "") Then MouseClick($MOUSE_CLICK_LEFT, 328, 283) _FileWriteLog($hFile, "Click: Ambos") Sleep(1000) EndIf ;32 - Listar Nº Referencia Global $sCoords[4] = [323, 321, 333, 331] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\05.png", 0.70, $sCoords, 1, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(500) ;Else ;Exit EndIf ;34 - No listar ctas sin movimiento Global $sCoords[4] = [323, 364, 333, 374] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\05.png", 0.70, $sCoords, 1, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(500) ;Else ;Exit EndIf ;35 - No listar ctas con saldo 0 Global $sCoords[4] = [323, 385, 334, 398] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\06.png", 0.70, $sCoords, 1, 500);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If Not @error Then _MarkMatch($Match1) ;Debugging: Draws a rect on the screen/coordinates of the match to show the user where the match was found Sleep(100) _ClickMouse($Match1, "left",1) ;Calculates the center of the match and clicks the left mouse once on click position Sleep(500) ;Else ;Exit EndIf If WinActive($hWnd, "") Then MouseClick($MOUSE_CLICK_LEFT, 93, 87) _FileWriteLog($hFile, "Click: pantalla") Sleep(1000) EndIf $offset = 1 While 1 If Not WinExists("__._._._ - Conexión a Escritorio remoto") Then _FileWriteLog($hFile, "Error Not WinExists: __._._._") ExitLoop Else If Not WinActive($hWnd, "") Then If _Timer_GetIdleTime() > 30000 Then WinActivate($hWnd) WinWaitActive($hWnd, "", 10) WinSetState($hWnd, "", @SW_MAXIMIZE) EndIf Sleep(5000) Else If $Found = False Then Global $sCoords[4] = [132, 45, 139, 55] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\Listado_Plan_Contable.png", 0.70, $sCoords, 1, 1000);Try to find the match picture on the screen. Number of tries: 1, Sleep between each try: 1000ms. If @error Then If WinActive($hWnd, "") Then $mouse = MouseGetPos() MouseMove($mouse[0] + $offset, $mouse[1] + $offset) $offset = -$offset EndIf Else $Found = True ConsoleWrite("Found: Listado_Plan_Contable.png" & @crlf) _FileWriteLog($hFile, "Found: Listado_Plan_Contable.png") EndIf Sleep(5000) Else Global $sCoords[4] = [132, 45, 139, 55] Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\a3\Listado_Plan_Contable.png", 0.70, $sCoords, 1, 1000);Try to find the match picture on the screen. Number of tries: 1, Sleep between each try: 1000ms. If @error Then _FileWriteLog($hFile, "Not Found: Listado_Plan_Contable.png") ConsoleWrite("Not Found: Listado_Plan_Contable.png" & @crlf) If ControlSend($hWnd, "", "", "{F10}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {F10}") Else _FileWriteLog($hFile, "Error ControlSend: {F10}") Exit EndIf Sleep(3000) If ControlSend($hWnd, "", "", $sFilePath2) = 1 Then _FileWriteLog($hFile, "OK ControlSend: " & $sFilePath2) Else _FileWriteLog($hFile, "Error ControlSend: " & $sFilePath2) Exit EndIf Sleep(3000) If ControlSend($hWnd, "", "", "{ENTER}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: {ENTER}") Else _FileWriteLog($hFile, "Error ControlSend: {ENTER}") Exit EndIf For $j = 0 To 29 Sleep(20000) If WinActive($hWnd, "") Then $mouse = MouseGetPos() MouseMove($mouse[0] + $offset, $mouse[1] + $offset) $offset = -$offset EndIf $iFileExists = FileExists($sFilePath2) If $iFileExists Then _FileWriteLog($hFile, "OK FileExists: " & $sFilePath2) ExitLoop Else _FileWriteLog($hFile, "Sleep(20000)") EndIf Next ExitLoop Else Sleep(5000) EndIf EndIf EndIf EndIf WEnd For $j = 0 To 300 $iFileExists = FileExists($sFilePath2) If $iFileExists Then While _WinAPI_FileInUse($sFilePath2) Sleep(1000) WEnd ExitLoop Else Sleep(1000) EndIf Next If FileExists($sFilePath2) Then If FileMove($sFilePath2, $sFilePath4, 1) = 1 Then _FileWriteLog($hFile, "OK FileMove") Global $iFileSize = FileGetSize($sFilePath4) $CleanLog = True Else _FileWriteLog($hFile, "Error FileMove") Exit EndIf Sleep(1000) While _WinAPI_FileInUse($sFilePath4) Sleep(1000) WEnd Sleep(1000) ;Evitar coincidir con ... (22 horas) While 1 ;use infinite loop since ExitLoop will get called If Abs(_DateDiff('n', $Year & "/" & $Mon & "/" & $Day & " 22:00:00", _NowCalc())) > 5 Then ExitLoop EndIf Sleep(1000) WEnd ;Outra forma ;Do ;Sleep(1000) ;Until Abs(_DateDiff('n', @YEAR & "/" & $Mon & "/" & @MDAY & " 22:00:00", _NowCalc())) > 5 RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & "C:\Users\...\Strings\RTF_to_DataBase.au3" & '"', "", @SW_SHOW, 0) _FileWriteLog($hFile, "OK: RTF_to_DataBase.au3") FileRecycle($sFilePath4) _FileWriteLog($hFile, "FileRecycle") If $sms Then Global $sResp = _HTTP_Post("http://api.mensatek.com/sms/v5/enviar.php", "Correo=" & URLEncode("SOME@DOMAIN.com") & "&Passwd=01234&Remitente=ABCDE&Destinatarios=" & URLEncode("34612345678") & "&Mensaje=" & URLEncode("OK: File size " & $iFileSize & " bytes") & "&Resp=JSON") ;Open the file for write access. Global $hFileOpen = FileOpen(@DesktopDir & "\Resp_mensatek.txt", 2) ;If $hFileOpen = -1 Then ;MsgBox(0, "", "An error occurred when reading/writing the file.") ;EndIf ;Write some data. FileWrite($hFileOpen, $sResp) ;Close the handle returned by FileOpen. FileClose($hFileOpen) EndIf Else _FileWriteLog($hFile, "Error Not FileExists: " & $sFilePath2) Exit EndIf Else ;MsgBox(0, "Error", "Window not active") ;Local $hActive = WinGetHandle("[active]") ;Local $sTitle = WinGetTitle("[active]") ;MsgBox(0, "Error", $sTitle) ;Open the file for write access. Global $hFileOpen = FileOpen(@DesktopDir & "\RDP_A3_OpenCV_ERROR.txt", 2) ;If $hFileOpen = -1 Then ;MsgBox(0, "", "An error occurred when reading/writing the file.") ;EndIf ;Write some data. FileWrite($hFileOpen, "ERROR: Conexión a Escritorio remoto non é a ventana activa") ;Close the handle returned by FileOpen. FileClose($hFileOpen) EndIf Func _CheckFullScreen() ;Check fullscreen ;https://superuser.com/questions/94620/remote-desktop-doesnt-maximize-to-fullscreen ;Try CTRL+ALT+BREAK - which switches the client between full-screen mode and window mode. ;https://learn.microsoft.com/en-us/windows/win32/termserv/terminal-services-shortcut-keys ;--- ;When you launch RDP dialog and before you logon/connect to the remote computer, select the Display Tab and set your display configuration. ;If you want full screen mode, set the slider all the way to the right. Global $sCoords[4] = [10, 10, 40, 170] While 1 ;use infinite loop since ExitLoop will get called Global $Match1 = _MatchPicture($sOpenCVDir & "\Match\0000.png", 0.70, $sCoords, 1, 1000);Try to find the match picture on the screen. Number of tries: 10, Sleep between each try: 500ms. If @error Then Sleep(100) ExitLoop EndIf ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "^!{BREAK}") = 1 Then _FileWriteLog($hFile, "OK ControlSend: ^!{BREAK}") Else _FileWriteLog($hFile, "Error ControlSend: ^!{BREAK}") EndIf $RestoreBreak = True Sleep(2000) WEnd EndFunc Func _RDPClose($iLine) If Not WinActive($hWnd, "") Then WinActivate($hWnd) WinWaitActive($hWnd, "", 10) WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(3000) EndIf ;Test if the window is now activated ;You can use the WinActive() function to check if WinActivate() succeeded. If WinActive($hWnd, "") Then ;WinSetState($hWnd, "", @SW_MAXIMIZE) ;MsgBox(0, "", "Window NOW active") Sleep(2000) _CheckFullScreen() ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#r") = 1 Then ;_FileWriteLog($hFile, "OK ControlSend: #r [" & $iLine & "]") Sleep(2000) If ControlSend($hWnd, "", "", "shutdown -L") = 1 Then ;_FileWriteLog($hFile, "OK ControlSend: shutdown -L [" & $iLine & "]") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Else SetError(2) ;_FileWriteLog($hFile, "Error ControlSend: shutdown -L [" & $iLine & "]") EndIf Else SetError(1) ;_FileWriteLog($hFile, "Error ControlSend: #r [" & $iLine & "]") EndIf Sleep(5000) EndIf EndFunc Func _ProcessClean($iLine) If Not WinActive($hWnd, "") Then WinActivate($hWnd) WinWaitActive($hWnd, "", 10) WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(3000) EndIf ;Test if the window is now activated ;You can use the WinActive() function to check if WinActivate() succeeded. If WinActive($hWnd, "") Then ;WinSetState($hWnd, "", @SW_MAXIMIZE) ;MsgBox(0, "", "Window NOW active") Sleep(2000) ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#r") = 1 Then _FileWriteLog($hFile, "OK ControlSend: #r [" & $iLine & "]") Sleep(2000) If ControlSend($hWnd, "", "", "TASKKILL /F /IM A3_SOME-2.EXE") = 1 Then _FileWriteLog($hFile, "OK ControlSend: TASKKILL /F /IM A3_SOME-2.EXE [" & $iLine & "]") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Else SetError(2) _FileWriteLog($hFile, "Error ControlSend: TASKKILL /F /IM A3_SOME-2.EXE [" & $iLine & "]") EndIf Else SetError(1) _FileWriteLog($hFile, "Error ControlSend: #r [" & $iLine & "]") EndIf Sleep(5000) ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#r") = 1 Then _FileWriteLog($hFile, "OK ControlSend: #r [" & $iLine & "]") Sleep(2000) If ControlSend($hWnd, "", "", "TASKKILL /F /IM A3_SOME.EXE") = 1 Then _FileWriteLog($hFile, "OK ControlSend: TASKKILL /F /IM A3_SOME.EXE [" & $iLine & "]") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Else SetError(2) _FileWriteLog($hFile, "Error ControlSend: TASKKILL /F /IM A3_SOME.EXE [" & $iLine & "]") EndIf Else SetError(1) _FileWriteLog($hFile, "Error ControlSend: #r [" & $iLine & "]") EndIf Sleep(5000) ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#r") = 1 Then _FileWriteLog($hFile, "OK ControlSend: #r [" & $iLine & "]") Sleep(2000) If ControlSend($hWnd, "", "", "TASKKILL /F /IM EXCEL.EXE") = 1 Then _FileWriteLog($hFile, "OK ControlSend: TASKKILL /F /IM EXCEL.EXE [" & $iLine & "]") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Else SetError(2) _FileWriteLog($hFile, "Error ControlSend: TASKKILL /F /IM EXCEL.EXE [" & $iLine & "]") EndIf Else SetError(1) _FileWriteLog($hFile, "Error ControlSend: #r [" & $iLine & "]") EndIf Sleep(2000) ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#r") = 1 Then _FileWriteLog($hFile, "OK ControlSend: #r [" & $iLine & "]") Sleep(2000) If ControlSend($hWnd, "", "", "TASKKILL /F /IM SOME.EXE") = 1 Then _FileWriteLog($hFile, "OK ControlSend: TASKKILL /F /IM SOME.EXE [" & $iLine & "]") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Else SetError(2) _FileWriteLog($hFile, "Error ControlSend: TASKKILL /F /IM SOME.EXE [" & $iLine & "]") EndIf Else SetError(1) _FileWriteLog($hFile, "Error ControlSend: #r [" & $iLine & "]") EndIf Sleep(2000) ;https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop If ControlSend($hWnd, "", "", "#d") = 1 Then _FileWriteLog($hFile, "OK ControlSend: #d [" & $iLine & "]") Else SetError(1) _FileWriteLog($hFile, "Error ControlSend: #d [" & $iLine & "]") EndIf Sleep(2000) EndIf EndFunc Func OnAutoItExit() If WinExists("__._._._ - Conexión a Escritorio remoto") Then If Not WinActive($hWnd, "") Then WinActivate($hWnd) WinWaitActive($hWnd, "", 10) WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(5000) EndIf ;Test if the window is now activated ;You can use the WinActive() function to check if WinActivate() succeeded. If WinActive($hWnd, "") Then ;WinSetState($hWnd, "", @SW_MAXIMIZE) ;MsgBox(0, "", "Window NOW active") _RDPClose(@ScriptLineNumber) EndIf EndIf _OpenCV_Shutdown();Closes DLLs ;_CFS_ReleaseSemaphore($logfile) FileClose($hFile) If $CleanLog Then FileRecycle($sFilePathLog) If $RestoreBreak Then ;google keywords: restore pause break key vba ;https://stackoverflow.com/questions/2154699/excel-vba-app-stops-spontaneously-with-message-code-execution-has-been-halted Send("{CTRLDOWN}{BREAK}{CTRLUP}") EndIf EndFunc Include.7z
    1 point
  4. Its quite simple: "RDP is like a video you can click an type". Unless you run your code from within the remote desktop, "RDP is like a video you can click an type". You'll be limited to whatever an image would allow. As far as forum rules, each time you type forum rules, the forum will add a link to the string. I hope you understand that am not judging your character, just stating the limitation that, by doing a search in the forum you'll see, there is not much that can be done. Good luck with your code and if you do in fact find a solution, share the code
    1 point
  5. Nine

    Question about listview

    @lucio69f Alright, I must admit that the link I gave you was NOT the best I could give you. So I made a minimalist example to show you how to display color easily in ListView: #include <GUIConstants.au3> #include <GuiListView.au3> Global $hListView, $aColors[3][3] _Example() Func _Example() Local $hGUI = GUICreate("Colored ListView", 350, 250) Local $idListView = GUICtrlCreateListView("Number|Number|Number", 5, 5, 300, 150) $hListView = GUICtrlGetHandle($idListView) GUICtrlCreateListViewItem('1|1|1', $idListView) GUICtrlCreateListViewItem('2|2|2', $idListView) GUICtrlCreateListViewItem('3|3|3', $idListView) ; set background colors $aColors[0][1] = 0xFFAAFF $aColors[1][2] = 0x00AA00 $aColors[2][0] = 0xCCCCCC GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Example Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch $tNMHDR.hWndFrom Case $hListView Switch $tNMHDR.Code Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = $tCustDraw.dwDrawStage If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = $tCustDraw.iSubItem Local $iItem = $tCustDraw.dwItemSpec If $aColors[$iItem][$iSubItem] Then $tCustDraw.clrTextBk = $aColors[$iItem][$iSubItem] Else $tCustDraw.clrTextBk = 0xFFFFFF EndIf Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Hope that helps a bit more. MSDN has all the info that you need to understand the process of owner drawing a list view.
    1 point
×
×
  • Create New...