Jump to content

Marc

Active Members
  • Posts

    314
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Marc

  1. Well I just thought „how should the command look like if entered on the command line“ and came tobte conclusion of „out every Parameter in „“ and to be sure it is correct I added the consolewrite to see the result🙃
  2. If I'm not mistaken, that's just what the code does... If you replace the line Local $Result = ShellExecuteWait('REG', 'EXPORT " ' & $_sRegKey[$i] & '" ' & $_RegFile[$i] & '') with my code, you'll get: ; ------------------------------------------------ #include <FileConstants.au3> ; ------------------------------------------------ Opt("MustDeclareVars", 1) ; ------------------------------------------------- _ExportRegKeys() ; ------------------------------------------------- Func _ExportRegKeys() ; Source data Local $_sRegKey[3] = [2] $_sRegKey[1] = "HKEY_CURRENT_USER\Software\Native Instruments" $_sRegKey[2] = "HKEY_LOCAL_MACHINE\Software\Native Instruments" ; ----------------- ; Destination data Local $_RegFile[3] = [2] $_RegFile[1] = "D:\Install\App_Config\Digital_Audio\2_GR5\Data\Reg_Keys\hkcu.reg" $_RegFile[2] = "D:\Install\App_Config\Digital_Audio\2_GR5\Data\Reg_Keys\hklm.reg" ; ------------------------------------------------- Local $sMessage = "Export Registry Keys data..." & @CRLF & @CRLF ; ------------------------------------------------- For $i = 1 To $_RegFile[0] Local $tmp = 'EXPORT "' & $_sRegKey[$i] & '" "' & $_RegFile[$i] & '" /Y' Local $Result = ShellExecuteWait('REG', $tmp) ConsoleWrite($tmp & @CRLF) Switch $Result Case 0 $Result = "The Registry Keys data...[" & $_RegFile[$i] & "]...was exported sucessfully!" Case 1 $Result = "The Registry Keys data...[" & $_RegFile[$i] & "]...was not exported sucessfully!" EndSwitch ; ----------------- $sMessage &= $Result & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Export Registry Keys completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("NOTICE!!", $sMessage, 1050, 170, -1, -1, 4, "FuturaBQ-DemiBold", 14) Sleep(3000) SplashOff() EndFunc ;==>_ExportRegKeys ; ------------------------------------------------- and it seems to work fine. It displays the "successfully" message and two .reg files are created at the given location. And it uses the /y because it overwrites the files without asking if they are already there. ¯\_(ツ)_/¯ best regards, Marc
  3. Hi mr-es335, here's one possible solution. Using an array with 3 Columns - Source, Destination and Mode. If you don't need to copy one file and move the other file, you could make this thing easier to maintain. Kick out the last column and check if the Source is a file or a directory and then choose the appropriate action. #include <FileConstants.au3> Opt("MustDeclareVars", 1) _UpdateUserData() Func _UpdateUserData() ; Array with source paths, destination paths, and operation type (1 = DirCopy, 2 = FileCopy, 3 = FileMove) Local $aFileOperations[4][3] = [ _ ["D:\Install\App_Install\Digital_Audio\2_GR5\Assets\Tapedeck", "C:\Program Files\Common Files\Native Instruments\Guitar Rig 5\Content\Tapedeck", 1], _ ["D:\Install\App_Install\Digital_Audio\2_GR5\Assets\User_Impulses", "C:\Program Files\Native Instruments\Reflektor\User_Impulses", 1], _ ["C:\RML\SAC\VST_PlugIns\Guitar Rig 5.dll", "C:\RML\SAC\VST_PlugIns\Ampsim\", 3], _ ["D:\Install\App_Install\Digital_Audio\2_GR5\Assets\Ampsim.ini", "C:\RML\SAC\VST_PlugIns", 2] _ ] SplashTextOn("NOTICE!!", "Update User data...", 350, 50, -1, -1) Sleep(1000) ; Perform copy/move operations with error handling For $i = 0 To UBound($aFileOperations) - 1 Local $result = 0 ; Determine the operation type based on the third column Switch $aFileOperations[$i][2] Case 1 ; DirCopy $result = DirCopy($aFileOperations[$i][0], $aFileOperations[$i][1], $FC_OVERWRITE) Case 2 ; FileCopy $result = FileCopy($aFileOperations[$i][0], $aFileOperations[$i][1], $FC_OVERWRITE) Case 3 ; FileMove $result = FileMove($aFileOperations[$i][0], $aFileOperations[$i][1], $FC_OVERWRITE + $FC_CREATEPATH) EndSwitch ; Error handling If $result = 0 Then MsgBox(16, "Error", "Failed to process: " & $aFileOperations[$i][0]) Else ConsoleWrite("Successfully processed: " & $aFileOperations[$i][0] & @CRLF) EndIf Next SplashTextOn("NOTICE!!", "Update User data completed...", 350, 50, -1, -1) Sleep(1000) SplashOff() EndFunc ;==>_UpdateUserData best regards, Marc P.S: this code is powered by ChatGPT 😏
  4. Hi, mr-es335, to #1: I like to see the created command, so I extracted the parameters in a separate variable and wrote it to console. Makes it more visible to see what actually happens. Works quite fine this way. even with /y: Local $tmp = 'EXPORT "' & $_sRegKey[$i] & '" "' & $_RegFile[$i] & '" /Y' Local $Result = ShellExecuteWait('REG', $tmp) ConsoleWrite($tmp & @CRLF) to #2: Looks quite stable to me. best regards, Marc
  5. Not really sure what you want to achieve. If you want the copied bytes displayed in MB/GB then take a look ath the lines GUICtrlSetData($lbl_bytes, $str_done_bytes & " of " & $str_total_bytes & " (" & StringFormat("%.2f", $percent_bytes) & "%)") you could use the function from guinnes here instead to format the value. best regards, Marc
  6. Darn! Ooookay, Put it on the "stupid idiot"-list,.. Invoking your Scite-Editor manually does everything right. I'm always using the "total commander" filemanager. Several years ago I wrote a launcher to decide which editor to use depending on the file extension. Which contains a funny bug... 🤦‍♂️ Embarassing.
  7. Yepp, it fails with my testfile. Downloaded the original scite and go not problems when editing it. Here's what I see when opening first in original scite and after that in the latest Scite4AutoIt (destroying it): Some things I checked: Original file starts with 26 69 6e 63 6c 75 defect file starts with ef bb bf 63 75 - seems like the first 3 bytes are simply overwritten with the UTF-8 Header renaming the Folder AppData\Local\AutoIt v3\SciTE\ does not change anything in this behaviour after re-adding the overwritten "#in" and saving the file, it stays fine Notepad++ detects my testfile as "UTF" and the file after saving it with the Scite4AutoIt-Editor as "UTF-8-BOM" hope this helps...
  8. Hi Jos, took the files from your zip and replaced the files from c:\Program Files (x86)\AutoIt3\SciTE\ with the contents. Help now says: 32-bit Version 5.3.5 Scintilla:5.3.4 Lexilla:5.2.4 Apr 8 2023 19:51:08 But: same result as before. As it seems to happen only on my system, perhaps I screwed up some config files...?
  9. It says: 32-bit Version 5.3.5 Scintilla:5.3.4 Lexilla:5.2.4 Apr 2 2023 16:03:32 by Neil Hodgson. Updated by Jos
  10. I'm using the setup-file from your post it's the 23.402.1150.0.15 Installer, to be more precise. Should I overwrite it with a different version? SciTEUser.properties
  11. Hm, am I the only onle having the issue that the first 3 characters of each file get cut off when editing it? Have an existing .au3 which starts with "#Region". When opening it in the new Scite, it starts with "gion", and the file immediatley gets saved with the first 3 Chars cut of. Re-Adding the "#Re" and saving, the file on the disk is fine and works, untit I dare to open it in Scite again... I'm sure it has to do with BOM... Re-installed the old version, everything's fine.
  12. thank you very much - and happy new year to all, too
  13. Hi all, here's a test snippet from a script I use daily. Worked fine, until roundabout last week. Problem is: I am checking for the next comic on the webpage. If the comic does not yet exist, the sourcecode contains the text <h1>404 Error</h1>. At least, that's the result in the Webbrowser. But I get a different sourcecode when using the edge browser or _InetGetSource. Especially the 404 Error-Tag is missing. Tried it with several variations of the UserAgent (my old value is "Mozilla / 5.0"). #include <INet.au3> ;HttpSetUserAgent('Mozilla / 5.0') HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0') ;HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36') ; HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36') $result = lfg(1985) MsgBox(0,"lfg", $result) Func lfg($start) $name = "lfg" & $start $x = _INetGetSource("http://www.lfg.co/page/" & $start & "/") ClipPut($x) If StringInStr($x, "<h1>404 Error</h1>") Then Return 404 Return "nope" EndFunc ;==>lfg Desired result of the test-script: a messagebox with 404. Current result of the test script: "nope". Any ideas what I'm doing wrong? best regards, Marc
  14. "Microsoft 365" (that's the current name as of 2022-12-04, may change ^^) still offers a standard installation of the software on your PC. Seems to work fine
  15. released a much newer version in the first post.
  16. Hm, the cause seems to be simple: StringBetween is doing what it should - it returns the text between your <div class="accordion-item"> and the first </div> without including the search-texts itself. So you'd need to find another end-string or solve it via regex. in your case, you could #include <String.au3> Global $HTML_Test $HTML_Test &= '<div class="accordion-item">' & @CRLF ; <!---- START GET--> $HTML_Test &= ' <div class="accordion-inner">' & @CRLF $HTML_Test &= ' <p>Khoá an toàn giúp bếp luôn được an toàn</p>' & @CRLF $HTML_Test &= ' </div>' & @CRLF $HTML_Test &= ' <a href="#" class="accordion-title plain">' & @CRLF $HTML_Test &= ' <button class="toggle">' & @CRLF $HTML_Test &= ' <i class="icon-angle-down"></i>' & @CRLF $HTML_Test &= ' </button>' & @CRLF $HTML_Test &= ' <span>Khoá an toàn</span>' & @CRLF $HTML_Test &= ' </a>' & @CRLF $HTML_Test &= '</div>' & @CRLF ;<!---- END GET --> Global $aSearch = _StringBetween($HTML_Test, '<div class="accordion-item">', '</a>' & @CRLF & '</div>') If IsArray($aSearch) Then For $i = 0 To UBound($aSearch) - 1 ConsoleWrite('!-> SB Return: ' & $aSearch[$i] & @CRLF) Next Else ConsoleWrite('! SB: No strings found. ' & @CRLF) EndIf so you'll get the inner text. Of course the closing </a> gets lost because it is included in the $sEnd-String. Or with a regex: #include <String.au3> Global $HTML_Test $HTML_Test &= '<div class="accordion-item">' & @CRLF ; <!---- START GET--> $HTML_Test &= ' <div class="accordion-inner">' & @CRLF $HTML_Test &= ' <p>Khoá an toàn giúp bếp luôn được an toàn</p>' & @CRLF $HTML_Test &= ' </div>' & @CRLF $HTML_Test &= ' <a href="#" class="accordion-title plain">' & @CRLF $HTML_Test &= ' <button class="toggle">' & @CRLF $HTML_Test &= ' <i class="icon-angle-down"></i>' & @CRLF $HTML_Test &= ' </button>' & @CRLF $HTML_Test &= ' <span>Khoá an toàn</span>' & @CRLF $HTML_Test &= ' </a>' & @CRLF $HTML_Test &= '</div>' & @CRLF ;<!---- END GET --> ; Global $aSearch = _StringBetween($HTML_Test, '<div class="accordion-item">', '</a>' & @CRLF & '</div>') $aSearch = StringRegExp($HTML_Test, '(?s)<div class="accordion-item">(.*)</div>',3) If IsArray($aSearch) Then For $i = 0 To UBound($aSearch) - 1 ConsoleWrite('!-> SB Return: ' & $aSearch[$i] & @CRLF) Next Else ConsoleWrite('! SB: No strings found. ' & @CRLF) EndIf best regards, Marc
  17. $text = StringRegExpReplace($text,"(?s)(CPU.*?°C).*", "$1") Try this way
  18. Without trying it by myself: the ps1 file writes to the relative path ".\process.txt" So, try to give the run command the right directory. as working directory or change the .ps1 to use an absolute path like "out-file -FilePath c:\test\process.txt
  19. You could use a logging UDF like Loga. It allows two ways: it print its debug messages into the console, but at the same time into a logfile. Which you could open and watch on your 2nd monitor, preferrably using a tool which constantly displays new lines of the file. I think LogExpert should do the job (untested) it allows to have its own outpout windows, see example 09 of the udf.
  20. You can simply use _FilePrint #include <File.au3> _FilePrint ("c:\file.txt") and of course, run this script at whatever time(s) you want using the task scheduler.
  21. @Danp2 Not in this specific case, because at my day job, the browser is forced to delete all cookies after closing. Okay, I'll try to automate it the old way using MouseClick. Update: _WD_Navigate($sSession, "https://www.gmx.net/pro_ssl/?origin=lpc") _WD_LoadWait($sSession) Sleep(1400) MouseClick("Left", 678, 980) Sleep(700) Sometimes, oldschool is still the easiest way
  22. Hi, I suppose it's only a minimal thing I am missing, but I just can't get it done. Goal of the script: open this webpage and close the stupid cookie-banner. Main problem is, that (at least according to SelectorsHub) the cookie banner is a cross origin iframe. So I tried to activate this iframe to dive into it and select the button. For your amusement, here are my futile attempts: #include "wd_core.au3" #include "wd_helper.au3" Global $sSession Global $_WD_DEBUG = $_WD_DEBUG_None Func searcher() $sElement = _WD_GetElementById($sSession, "save-all-conditionally") If @error Then ConsoleWrite("!Not found with _WD_GetElementById" & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='save-all-conditionally']") If @error Then ConsoleWrite("!Not found with XPath + ID" & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Zustimmen und weiter')]") If @error Then ConsoleWrite("!Not found with XPath + Text" & @CRLF) Else ConsoleWrite("+Found with XPath + Text" & @CRLF) EndIf Else ConsoleWrite("+Found with XPath + ID" & @CRLF) EndIf Else ConsoleWrite("+Found with _WD_GetElementById" & @CRLF) EndIf _WD_FrameLeave($sSession) EndFunc _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose') _WD_Startup() $sSession = _WD_CreateSession('{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}}}}') _WD_Navigate($sSession, "https://www.gmx.net/pro_ssl/?origin=lpc") _WD_LoadWait($sSession) Sleep(500) ; first try with native XPath $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='overlay']") if @error Then ConsoleWrite("!Peng" & @CRLF) _WD_FrameEnter($sSession, $sElement) searcher() ; ; after that, try all iframes $x = _WD_GetFrameCount($sSession) For $i = 0 To $x - 1 ConsoleWrite("Frame: " & $i & @CRLF) _WD_FrameEnter($sSession, $i) if @error Then ConsoleWrite("!Peng" & @CRLF) searcher() Next _WD_DeleteSession($sSession) _WD_Shutdown() *sigh* best regards, Marc
  23. Your Regex works fine, me thinks: $sConsole = "Transferred: 243.269M / 3.341 GBytes, 7%, 72.603 MBytes/s, ETA 43s" $result = StringRegExp($sConsole, "\h*\d+%", 3) ConsoleWrite("Result: " & $result[0] & @CRLF) Text from console Output: "Result: 7%"
×
×
  • Create New...