Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/20/2023 in all areas

  1. You can do it with COM objects using MQAX200.dll and you have an example here about how to get data from queue. You should be able to figure it out also how to put a message to queue. Even if it's not AutoIt, this might help you as well.
    2 points
  2. Accept Multiple Files UDF is inspired by this topic and this topic. Introduction if your app (compiled script) is launched from Windows Explorer context menu, then you've probably noticed that when multiple files are selected, only one file is passed to your app, so Windows starts multiple instances of your app, one for each file selected. few simple ways to overcome this issue are: 1) put a shortcut to your app on your "Send To..." context menu. this passes all the selected files as individual parameters to a single instance of your app. 2) put a shortcut to your app somewhere accessible, and drag the selected files to that shortcut. that will give you the same effect. (an accessible location might not include the task bar, unfortunately. but the Start menu for example is ok). 3) use an intermediate launcher, like this one (not tested by me). if none of these apply to you, then this UDF allows your app to handle this issue internally. Usage - yes, it is a one-liner: Global $aFiles = _AcceptMultipleFiles() Example Script - with comprehensive comments inside: #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Array.au3> ; this is needed only For the _ArrayDisplay later In this example script. #include 'AMF.au3' ; include the "Accept Multiple Files" UDF. #NoTrayIcon ; disable this interactive feature. Global $hTimer = TimerInit() ; for testing purposes Global $aFiles = _AcceptMultipleFiles() Global $fDiff = Round(TimerDiff($hTimer)) / 1000 ; determine how long the process took #cs calling _AcceptMultipleFiles makes the calling script accept all files passed as parameters to multiple instances of the calling script, typically invoked by Windows Explorer context menu. list of files is returned as an array. this is best performed as early as possible in your script, and definitely before any user interaction. it will either make this instance the 'master', that will accept multiple files to process (and continue running), or submit its file to the master instance if one is already active (and exit). *NOTE: if there are files to process, and if this is NOT the 'master' instance, then this line will never be reached. *NOTE: if only one file is selected - thus only one instance is invoked - then that instance becomes the 'master' and the files array contains only the one file. if your code made it this far, there are two possible scenarios: 1) there are files to process, and they are stored in the array. element zero and @extended both store the number of files. 2) your app was called with no parameters, or too many, or one that is not a file. in this case element zero = 0 and @extended = 0. hence, you can use element zero to decide on your next action. something like this: #ce If $aFiles[0] > 0 Then ; <<<<<<<<<< do your stuff with the files listed in $aFiles >>>>>>>>>> _ArrayDisplay($aFiles, 'AMF Example (' & $fDiff & ' sec)') Else ; <<<<<<<<<< do your stuff when no parameters were specified, or too many parameters, or a single parameter which is not a valid file >>>>>>>>>> MsgBox(0, 'AMF Example (' & $fDiff & ' sec)', 'This was the command line:' & @CRLF & $CmdLineRaw) EndIf UDF: #include-Once ; #INDEX# ======================================================================================================================= ; Title .........: Accept Multiple Files ; AutoIt Version : 3.3.16.1 ; UDF Version ...: 2.0 ; Status ........: Production ; Language ......: English ; Description ...: Allows a script to accept multiple files from Windows Explorer context menu, which invokes multiple instances. ; One instance becomes the 'master'. All other instanes submit their files to the master and exit, so only the ; 'master' instance remains active and can process all files. ; Author(s) .....: orbs ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== Global $__g_AMF_bDebug = False ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _AcceptMultipleFiles ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _AcceptMultipleFiles ; Description ...: Accepts multiple files given as parameters to multiple instances of the calling script. ; Syntax ........: _AcceptMultipleFiles([$iAttempts = 10[, $iInterval = 10[, $bDebug = False]]]) ; Parameters ....: $iAttempts - [optional] number of attempts of searching for submitted files. Default (and minimum) is 10. ; $iInterval - [optional] number of milliseconds between attempts. Default (and minimum) is 10. ; $bDebug - [optional] default is False. if True, log files are created in the temporary folder. ; Return values .: a 1-based array of all files submitted by all instances. @extended is set to file count. ; Author ........: orbs ; Modified ......: ; Remarks .......: - if no parameters were specified, or too many parameters, or a single parameter which is not a valid file, ; then the function returns an array with element [0]=0, and @extended is set to 0. ; - to improve reliability, the calling script may increase $iAttempts and/or $iInterval. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _AcceptMultipleFiles($iAttempts = 10, $iInterval = 10, $bDebug = False) ; process parameters If ($iAttempts = Default) Or ($iAttempts < 10) Then $iAttempts = 10 If ($iInterval = Default) Or ($iInterval < 10) Then $iInterval = 10 If $bDebug = Default Then $bDebug = False $__g_AMF_bDebug = $bDebug __AMF_Log('enter _AcceptMultipleFiles') __AMF_Log('attempts: ' & $iAttempts) __AMF_Log('interval: ' & $iInterval) ; initialize return data Local $aFiles[1] = [0] ; validate parameter If Not ($CmdLine[0] = 1 And FileExists($CmdLine[1])) Then Return SetExtended(__AMF_Log('invalid param => return empty array'), $aFiles) ; prepare variables and parent (root) folder Local Const $sAMF_Root = @LocalAppDataDir & '\AMF' __AMF_Log('AMF root: ' & $sAMF_Root) __AMF_Log('root DirCreate = ' & DirCreate($sAMF_Root)) Local Const $sAMF_Path = @LocalAppDataDir & '\AMF\' & __AMF_CreateGUID(StringRight(@ScriptFullPath, 16)) Local Const $sAMF_MasterFile = $sAMF_Path & '\master' __AMF_Log('AMF path: ' & $sAMF_Path) __AMF_Log('master file: ' & $sAMF_MasterFile) Local $iIteration = 0 Local $bFound Local $hSearch Local $sAMF_File Local $sFile ; determine if master While Not __AMF_TakeOver($sAMF_Path, $sAMF_MasterFile) ; see if this should become the master process. If __AMF_MasterIsActive($sAMF_MasterFile, $iAttempts, $iInterval) Then ;; if not, then check if there is already an active master process. __AMF_SubmitFile($sAMF_Path, $CmdLine[1]) ;;; if so, then submit the file to the master and exit. __AMF_Log('file submitted => exit') Exit Else __AMF_Cleanup($sAMF_Path) ;; if there is no active master, assume the past master has crashed. cleanup and repeat trying to take over. EndIf WEnd __AMF_Log('this instance is master') ; start with first file, submitted by the master ReDim $aFiles[UBound($aFiles) + 1] $aFiles[0] += 1 $aFiles[UBound($aFiles) - 1] = $CmdLine[1] ; process submitted files __AMF_Log('searching for submitted files') Do $iIteration += 1 $bFound = False __AMF_Log('start iteration #' & $iIteration) For $i = 1 To $iAttempts __AMF_Log('attempt #' & $i) FileClose($hSearch) $hSearch = FileFindFirstFile($sAMF_Path & '\PID_*') If @error Then __AMF_Log('FileFindFirstFile @error=' & @error & ' => next attempt') FileClose($hSearch) Sleep($iInterval) ContinueLoop EndIf $sAMF_File = FileFindNextFile($hSearch) If @error Then __AMF_Log('FileFindNextFile @error=' & @error & ' => next attempt') Sleep($iInterval) ContinueLoop EndIf $bFound = True __AMF_Log('$sAMF_File = ' & $sAMF_File) $sAMF_File = $sAMF_Path & '\' & $sAMF_File __AMF_Log('prefix full path = ' & $sAMF_File) __AMF_Log('FileGetAttrib = ' & FileGetAttrib($sAMF_File)) If StringInStr(FileGetAttrib($sAMF_File), 'R') Then __AMF_Log('Attrib R found') $sFile = FileReadLine($sAMF_File) __AMF_Log('FileReadLine = ' & $sFile) If $sFile = '' Then __AMF_Log('result is empty => repeat attempt') Sleep($iInterval) $i -= 1 ContinueLoop Else __AMF_Log('FileSetAttrib -R = ' & FileSetAttrib($sAMF_File, '-R')) __AMF_Log('FileDelete = ' & FileDelete($sAMF_File)) EndIf Else __AMF_Log('Attrib R not found => repeat attempt') Sleep($iInterval) $i -= 1 ContinueLoop EndIf ReDim $aFiles[UBound($aFiles) + 1] $aFiles[0] += 1 $aFiles[UBound($aFiles) - 1] = $sFile __AMF_Log('added to array => repeat attempt on next file') $i -= 1 Next __AMF_Log('iteration ended. files found = ' & $bFound) Until Not $bFound FileClose($hSearch) __AMF_Log('search for submitted files ended') __AMF_Cleanup($sAMF_Path) Return SetExtended(__AMF_Log('end _AcceptMultipleFiles => return array with @extended=' & $aFiles[0], $aFiles[0]), $aFiles) EndFunc ;==>_AcceptMultipleFiles ; #INTERNAL_USE_ONLY# =========================================================================================================== ; __AMF_CreateGUID ; __AMF_TakeOver ; __AMF_MasterIsActive ; __AMF_SubmitFile ; __AMF_Cleanup ; __AMF_Log ; =============================================================================================================================== Func __AMF_CreateGUID($sString) ; ref: https://www.autoitscript.com/forum/topic/147995-createguidfromstring-convert-a-string-to-a-valid-guid/ Return StringRegExpReplace(StringToBinary($sString) & "0000000000000000000000000000000000", "..(.{8})(.{4})(.{4})(.{4})(.{12}).*", "\{$1-$2-$3-$4-$5\}") EndFunc ;==>__AMF_CreateGUID Func __AMF_TakeOver($sAMF_Path, $sAMF_MasterFile) __AMF_Log('enter __AMF_TakeOver') Local $aResult = DllCall('kernel32.dll', 'bool', 'CreateDirectoryW', 'wstr', $sAMF_Path, 'struct*', 0) If @error Or ($aResult[0] = 0) Then Return __AMF_Log('cannot create folder => this instance is not the master. return 0') Else __AMF_Log('FileWriteLine = ' & FileWriteLine($sAMF_MasterFile, @AutoItPID)) __AMF_Log('FileSetAttrib +R = ' & FileSetAttrib($sAMF_MasterFile, '+R')) Return __AMF_Log('master file created => return 1', 1) EndIf EndFunc ;==>__AMF_TakeOver Func __AMF_MasterIsActive($sAMF_MasterFile, $iAttempts, $iInterval) __AMF_Log('enter __AMF_MasterIsActive') Local $iPID For $i = 1 To $iAttempts If StringInStr(FileGetAttrib($sAMF_MasterFile), 'R') Then $iPID = Number(FileReadLine($sAMF_MasterFile)) ExitLoop Else Sleep($iInterval) EndIf Next __AMF_Log('read PID = ' & $iPID) If $iPID = 0 Then Return __AMF_Log('PID=0 => return 0') If ProcessExists($iPID) Then Return __AMF_Log('process exists => return 1', 1) Return __AMF_Log('end __AMF_MasterIsActive => return 0') EndFunc ;==>__AMF_MasterIsActive Func __AMF_SubmitFile($sAMF_Path, $sFile) __AMF_Log('enter __AMF_SubmitFile') Local $sAMF_File = $sAMF_Path & '\PID_' & @AutoItPID __AMF_Log('FileDelete = ' & FileDelete($sAMF_File)) __AMF_Log('file to submit: ' & $sFile) __AMF_Log('FileWriteLine = ' & FileWriteLine($sAMF_File, $sFile)) __AMF_Log('FileSetAttrib +R = ' & FileSetAttrib($sAMF_File, 'R')) __AMF_Log('end __AMF_SubmitFile') EndFunc ;==>__AMF_SubmitFile Func __AMF_Cleanup($sAMF_Path) __AMF_Log('enter __AMF_Cleanup') __AMF_Log('dir to remove: ' & $sAMF_Path) __AMF_Log('FileSetAttrib -R = ' & FileSetAttrib($sAMF_Path, '-R', 1)) __AMF_Log('DirRemove = ' & DirRemove($sAMF_Path, 1)) __AMF_Log('end __AMF_Cleanup') EndFunc ;==>__AMF_Cleanup Func __AMF_Log($sString, $xRet = 0) If $__g_AMF_bDebug Then FileWriteLine(@TempDir & '\AMF_log_' & @AutoItPID & '.txt', @HOUR & ':' & @MIN & ':' & @SEC & '.' & @MSEC & ' (' & @AutoItPID & ') ' & $sString) Return $xRet EndFunc ;==>__AMF_Log Testing Instructions: 1) save the UDF as file "AMF.au3". 2) save the example script as file "AMF_Example.au3". 3) compile the example script as "AMF_Example.exe". 4) place the executable in the root of drive D (or anywhere else ,but adapt the following registry entry accordingly) 5) save this text as registry file "AMF_Example.reg" and import it: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\AMF Example] "MultiSelectModel"="Player" [HKEY_CLASSES_ROOT\*\shell\AMF Example\command] @="D:\\AMF_Example.exe \"%1\"" 6) open Windows Explorer, select multiple files, right click one of them and choose "AMF Example" from the context menu. 7) enjoy!
    1 point
  3. As many of you may not be aware, of much about AutoIt's humble beginnings, and aspects related to the first GUI version of AutoIt, I thought it might be nice to create a historical reference here for all the many GUI creators that have been created by various people over the years. NOTE - While one could argue, that this topic might be better placed in one of the Chat forums, I would argue, that it links to heaps of good code. While much may be redundant in that code, it is still interesting and forms a great perspective. Many are bound to find useful elements at the very least. Koda, is no doubt the most well-known GUI creator now, but there was a time, when CyberSlug's legendary GUIBuilder (first known as AutoBuilder) ruled the roost, and AutoIt coder's saw it as a Godsend. AutoIt coding was much simpler back then of course. Below, will be a timeline, of any AutoIt GUI creators listed in forum pages. It will be added to by myself as I find them or as others here find them and place a link in a subsequent post ... PLEASE HELP! Comments welcome too. (Also note, that this is also intended to include updates, branches etc by others) Apr 20 2004 - AutoBuilder by CyberSlug. Sep 27 2004 - An interesting topic, where CyberSlug talks about the future of AutoBuilder (etc) and renaming to GUIBuilder and you see the first mentions and links to updates by others (including myself & livewire). Nov 05 2004 - A topic where lookfar is working on a SciTE replacement, talks about starting a Form Designer. Aug 10 2005 - GuiBuilder first update by TheSaint. Sep 26 2005 - GUIBuilder updates by livewire (he also talks about transferring his efforts to Koda). Nov 02 2005 - KODA FormDesigner v1.3 by lookfar Nov 03 2005 - Seemingly interesting topic about forms by tonedeaf Dec 26 2005 - AutoIt Studio(beta) by BillLuvsU Jan 09 2006 - AutoBuilder update (or branch) by _^__darkbytez (livewire also posts). Feb 19 2006 - Koda v1.5 by lookfar Sep 07 2006 - Koda v1.7.3.0 by Lazycat Jan 07 2007 - Form/GUI Builder by FlintBrenick Jun 10 2007 - Gorganizer by _Kurt (more of an assister than actual GUI maker) Jun 27 2007 - Basic GUI Designer by Mast3rpyr0 May 03 2008 - Autoit Programmer's Desktop (APD) by Ealric Jul 11 2008 - Gui Designer by Alek Aug 11 2008 - Gorganizer update by _Kurt Jun 19 2009 - Easy GUI by Mat Aug 13 2009 - GUI Script Creator by Pandemic (not sure this qualifies, but it made me think of templates) Aug 16 2010 - Creation Gui by AZJIO Jan 22 2012 - ISN AutoIt Studio by ISI360 (includes ISN Form Studio 2, a GUI editor) Mar 19 2012 - Arduino GUI Programmer by nikosliapis (creates a specific type of GUI) Aug 01 2012 - GuiBuilder Resurrected update/branch to GUIBuilder by baroquebob Dec 01 2012 - Form Builder beta (v1.0.6) by BuckMaster Jan 12 2015 - GUIBuilderNxt update by jaberwacky of GUIBuilder v0.8 (as a new prototype, modified to work with latest AutoIt) (not a update to the Resurrected version) Aug 12 2016 - The GuiBuilder Return by DFerrato as an update to GUIBuilder, Jan 17 2017 - GUIBuilder Project by TheSaint (a work in progress based on CyberSlug's original ... and later versions, updated by Roy, TheSaint & others). May 29 2019 - The GuiBuilder Return by DFerrato as an update to GUIBuilder, His new and improved version. May 9 2022 - GuiBuilderPlus by kurtykurtyboy as an update to GUIBuilder. A new an improved version with more to come. There are a significant number of creators/designers that have been started and never completed. +++++ STILL UNDER CONSTRUCTION +++++ P.S. Well that's it from me tonight. I know of at least one other major creator, but cannot recall it's name or the name of the coder, though I think it starts with 'L'. Bound to be a few I've missed, and some I cannot seem to find their first appearance here (Koda, Form Builder, etc), but there may be an obvious reason for that. Will probably rely on feedback from others now that I've got the ball rolling. NOTE - If anyone wants to discuss any of these programs above or give some background history, then by all means do so. I will cross-reference (link to) any important comments.
    1 point
  4. I agree. just like me I do small changes in my old UDF's every day, and create new projects related to my old UDF every days. In my case: I start this project 3 years ago..... most huge jobs done, still a zillion small things to do. I agree. EDIT: by the way. Thank you for all your comments, I hope my comments will not be perceived as aggressive, but as a case history for others.
    1 point
  5. Understood, but that means that you also disabled the smart AutoComplete part and all will work as before all changes. Maybe I need to consider making the auto add includes optional ?! That is controlled by change.history. Set it to 3 for what you want and restart SciTE: Pretty sure that is a glitch in the LUA code only removing one of the 2 characters of a Unicode character, so will have a look to check that... thanks for reporting!
    1 point
  6. Func RotatePDF() ControlSend($Gui, '', 'AVL_AVView32', '^+{+}') EndFunc PS: declare $Gui as global
    1 point
  7. I figured out how to disable the internal autoindent just for au3 and fully do the indentation in lua which then also works with multiselections.. will publish it when I've done some more testing in a couple of days.
    1 point
  8. Use _Excel_BookList to get a list of open workbooks. The returned array holds the full path of each workbook.
    1 point
  9. how about this? (i've had that piece of code running for quite some time now, but it took a few days to wrap it up nicely as a UDF).
    1 point
  10. The first new addition in a while, to the second post of this topic. June 10 2023 - Glance - GUI library for AutoIt, based on Windows api by kcvinu
    1 point
×
×
  • Create New...