Leaderboard
Popular Content
Showing content with the highest reputation on 04/12/2018 in all areas
-
If the subject string actually contains extended ASCII characters of some ANSI codepage that are not mapped identically in Unicode, then they can only be filtered in/out using their Unicode codepoint value or directly using the literal character itself. Re-using the OP code both examples below work: #include <Array.au3> $buf = "First title" & @CRLF & "Tom" & Chr(0x92) & "s sleepwalking" & @CRLF & "Last | line" & @CRLF $items = StringRegExp($buf, '([\x20-\xff\x2019]+)\x0d\x0a', 3) _ArrayDisplay($items,'') $items = StringRegExp($buf, '([\x20-\xff’]+)\x0d\x0a', 3) _ArrayDisplay($items,'') Of course if the goal is to split the input on line breaks, using a regexp like this is both an overkill and prone to failure. StringSplit would do the job fine, as well as $items = StringRegExp($buf, '(.*)\R', 3) Last note: given the fact that many distinct single or double Unicode quotes, apostrophes and prime (and accents and diacritics !!!) are very closely similar-looking despite having different codepoints, I recommend being very careful not to confuse between them. To wit (and I didn't put them all): '´ʹʼʽʻʾʿ̀`ՙ՝᾿῀´῾‘’‛“”‟′″‴‵‶‷ Have fun telling which is which just by looking! .2 points
-
TeraCopy Timer updated to v2.5. See first post. (v2.5) Added support for multiple drag & drop in MINimum mode, thanks to a Lazycat example from 2006. Multiple files/folders can be added either as individual jobs or combined as a single job per drop. Kudos Lazycat. Latest Screenshots NOTES - This has been a somewhat complex undertaking this update, so for those like Earthshine who have adapted an earlier version for Robocopy etc (which hopefully he will share here soon ), there may be an issue in regard to processing a list of file paths.2 points
-
method for interaction with hidden window(s)
marcus_tong reacted to garbb for a topic
Here is a method for running a windows application (that may create any number of windows) completely hidden while still being able to interact with it with autoit (controlsend(), controlclick(), etc...) and get a screencap of any of the windows. Basically this is accomplished by running the application on a hidden desktop (credit to Decipher) and then running a separate instance of autoit also on the hidden desktop to interact with the application. This is kind of a goofy hack, but it seems to work. hiddenDesktopInteract.au3: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPI.au3> #include <WinAPIEx.au3> #include <GDIPlus.au3> ;1st command line param that will launch seperate instance Const $hdiParam = 'hiddenDesktopInteract' ;######DO NOT PUT ANY OTHER CODE ABOVE THIS THAT CALLS A 2ND INSTANCE OF THE SCRIPT OR ELSE YOU MAY END UP CALLING INFINITE INSTANCES AND CRASHING WINDOWS!!!!!! ;seperate process for hidden desktop interaction ;1st param should be 'hiddenDesktopInteract' and 2nd param is name of func to call for interaction code ;ex: "autoit.exe script.au3 hiddenDesktopInteract interactionfunc" or "compiledscript.exe hiddenDesktopInteract interactionfunc" if $CmdLine[0] = 2 AND $CmdLine[1] = $hdiParam Then EXIT Call($CmdLine[2]) ;credit to Decipher in thread https://www.autoitscript.com/forum/topic/152515-start-a-process-hidden/#comment-1095173 for code for running process on a hidden desktop Func _hiddenDesktopInteract_run($sProgram, $sInteractionFunc, $sCommand = '') ;if the interaction function does not exist then don't do anything If Not IsFunc(Execute($sInteractionFunc)) Then ConsoleWrite('error: interaction function "' & $sInteractionFunc & '" for "' & $sProgram & '" does not exist' & @CRLF) Return EndIf ;create structs Local $tStartupInfo = DllStructCreate($tagStartupInfo) DllStructSetData($tStartupInfo, "Size", DllStructGetSize($tStartupInfo)) Local $tProcessInfo_targetApp = DllStructCreate($tagPROCESS_INFORMATION) Local $tProcessInfo_interactionScript = DllStructCreate($tagPROCESS_INFORMATION) ; Create Desktop Local $hDesktop = _WinAPI_CreateDesktop('AutoItHidden', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP)) If Not $hDesktop Then MsgBox(0, 'Error', 'Unable to create desktop.') Exit EndIf ; Prep Process Info Local $nSuccess = DllStructSetData($tStartupInfo, "Desktop", _WinAPI_CreateString("AutoItHidden")) ;run target program on hidden desktop and get PID _WinAPI_CreateProcess('', '"' & $sProgram & '"' & ($sCommand ? ' ' & $sCommand : ''), 0, 0, 0, 0x00000200, 0, 0, DllStructGetPtr($tStartupInfo), DllStructGetPtr($tProcessInfo_targetApp)) Local $aPID_targetApp = DllStructGetData($tProcessInfo_targetApp, 'ProcessID') ConsoleWrite('!>target app PID:' & $aPID_targetApp & @CRLF) ;run instance of this script on hidden desktop to interact with target program Local $sParams = '"' & @ScriptFullPath & '" ' & $hdiParam & ' ' & $sInteractionFunc Switch @Compiled case True Local $sAppName = @ScriptFullPath Local $sCommandLine = $sParams case False Local $sAppName = @AutoItExe Local $sCommandLine = '"' & @AutoItExe & '" ' & $sParams EndSwitch _WinAPI_CreateProcess('', $sCommandLine, 0, 0, 0, 0x00000200, 0, 0, DllStructGetPtr($tStartupInfo), DllStructGetPtr($tProcessInfo_interactionScript)) ;and get PID of interaction instance so we can wait until it is finished Local $iPID_interactionScript = DllStructGetData($tProcessInfo_interactionScript, 'ProcessID') ConsoleWrite('!>Interaction Script PID: ' & $iPID_interactionScript & @CRLF) ;wait until interaction script instance is finished and get exit code (which is return value from interaction function) ProcessWaitClose($iPID_interactionScript) Local $exitcode_interactionScript = @extended ConsoleWrite("!>Interaction Script Exit Code: " & $exitcode_interactionScript & @CRLF) Local $sOutput = StdoutRead($iPID_interactionScript) ConsoleWrite("!>Interaction Script Stdout: " & $sOutput & @CRLF) ;close hidden desktop Local $aRet = DllCall("User32.dll", "int", "CloseDesktop", "handle", $hDesktop) ConsoleWrite("!>Close Desktop: " & $aRet[0] & @CRLF) ; Non-Zero is successfull! Return $exitcode_interactionScript EndFunc Func _hiddenDesktopInteract_cap($title, $imgfile, $Left = 0, $Top = 0, $Right = -1, $Bottom = -1) _GDIPlus_Startup() $hWnd = WinGetHandle($title) $iWidth = _WinAPI_GetWindowWidth($hWnd) $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) $hBMPclone = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) if $Right = -1 then $iX = _GDIPlus_ImageGetWidth($hBMPclone) - $Left Else $iX = $Right - $Left EndIf if $Bottom = -1 then $iY = _GDIPlus_ImageGetHeight($hBMPclone) - $Top Else $iY = $Bottom - $Top EndIf ;convert from 32bit bitmap to 24bit bitmap b/c 32bit bitmap cannot display correctly in autoit GUI for some reason $hClone = _GDIPlus_BitmapCloneArea($hBMPclone, $Left, $Top, $iX, $iY, $GDIP_PXF24RGB) _GDIPlus_ImageSaveToFile($hClone, $imgfile) _WinAPI_DeleteObject($hBMP) _WinAPI_DeleteObject($hBMPclone) _WinAPI_DeleteObject($hClone) _GDIPlus_Shutdown() EndFunc hiddenDesktopInteract_EXAMPLES.au3: #include "hiddenDesktopInteract.au3" ;test function for interacting with notepad app on hidden desktop func notepadtest() opt('winwaitdelay', 0) ;to make it run a little bit faster WinWait('[CLASS:Notepad]') $hwin = WinGetHandle('[CLASS:Notepad]') ControlSend($hwin, '', '[CLASS:Edit; INSTANCE:1]', 'hello{ENTER}') WinMenuSelectItem($hwin, '', '&Edit', 'Time/&Date') _hiddenDesktopInteract_cap($hwin, @DesktopDir & '\notepad_cap.jpg') ControlSend($hwin, '', '[CLASS:Edit; INSTANCE:1]', '^a') ControlSend($hwin, '', '[CLASS:Edit; INSTANCE:1]', '{DELETE}') WinClose($hwin) EndFunc ;test function for interacting with cmd.exe on hidden desktop func cmdtest() opt('winwaitdelay', 0) ;to make it run a little bit faster WinWait('[CLASS:ConsoleWindowClass]') $hwin = WinGetHandle('[CLASS:ConsoleWindowClass]') ControlSend($hwin, '', '', 'dir{ENTER}') sleep(500) _hiddenDesktopInteract_cap($hwin, @DesktopDir & '\cmd_cap.jpg') ControlSend($hwin, '', '', 'exit{ENTER}') EndFunc _hiddenDesktopInteract_run("notepad.exe", 'notepadtest') _hiddenDesktopInteract_run("cmd.exe", 'cmdtest') The example script demonstrates running a hidden instance of notepad and cmd.exe and interacting with it via controlclick() and controlsend() and then capturing a screencap of the window before closing it. I made this because some applications ignore the @SW_HIDE parameter when launching them and show a window anyways, and also because I wanted to be able to screencap windows while making them hidden so they wouldn't steal focus. To use this you must first write a function that will interact with the target application/window and then call _hiddenDesktopInteract_run() with the name of the application as the first parameter and the name of the function as the second parameter. You can also use _hiddenDesktopInteract_cap() within your function to store an image of the hidden window to a file. Because the way that this works is that ONLY the function that you specify will be run on the hidden desktop, you must make sure that your function does not depend on any variables/code that is outside of the function or it will fail. I was also trying to find some way to transfer information from the autoit instance that runs on the hidden desktop to the main instance of the script using consolewrite() and getting the stdout stream of the other instance but I couldn't figure it out. (I was looking at the code here but I couldn't get it to work) Maybe someone knows how to get it working... Right now the exit code of the hidden desktop autoit instance is used to transfer the return code of the function but this only works with integers and so isn't really a good method. Anyways, I hope this will be useful for someone. Or maybe someone knows a better/less hacky way to achieve the same thing... Tested with autoit 3.3.14.2 on Windows 7 64bit SP1 and Windows 10 64bit 1511 (OS Build 10586.164) hiddenDesktopInteract.au3 hiddenDesktopInteract_EXAMPLES.au31 point -
CMD Click or Action
Earthshine reacted to Jos for a topic
You seriously don't get it ...do you? You haven't given any information yet and yet expect help. I am done and leave it to other to start with the guessing game ... ... ah it started already.1 point -
Automating Calculator for windows 10
Earthshine reacted to junkew for a topic
In examples section thread iuiautomation you can download the examples (and the udf) and there is a calculator+notepad demo within the first few examples.1 point -
Problem with regexp after updating autoit
boomingranny reacted to jchd for a topic
Guys, you mix ANSI and Unicode codepoints. AutoIt strings are native Unicode (well almost). Indeed, Chr(0x92) translates into the character Prime RIGHT SINGLE QUOTATION MARK, hex Unicode codepoint 0x2019 (using the western latin codepage): ConsoleWrite(Hex(AscW(Chr(0x92))) & @LF) It's the same issue with a number of "extended ANSI" characters, which depend on the ANSI codepage in force. That's the whole point for inventing Unicode, first published in 1991. PCRE in AutoIt handles Unicode strings since version 3.3.10.0 (23rd December, 2013) (Release) as changelog says. EDIT: actually the official name of Unicode codepoint U2019 is "RIGHT SINGLE QUOTATION MARK" and glyph looks like this < ’ >. The name "PRIME" refers to codepoint U2032 and its glyph looks like this: < ′ >, pretty much the same visually.1 point -
Its best practice not to use Dim when declaring variables, but use Local or Global. Below is a basic explanation of how variables are viewed with AutoIt. ;~ This following three variables are all within the Global scope range aka able to be seen by all functions Global $sVariable = "String" $hVariable = WinGetHandle("title", "text") ;~ Declaring Local Variable in Global scope would also be treated like a Global variable Local $iVariable = 1 Func _Example() ;~ The following example is within the Local scope range aka only able to be seen by the "Example" function Local $aVariable[1] = ["Array"] $bVariable = True ;~ NOTE: It is best practice not declare Global variables within functions EndFunc1 point
-
Holy crap I think I just found it.. Func _IsMoreRecentBackup($sCompareTime) Local $sPath = $SERVER_DIR & '\backups\', $hSearch, $sFile, $sFileTime, $sReturnTime If FileExists($sPath) Then $hSearch = FileFindFirstFile($sPath & '*.zip') While $hSearch <> -1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $sFile > $sCompareTime Then Return True WEnd FileClose($hSearch) EndIf EndFunc I just realized that this function is leaving open file handles. And it's called from the main loop. And you were right to hesitate John, the part of the code that calls this was disabled in the code I posted above, so running it (as I have been for the last ~20 hours) would produce no errors. Gosh I feel like a complete heel. Time to correct, compile, and test.1 point
-
Just want to inform you that a new hotfix update for version 1.07 is out now! Fixes: - Fixed error jumping reported by Rex (Also marks now the "selected" error in the console output window) - API update to AutoIt 3.3.14.4 - .exe files are now compiled with AutoIt 3.3.14.4 - Updated French translation (thx to Swirti) - Updated "Testproject" - Litte new feature: If you write a new include, autocomplete show you now the autoit includes (when you type #include <) OR files from your project (when you type #include ")1 point
-
Why array variable do not work with _IEQuit?
oemript reacted to boomingranny for a topic
First example: local creates the variable called $oIE1, then the bit after the = assigns its value The second example does the same thing, (but called $oIE2) if the variable isn't already created then AutoIT automatically creates it. AutoIT sees the code $oIE2, and sees there isn't a variable with that name yet, so it goes ahead and makes a new variable called $oIE2 dim global and local all create variables or arrays of variables. This page explains it in further detail: https://www.autoitscript.com/autoit3/docs/keywords/Dim.htm The problem with your first post's code is that you already made the array $aOIE you then tried to declare an array called $aOIE with the size of [$Item_No] If you want to recreate/resize your array (which I don't think is what you were trying to do) you can use redim (https://www.autoitscript.com/autoit3/docs/keywords/ReDim.htm) To help understand this concept better, If you use Opt("MustDeclareVars",1) at the start of your script, you will be forced to declare every variable you use (similar to some other programming languages) you will then better appreciate the use of dim/global/local.1 point