Jump to content

mistersquirrle

Active Members
  • Posts

    406
  • Joined

  • Last visited

  • Days Won

    7

Community Answers

  1. mistersquirrle's post in Always on top feature was marked as the answer   
    Another option if it's a GUI that you're creating is to use the ExStyle for $WS_EX_TOPMOST:
    #include <WindowsConstants.au3> #include <GUIConstants.au3> Global $hGui = GUICreate('Au3Gui', 200, 100, -1, -1, -1, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $hGui) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGui) Exit EndSwitch WEnd  
  2. mistersquirrle's post in delayed function was marked as the answer   
    Indeed, you'll need to show your code, as I have no issues/delays with launching a function with a hotkey:
    HotKeySet('\', '__Func') HotKeySet('{ESC}', '__Exit') While 1 Sleep(10) WEnd Func __Func() MsgBox(0,'Test','Test', 3) EndFunc Func __Exit() Exit EndFunc It might be possible that you have some other blocking function happening when you press the hotkey, so it's queued until it's able to actually process it.
  3. mistersquirrle's post in Using Task Scheduler for unattended execution - (Moved) was marked as the answer   
    Depends on what the job is, and how it's launched from Task Scheduler. If you run a task as a logged in user while the computer is unlocked, there's shouldn't be an issue.
    Otherwise for testing, just make your script log/write to a file for the steps that it's on, if it completed, if it was an error, etc. Then as Nine mentioned, you'll know when/where your script fails. You should always be handling and checking for errors, and you can likely get away with some of your actions completing and seeing what's possible and what isn't.
    Your (a) and (b) points shouldn't have an issue from Task Scheduler even if the computer is locked, as long as you're not anything in the link from ioa747. (c) will likely give you troubles if the computer is locked.
     
    https://www.autoitscript.com/autoit3/docs/libfunctions/_FileWriteLog.htm should be very useful for you logging your script.
  4. mistersquirrle's post in Play a sound file with SoundPlay Does not work. was marked as the answer   
    Why are you using @WindowsDir? Keep in mind that that's a macro used to point to your Windows folder, so for me it's: C:\WINDOWS
    This means your paths are:
    C:\WINDOWS\media\tada.wav C:\WINDOWSD:\MyFolder\Example\sound.wav That first one should be correct, but the second one definitely isn't. Does "D:\MyFolder\Example\sound.wav" work without @WindowsDir?
    Also, you may have whatever process is playing the sound muted in your Volume Mixer. I would try playing the sound in a loop and look at the volume mixer for what's the playing the sound and make sure it's not muted. The SoundPlay example for tada.wav worked for me.
  5. mistersquirrle's post in Keypress simulation with WinAPI functions directly was marked as the answer   
    I also tried some things with SendInput, and in the end I decided that it wasn't worth it, as I'm pretty sure that AutoIt's Send uses it (though I haven't confirmed, so if someone with more knowledge wants to correct me...). The main problem, and likely that problem that you're having is that SendInput doesn't work (with what you have here) in x64 mode. Your code works for me if you make sure it's running as x86 by putting this at the top of your script:
    #AutoIt3Wrapper_UseX64=n I messed around with SendInput for a while trying to get it work with 64-bit but couldn't. I got it to the point where DllCall did not return any errors, so it seemed like it and SendInput were happy with everything, but nothing happened.
    Maybe someone knows how to get SendInput working with 64-bit, but it wasn't worth it to me.
    Also, keep in mind that with your SendInput call, you're not sending the key back UP, it's only being pressed down. You should send the key back up as well:
    Global Const $KEYEVENTF_KEYUP = 0x0002 And from the Microsoft page on SendInput:
    This function is subject to UIPI [User Interface Privilege Isolation]. Applications are permitted to inject input only into applications that are at an equal or lesser integrity level Meaning you may want/need to add #RequireAdmin to your script as well.
  6. mistersquirrle's post in Subtract from a specific time to find out what time it was. was marked as the answer   
    Did you try my example? I think that it does what you want. I updated it slightly so that you can use hms as separators for the time instead of colons :.
    Here's the updated example:
    Global $sStartDate = @YEAR & "/" & @MON & "/" & @MDAY & " " & "05:44:15" Global $sEndDate = @YEAR & "/" & @MON & "/" & @MDAY & " " & "14:44:15" Global $iDifference = _DateDiff('s', $sStartDate, $sEndDate) ConsoleWrite('Seconds difference for comparison: ' & $iDifference & @CRLF) ConsoleWrite(@TAB & __MillisecondToTimestamp($iDifference, True) & @CRLF) ConsoleWrite(@TAB & __MillisecondToTimestamp($iDifference, True, False) & @CRLF) $sStartDate = @YEAR & "/" & @MON & "/" & @MDAY & " " & "05:44:15" $sEndDate = @YEAR & "/" & @MON & "/" & @MDAY & " " & "14:54:45" $iDifference = _DateDiff('s', $sStartDate, $sEndDate) ConsoleWrite('Seconds difference for second comparison: ' & $iDifference & @CRLF) ConsoleWrite(@TAB & __MillisecondToTimestamp($iDifference, True) & @CRLF) ConsoleWrite(@TAB & __MillisecondToTimestamp($iDifference, True, False) & @CRLF) Func __MillisecondToTimestamp($iMs, $bSeconds = False, $bColonSeparator = True) Local $sTimestamp If $bSeconds Then $iMs *= 1000 $iMs = Int($iMs, 0) ; Auto Int ; Convert the milliseconds to days, hours, minutes, and seconds $iDays = (($iMs >= 86400000) ? Int($iMs / 86400000) : 0) $iHours = Int(Mod($iMs, 86400000) / 3600000) $iMinutes = Int(Mod($iMs, 3600000) / 60000) $iSeconds = Int(Mod($iMs, 60000) / 1000) ; Format the timestamp as [DD ]hh:mm:ss.zzz ; Not using StringFormat here because it's considerably slower... when you do it 10K+ times, so probably doesn't matter at all for this $sTimestamp = _ ($iDays > 0 ? StringRight('0' & String($iDays), 2) & (($bColonSeparator) ? ' ' : 'd') : '') & _ StringRight('0' & String($iHours), 2) & (($bColonSeparator) ? ':' : 'h') & _ StringRight('0' & String($iMinutes), 2) & (($bColonSeparator) ? ':' : 'm') & _ StringRight('0' & String($iSeconds), 2) & _ ((Not $bSeconds) ? _ (($bColonSeparator) ? '.' : 's') & StringRight('00' & String($iMs), 3) & (($bColonSeparator) ? '' : 'ms') : _ (($bColonSeparator) ? '' : 's')) Return $sTimestamp EndFunc ;==>__MillisecondToTimestamp And here's the output:
    Seconds difference for comparison: 32400 09:00:00 09h00m00s Seconds difference for second comparison: 33030 09:10:30 09h10m30s You can change the separators in the function if you need it to be "H", "Min", "Sec". If you don't want the 0 padding, just change the second param of StringRight from 2 to 1.
  7. mistersquirrle's post in Running AutoIT Script in another machine was marked as the answer   
    It would be best if you could take at least the AutoIt Window Info tool onto the other system and check the class name, as that does seem like it could have some version information in it. However the best option would be to add some logging to a file into your script to run on the computer, or just run and debug the script on the other computer manually.
    You can also use RegEx in the class: https://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm
    For example:
    WinGetTitle('[REGEXPCLASS:WindowsForms\d+\.Window\.\d+\.app\.\d+\..*?') This should get you started, however this (if it does match anything) may not match the correct window, since it's now a very vague match for any window with a similar class. I suggest that you figure out where the problem is on the other computer first, then ask a more specific question.
  8. mistersquirrle's post in DllCall function behaving differently on 2 computers was marked as the answer   
    Are you sure that the DLL that you're opening is in the same location on both computers? Just compiling as EXE will take care of anything AutoIt related, so any #include files and all the AutoIt code/dependencies, but it will do nothing for any files that you're opening in the code, like your DLL. You can use FileInstall to include the DLL or other files into the EXE and that way you can carry them with the EXE.
    But, is the DLL available on both computers where the program is looking for it?
    And other dependencies I'm referencing are things that the DLL may rely on, such as Python or Visual Studio, which have nothing to do with AutoIt.
  9. mistersquirrle's post in What's needed to create _WinAPI_URLUnescape was marked as the answer   
    I'm not that familiar with DllStructs and calls myself, but I've been using them a bit lately, so I gave this a try. Check this out, it seems to work for me. I have a couple of test strings in there and they all do what's expected. For the first one, it should be run through the function until the StringLen doesn't change, so put a URL through it until there's no changes:
    #include <WinAPI.au3> Global $asUrls[] = [ _ 'https%253A%252F%252Flearn.microsoft.com%252Fen-us%252Fwindows%252Fwin32%252Fseccrypto%252Fcommon-hresult-values', _ 'https%3A%2F%2Fwww.autoitscript.com%2Fforum%2Ftopic%2F209966-whats-needed-to-create-_winapi_urlunescape%2F', _ '\vbnet%20code%20library\', _ 'https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-urlescapew' _ ] Global $sReturn For $iIndex = 0 To UBound($asUrls) - 1 $sReturn = _WinAPI_UrlUnescape($asUrls[$iIndex]) If @error Then ConsoleWrite('Error: ' & @error & @CRLF) Exit EndIf ConsoleWrite('Output ' & $iIndex & ': ' & $sReturn & @CRLF) Next Func _WinAPI_UrlUnescape($sUrl, $dFlags = 0) ; https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-urlunescapew Local $aUrlUnescape = DllCall("Shlwapi.dll", "long", "UrlUnescapeW", _ "wstr", $sUrl, _ ; PWSTR pszUrl - A pointer to a null-terminated string with the URL "wstr", "decodedUrl", _ ; PWSTR pszUnescaped - A pointer to a buffer that will receive a null-terminated string that contains the unescaped version of pszURL "dword*", 1024, _ ; DWORD *pcchUnescaped - The number of characters in the buffer pointed to by pszUnescaped "dword", $dFlags) ; DWORD dwFlags If @error Then ConsoleWrite('UrlUnescape error: ' & @error & ', LastErr: ' & _WinAPI_GetLastError() & ', LastMsg: ' & _WinAPI_GetLastErrorMessage() & @CRLF) Return SetError(@error, @extended, 0) EndIf If IsArray($aUrlUnescape) Then For $iIndex = 0 To UBound($aUrlUnescape) - 1 ConsoleWrite(' $aUrlUnescape[' & $iIndex & ']: ' & VarGetType($aUrlUnescape[$iIndex]) & ' - ' & $aUrlUnescape[$iIndex] & @CRLF) Next EndIf Return $aUrlUnescape[2] EndFunc ;==>_WinAPI_UrlUnescape  
    Edit: Note that there is nothing special about this line: "wstr", "decodedUrl", the "decodedUrl" can be anything, really, even just 0 works.
  10. mistersquirrle's post in How to click on a button was marked as the answer   
    Instead of 'Button1' for the ControlClick, try one of these:
    ControlClick($hWnd, '', 'Button', 'main', 1) ControlClick($hWnd, '', '[CLASS:Button; INSTANCE:1]', 'main', 1) ControlClick($hWnd, '', 1, 'main', 1) Alternatively, if it doesn't matter if you click Continue or Cancel you could try just using WinClose or WinKill, though I imagine Continue makes it skip over the current item and continue processing, so those may not be options for you.
  11. mistersquirrle's post in File Mass Rename loses Array Variable was marked as the answer   
    I suggest that you add some logging so you can see/watch the progress of it, and know when/where it fails:
    #include <GDIPlus.au3> #include <Array.au3> #include <File.au3> _GDIPlus_Startup() Global Const $sFolder = "C:\ItemsbyName\240x240\Organic" Global $FileList = _FileListToArray($sFolder, "*", $FLTA_FILES) If @error Then ConsoleWrite('_FileListToArray error: ' & @error & @CRLF) Exit EndIf Global $Total = $FileList[0] ConsoleWrite('$Total: ' & $Total & @CRLF) If FileExists($sFolder & "\New\") = 0 Then DirCreate($sFolder & "\New\") EndIf For $i = 1 To $Total $Filename = $FileList[$i] $Filename3 = "9" & $Filename ConsoleWrite('$Filename (' & $i & '/' & $Total & '): ' & $Filename & @CRLF) $hImage1 = _GDIPlus_ImageLoadFromFile($sFolder & '\' & $Filename) If @error Then ConsoleWrite('_GDIPlus_ImageLoadFromFile $hImage1 error: ' & @error & @CRLF) Exit EndIf $hImage2 = _GDIPlus_ImageLoadFromFile(@DesktopDir & "\organic.png") If @error Then ConsoleWrite('_GDIPlus_ImageLoadFromFile $hImage2 error: ' & @error & @CRLF) Exit EndIf $hGraphics1 = _GDIPlus_ImageGetGraphicsContext($hImage1) If @error Then ConsoleWrite('_GDIPlus_ImageGetGraphicsContext error: ' & @error & @CRLF) Exit EndIf _GDIPlus_GraphicsDrawImage($hGraphics1, $hImage2, 0, 0) If @error Then ConsoleWrite('_GDIPlus_GraphicsDrawImage error: ' & @error & @CRLF) Exit EndIf _GDIPlus_ImageSaveToFile($hImage1, $sFolder & "\New\" & $Filename3) If @error Then ConsoleWrite('_GDIPlus_ImageSaveToFile error: ' & @error & @CRLF) Exit EndIf _GDIPlus_GraphicsDispose($hGraphics1) If @error Then ConsoleWrite('_GDIPlus_GraphicsDispose error: ' & @error & @CRLF) Exit EndIf _GDIPlus_ImageDispose($hImage1) If @error Then ConsoleWrite('_GDIPlus_ImageDispose($hImage1) error: ' & @error & @CRLF) Exit EndIf _GDIPlus_ImageDispose($hImage2) If @error Then ConsoleWrite('_GDIPlus_ImageDispose($hImage2) error: ' & @error & @CRLF) Exit EndIf Next _GDIPlus_Shutdown() As Danp2 mentioned $FileList[0] contains the number of records, or if you use UBound you need to do -1 since arrays start at 0, not 1.
    I also moved _GDIPlus_Shutdown() out of the loop, since you don't need to be shutting it down each loop (especially since you're not explicitly starting it, though I think most GDI functions check if it's started).
    Give that a run, and see how it processes, look at the console to see what file it's on. (I disabled all the GDIPlus stuff and ran it myself against my Downloads folder and it logged everything in there with no errors)
     
    Edit: You may want to also either delete or move the file that you've just processed out of the folder you're scanning, so you don't accidentally process it multiple times
  12. mistersquirrle's post in how to make _ScreenCapture_Capture() adapt 1920*1080? but it works well with 1366*768 was marked as the answer   
    I'm not sure what you mean by amplified. Sounds like that it's not an AutoIt problem, then? Have you tried checking your windows scaling size? Check out these links:
    View display settings in Windows:  https://support.microsoft.com/en-us/windows/view-display-settings-in-windows-37f0e05e-98a9-474c-317a-e85422daa8bb Windows scaling issues for high-DPI devices:  https://support.microsoft.com/en-us/topic/windows-scaling-issues-for-high-dpi-devices-508483cd-7c59-0d08-12b0-960b99aa347d
  13. mistersquirrle's post in Function "Execute" fails to execute string from STDIN in console mode was marked as the answer   
    I think similar to 
    Part of the problem is how the 'Console' works in an uncompiled script. You're running it through the AutoIt.exe process, not through SciTE or its own process. You're not inputting into the 'correct' console window, is basically my thought. 
    So, basically, you cannot do what you want unless you compile the script, and do you things from the console window of the direct .exe file. As for why Execute is not working, that's because of CR/LF/CRLF, basically. I tested your code, and some example code built from the help file entry for Execute, and I got it working:
    #include <MsgBoxConstants.au3> #cs Compile this script to "ConsoleRead.exe". Open a command prompt to the directory where ConsoleRead.exe resides. Type the following on the command line: echo Hello! | ConsoleRead.exe When invoked in a console window, the above command echos the text "Hello!" but instead of displaying it, the | tells the console to pipe it to the STDIN stream of the ConsoleRead.exe process. #ce ; MouseClick("main", 436, 451, 1, 10) ; Copy this and try executing that, or whatever you want Example() Func Example() If Not @Compiled Then MsgBox($MB_SYSTEMMODAL, "", "This script must be compiled in order to run the example.") Exit EndIf Local $sOutput While True Sleep(25) $sOutput = ConsoleRead() ;~ If @error Then ExitLoop If $sOutput <> '' Then MsgBox($MB_SYSTEMMODAL, "", "Received: " & @CRLF & 'Type: ' & VarGetType($sOutput) & @CRLF & $sOutput) Execute(StringStripCR(StringStripWS($sOutput, 1 + 2))) ; $STR_STRIPLEADING + $STR_STRIPTRAILING If @error Then MsgBox($MB_SYSTEMMODAL, "", "Execute $sOutput error: " & @CRLF & @CRLF & @error) EndIf EndIf WEnd MsgBox($MB_SYSTEMMODAL, "", "Received: " & @CRLF & @CRLF & $sOutput) EndFunc ;==>Example Give that a shot (compiled) and see if it works for you, it did for me (sending the MouseClick line in there). Keep in mind then that this will only work for single line things.
     
    Edit: Also take a look at https://www.autoitscript.com/autoit3/docs/intro/running.htm, specifically: AutoIt specific command Line Switches
    And keep in mind that to use AutoIt3ExecuteScript  or AutoIt3ExecuteLine, the file needs to be compiled with this flag: 
    #pragma compile(AutoItExecuteAllowed, true)  
  14. mistersquirrle's post in is it possible the get the mouse moving speed and return its speed value? was marked as the answer   
    Yes, it's possible.
    Have you tried anything? It's some basic mathematics. Calculate the distance between 2 measurements of the cursor, use a timer to get how long it was between measurements, and then calculate the speed using the distance and time taken (speed = distance/time).
  15. mistersquirrle's post in If Then Else GUI Delete Problem was marked as the answer   
    Probably main problem is this:
    Do Sleep(1000) ; wait 1 second before checking again Until Not $result $result is an array, not really something that you can do good checking against to determine true/false by itself. Also, you are NOT doing any checks to see if the color is still there.
    Also this part:
    Local $color = "0x6EC89B" ; the color you are looking for (green) Local $result = PixelSearch(0, 137, 1, 465, 0xE8E9F1, 0) You're searching a different color than $color, because you're not using $color for the call. Also the 0 at the end of the function means that the color must match exactly, it may be a good idea to allow some variance.
    Next up this part: 
    Opt("PixelCoordMode", 2) ; WinActivate($hGui) PixelCoordMode 2 means relative to the client, however you're changing what the client is with WinActivate, so your PixelSearch will now be searching the wrong coordinates. Also deleting the GUI and re-making it isn't the best idea. Check out my modifications (still set up to test on my computer, so your color and search location are different):
    #include <GuiConstants.au3> OnAutoItExitRegister('__Exit') AutoItSetOption("PixelCoordMode", 1) ; 1 = Screen coords, 2 = relative to Client AutoItSetOption("WinWaitDelay", 50) Global $hGui = Null, $hTimer Global $iColor = "0x5379BD" ; the color you are looking for (green) Global $iState, $iColorShadeVariation = 10 Global $aResult, $aWinPos, $aGuiPos[2] = [350, 907], $aSearchPos[4] = [2797, 791, 2798, 792] $hGui = GUICreate("Disabled", 180, 60, $aGuiPos[0], $aGuiPos[1], $WS_DISABLED, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) ; $WS_DISABLED to prevent moving/resizing, $WS_EX_TOOLWINDOW so that it doesn't create an icon in the taskbar GUISetState(@SW_HIDE, $hGui) ; Make sure the GUI is initially hidden GUISetState(@SW_DISABLE, $hGui) ; Make sure the GUI is disabled, so it can't be messed with While 1 Sleep(10) ; Small sleep to avoid thrashing the CPU $aResult = PixelSearch($aSearchPos[0], $aSearchPos[1], $aSearchPos[2], $aSearchPos[3], $iColor, $iColorShadeVariation) If Not @error And IsArray($aResult) Then ; PixelSearch was successful ;~ ConsoleWrite('Success: ' & $aResult[0] & ', ' & $aResult[1] & @CRLF) GUISetState(@SW_SHOW, $hGui) ; Show our 'Disabled' GUI WinMove($hGui, '', $aGuiPos[0], $aGuiPos[1], Default, Default, 0) ; Move to the correct position WinSetOnTop($hGui, "", 1) ; Make sure it's set ontop ;~ WinActivate($hGui) ; We have no need to activate the window Do ; With the window disabled it can't be moved, so this below code isn't needed (or shouldn't be) to keep it in place ;~ $aWinPos = WinGetPos($hGui) ;~ If $aWinPos[0] <> $aGuiPos[0] Or $aWinPos[1] <> $aGuiPos[1] Then ;~ WinMove($hGui, '', $aGuiPos[0], $aGuiPos[1], Default, Default, 0) ;~ EndIf Sleep(10) ; Small wait to check again to avoid thrashing the CPU, but not so long that it's a hinderance $aResult = PixelSearch($aSearchPos[0], $aSearchPos[1], $aSearchPos[2], $aSearchPos[3], $iColor, $iColorShadeVariation) Until @error Or Not IsArray($aResult) ; Go until the PixelSearch fails GUISetState(@SW_HIDE, $hGui) ; Hide the GUI Else ; PixelSearch failed, we did not find the color you were looking for ;~ ConsoleWrite('Not found' & @CRLF) $iState = WinGetState($hGui) ; Get the GUI state If BitAND($iState, $WIN_STATE_VISIBLE) Then ; If it's visible... GUISetState(@SW_HIDE, $hGui) ; Hide it EndIf EndIf WEnd Func __Exit() GUIDelete($hGui) EndFunc ;==>__Exit  
    Edit: Also completely agree with @SOLVE-SMART, it looks like you're zoomed to 110%, and you'll likely have the incorrect coordinates with a different zoom level, browser, theme, screen resolution, window size, etc. This is definitely not the best way to do what you want to do.
  16. mistersquirrle's post in how to modify this code, so that a thin colored line can appear in the middle of the screen to divide the screen into 2 parts? was marked as the answer   
    Just modifying that code?
    #include <WindowsConstants.au3> #include <WinAPI.au3> #Include <GDIPlus.au3> _GDIPlus_Startup () $hDC = _WinAPI_GetWindowDC(0) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) $Color = 0xFF000000 $hPen = _GDIPlus_PenCreate($Color,2) _GDIPlus_GraphicsDrawLine($hGraphic, 0, @DesktopHeight/2, @DesktopWidth, @DesktopHeight/2, $hPen) _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN) _WinAPI_ReleaseDC(0, $hDC) _GDIPlus_Shutdown() However there's some issues with it, such that anything that updates on the screen will remove your painted line. If you want to create a presistent overlay, check out this thread/post from Melba: 
     
  17. mistersquirrle's post in Need help making correct string representation of raw value in a json file into my autoit code. was marked as the answer   
    He's trying to get the JSON in the second snippet into his AutoIt code (first snippet) to send as a request: 
    At least that's my take on the request.
     
    First of all, your JSON is not valid, JSON does NOT support comments, like //Incident Business Object ID. You need to remove all of those. As for then putting the multiline JSON into your script, I recommend that you run the JSON through a minifier, like: https://codebeautify.org/jsonminifier
    With the 'comments' removed, it outputs this:
    {"busObId":"6dd53665c0c24cab86870a21cf6434ae","Fields":["6ae282c55e8e4266ae66ffc070c17fa3"],"filters":[{"fieldId":"9365a6098398ff2551e1c14dd398c466d5a201a9c7","operator":"equals","value":"Incident"},{"fieldId":"83c36313e97b4e6b9028aff3b401b71c","operator":"equals","value":"1"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"New"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"Assigned"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"In Progress"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"Pending"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"Reopened"}]} That should have no issues inserting into AutoIt as long as it's enclosed with a single quote: '
     
  18. mistersquirrle's post in _Excel_Rangefind issue - (Moved) was marked as the answer   
    I would suggest looking at StringSplit: https://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm
    Like water said, iterate over the array checking the 'Value' column by using StringSplit (with both space and comma as your delimiters). You can then check each value separately. Something like this:
     
    #include <StringConstants.au3> Local Enum $eHeader_Sheet, $eHeader_Name, $eHeader_Cell, $eHeader_Value, $eHeader_Formula, $eHeader_Comment, _ $eHeader_Max Local $aArray[][$eHeader_Max] = [ _ ['Sheet0', '', '$AK$24', 'D1, D2, D33, D36', 'D1, D2, D33, D36', ''], _ ['Sheet0', '', '$AK$25', 'D3, D99', 'D3, D99', ''], _ ['Sheet0', '', '$AZ$25', 'D3, D99', 'D3, D99', ''], _ ['Sheet0', '', '$AK$32', 'D27, D28, D29, D30, D31', 'D27, D28, D29, D30, D31', ''], _ ['Sheet0', '', '$AK$61', 'LED1, LED2, LED3, LED4, LED5', 'LED1, LED2, LED3, LED4, LED5', ''] _ ] Local $aSplit Local $sCellToSearchFor = 'D3' Local $bFound = False For $iRow = 0 To UBound($aArray) - 1 $bFound = False $aSplit = StringSplit($aArray[$iRow][$eHeader_Value], ' ,', $STR_NOCOUNT) For $iValue = 0 To UBound($aSplit) - 1 If StringCompare(StringStripWS($aSplit[$iValue], $STR_STRIPALL), $sCellToSearchFor) = 0 Then ConsoleWrite(@TAB & 'Found ' & $sCellToSearchFor & ' reference in row ' & $iRow & ': ' & $aArray[$iRow][$eHeader_Value] & ', Cell: ' & $aArray[$iRow][$eHeader_Cell] & @CRLF) $bFound = True ExitLoop EndIf Next If Not $bFound Then ConsoleWrite('Not found in row: ' & $iRow & @CRLF) EndIf Next Exit I'm using StringCompare instead of just " = " because it can be a bit safer occasionally when comparing if strings are equal. Also, StringStripWS to remove any whitespace when doing the comparison, just in case there's extra spaces. If you wanted to stop searching after the first match just do ExitLoop 2, and it'll exit both For loops.
  19. mistersquirrle's post in Scope of #include was marked as the answer   
    It doesn't work because you're "including" the file too late. You enter a While loop at line 21, and so nothing after it is executed or initialized. That means that this whole section is never reached, and with how AutoIt works, the functions exist, but all the variables from the includes are never initialized and do not exist:
    ;------------------------------------------ this code below intended to be in a UDF eventually ---------------------------------------- Local $hDLL = DllOpen("user32.dll") ;also Global to all functions called - DO NOT close as calling program may be using user32.dll ;actually we CAN close it as user's call to same user32.dll will have a different handle #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK #include-Once #include <Debug.au3> ;for _DebugArrayDisplay() ;< - -this one does Not seem To work, only one In user's program above seems to work #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <Misc.au3> ;for _IsPressed() #include <WindowsConstants.au3> AutoItSetOption("MustDeclareVars", 1)  
    So, the FUNCTIONS from the includes DO exist, all the variables do NOT, because they're not initialized. As RTFC said, it's best to put all includes at the TOP of the script, before you do anything, like declare your own variables.
    My suggestion would be to treat your "intended to be in a UDF eventually" code as a UDF, and move all of it into a different file, and include that in the first half of the script. Doing that worked just fine for me, so I had the file looking like: 
    #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK ;~ #include <Debug.au3> ;for _DebugArrayDisplay() ;<-- commenting this out makes it fail vs #include at line 50 ??? #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include "ahha-include.au3" AutoItSetOption("MustDeclareVars", 1) ;create an example window with an edit control Local $hGUI = GUICreate("Test", 500, 400) ;the main window Local $cIDEdit1 = GUICtrlCreateEdit("Edit control #1", 10, 10, 200, 250, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL)) GUISetState(@SW_SHOW, $hGUI) ;show it MsgBox(262144, "USAGE", "Example window." & @CRLF & @CRLF & "Press Alt+W (once or twice) after clicking OK to enter window/control mode.") Local $nMsg While 1 ;this is your code main loop $nMsg = GUIGetMsg() If $nMsg <> 0 Then ;we have a message so Switch $nMsg ;Check for GUI events Case $GUI_EVENT_CLOSE ;the GUI is closed red [X] is clicked Exit Case Else ;do nothing EndSwitch ;End running through GUI events. Else ;no message Sleep(100) ;do something in your program EndIf ;---------------------------------------------------------------------------------------------------------------------------+ ;ADD this function into your $nMsg loop after the $nMsg EndIf ;as shown here or in your While 1 loop so it gets executed | _WindowControlOperations() ;let's go into move/adjust window/control operations if Alt+W pressed | ;comment out this function call when all done, or delete it | ;---------------------------------------------------------------------------------------------------------------------------+ WEnd And then the ahha-include file like:
    ;------------------------------------------ this code below intended to be in a UDF eventually ---------------------------------------- Local $hDLL = DllOpen("user32.dll") ;also Global to all functions called - DO NOT close as calling program may be using user32.dll ;actually we CAN close it as user's call to same user32.dll will have a different handle #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK #include-Once #include <Debug.au3> ;for _DebugArrayDisplay() ;< - -this one does Not seem To work, only one In user's program above seems to work #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <Misc.au3> ;for _IsPressed() #include <WindowsConstants.au3> AutoItSetOption("MustDeclareVars", 1) Func _WindowControlOperations() ;called by user program and only continues below if Alt+W pressed else returns to calling program above If Not (((_IsPressed("12") = 1) And (_IsPressed("57") = 1))) Then ;check for Alt+W ;12 ALT key, 57 W key ; default DLL=user32.dll Return (0) ;as Alt+W not pressed Else ;Alt+W pressed to call rest _WindowControlOperationsContinue() EndIf EndFunc ;==>_WindowControlOperations Func _WindowControlOperationsContinue() ;Alt+W was pressed Global $aWindowControlLog[1][3] = [["Window/Control", "Title", "Left, Top, Width, Height"]] ;element [0] [Row][Column] ;v2a - create an Instructions window Global $iLeft = 0, $iTop = 0, $iWidth = 0, $iHeight = 0 ;init values Global $sStatus = "$iLeft, $iTop, $iWidth, $iHeight" & @CRLF & $iLeft & ", " & $iTop & ", " & $iWidth & ", " & $iHeight ;create main Instructions window Global $hWndInstructions = GUICreate("Instructions", 300, 457) ;the main instructions window Local $sInstructions = "Click List All to list all adjustments made." & @CRLF & _ " " & @CRLF & _ "Click upper right X to exit program." ;create an edit control - into which we'll put the instruction text Local $cIDInstructions = GUICtrlCreateEdit("", 10, 10, 280, 300, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) ;no , $WS_HSCROLL)) Global $sStatus = "$iLeft, $iTop, $iWidth, $iHeight" & @CRLF & $iLeft & ", " & $iTop & ", " & $iWidth & ", " & $iHeight Global $hStatus = _GUICtrlEdit_Create($hWndInstructions, $sStatus, 10, 318, 280, 50) Global $idButton_List = GUICtrlCreateButton("List All" & @CRLF & "Sizes/Positions", 152, 412, 139, 35, 0x2000) ;create control button ,0x2000=multi-line GUISetState(@SW_SHOW, $hWndInstructions) ;show window and edit controls ControlSetText("", "", $cIDInstructions, $sInstructions) ;show instructions ControlSetText("", "", $hStatus, $sStatus) ;show status _While1() ;enter our message loop Return (0) ;to main calling program EndFunc ;==>_WindowControlOperationsContinue Func _While1() Local $nMsg While 1 ;look for button presses $nMsg = GUIGetMsg() If $nMsg <> 0 Then ;we have a message so Switch $nMsg ;Check for GUI events Case $GUI_EVENT_CLOSE ;the GUI is closed red [X] is clicked GUIDelete($hWndInstructions) ;destroy the Instructions window and all controls therein Return (0) ;to Func _WindowControlOperationsContinue() Case $idButton_List _DebugArrayDisplay($aWindowControlLog, "$aWindowControlLog") ;<-- problem here with #include <Debug.au3> scope Case Else ;do nothing EndSwitch ;End running through GUI events. Else ;no message - do nothing ;no message EndIf WEnd ;While 1 EndFunc ;==>_While1  
    Doing it like this worked for me with the #include <Debug.au3> commented or uncommented in the main script.
  20. mistersquirrle's post in Can't exit Node-Red (in console window) with CTRL+C was marked as the answer   
    I think that this is an issue with how running an uncompiled script works in AutoIt. You can test the issue with this:
     
    #include <AutoItConstants.au3> Local $iPid = Run(@ComSpec & ' /k ping 127.0.0.1 -t ', '', @SW_SHOW, $RUN_CREATE_NEW_CONSOLE) If you run that from SciTE and try to do Ctrl + c to cancel it, or Ctrl + BREAK, neither work and the ping continues. However, if you set the flag
    #AutoIt3Wrapper_Change2CUI=y And then compile the script and run it, you ARE able to cancel it with Ctrl + c. So I think that if you're looking for that Ctrl + c functionality, just keep in mind that you'll need to compile the script to get it. Here's my full test:
    #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <AutoItConstants.au3> Local $iPid = Run(@ComSpec & ' /k ping 127.0.0.1 -t ', '', @SW_SHOW, $RUN_CREATE_NEW_CONSOLE)  
  21. mistersquirrle's post in Is there a way to send copy , no matter what language I have active? was marked as the answer   
    You can try SendMessage or PostMessage, though not all windows will accept the commands (unless you get tricky with it, maybe).
    Try out this script. I works for pasting in SciTE, Windows Explorer and Notepad, but it didn't work in Visual Studio Code or Chrome, for example. It should work fine in an AutoIt GUI though.
    #include <SendMessage.au3> HotKeySet('[', '_Go') While 1 Sleep(10) WEnd Func _Go() Local $hHwnd = WinGetHandle('[ACTIVE]') Local $hCtrlHnd = ControlGetFocus($hHwnd) $hCtrlHnd = ControlGetHandle($hHwnd, '', $hCtrlHnd) _SendMessage($hCtrlHnd, $WM_PASTE) EndFunc  
    Edit: plugging it into your script works:
    #include <SendMessage.au3> #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("My GUI", 320, 120) Local $idFile = GUICtrlCreateInput("Sends simulated keystrokes to the active window.", 10, 5, 300, 20) Local $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn ControlFocus("My GUI", "", "Edit1") Local $hHwnd = WinGetHandle('[ACTIVE]') Local $hCtrlHnd = ControlGetFocus($hHwnd) $hCtrlHnd = ControlGetHandle($hHwnd, '', $hCtrlHnd) _SendMessage($hCtrlHnd, $WM_PASTE) ConsoleWrite(ClipGet() & @CRLF) EndSwitch WEnd EndFunc ;==>Example  
  22. mistersquirrle's post in Uncompiled Script on Start Up? was marked as the answer   
    @Danp2 That is a pretty neat thread and approach to doing things, thanks for linking it, I may not have seen it otherwise.
     
    Another option for @SkysLastChance would also be to get the AutoIt3.exe (or AutoIt3_x64.exe) itself approved, and then you could use a .bat or shortcut to call an uncompiled script or compiled as .a3x. 
    .bat file would look something like: 
    "C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "C:\Users\User\Documents\AutoIt\DoSomething.a3x"  
    Though I doubt that IT would approve the AutoIt exe itself... That Au3toCmd really seems like a good option. Also if you're able to get the AutoIt exe approved or AutoIt installed, you don't even need to compile as .a3x, the .au3 file will work using the same syntax with a .bat file or a shortcut in the startup folder.
     
    https://www.autoitscript.com/autoit3/docs/intro/running.htm
×
×
  • Create New...