gruntydatsun Posted October 9, 2011 Share Posted October 9, 2011 Hi, I wrote a script that processes files you select from the shell. Drag a box around files, right click, select Process Files from context menu. The program uses CMDLINERAW to take in the arguments passed by the shell. This is running the program properly and passing the files selected as arguments to the program. The problem is that it runs a separate instance of the program for everyfile in the selection. The keys I wound up with are: HKEY_CLASSES_ROOT/*/SHELL/MYKEY/(Default)--- Reg_SZ--- Optimise FilesIcon -------Reg_SZ--- C:\Scripts\myicon.icoPosition-----Reg_SZ--- MiddleHKEY_CLASSES_ROOT/*/SHELL/MYKEY/COMMAND (Default)----Reg_SZ----C:\Scripts\myprogram.exe %1So if I drag a box around three files, right click selection and left click Optimise Files then I get three instances of the program run with single file in each, instead of a single instance with three files in it. What I need is for it to pass all the files as arguments to a single instance of the program. Can anyone help with this? Link to comment Share on other sites More sharing options...
guinness Posted October 9, 2011 Share Posted October 9, 2011 (edited) WM_COPYDATA will achieve what I believe you're looking for. Look in my signature for an example of how to use. Edited October 9, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 10, 2011 Author Share Posted October 10, 2011 Thanks guinness. That is a very interesting bit of code but it's not quite what I'm chasing. Heaps of interesting stuff in your sigblock. I just need to know what registry key to create to make only a single instance of the program run with all the selections passed to it. I'm having all sorts of trouble trying to get this working. Any advice appreciated. Link to comment Share on other sites More sharing options...
guinness Posted October 10, 2011 Share Posted October 10, 2011 I just need to know what registry key to create to make only a single instance of the program run with all the selections passed to it.There's no Registry Key take a look at _Singleton() in the Help file and then $CmdLine in the help file. I'm sure WM_COPYDATA is what you're looking for. A quick example, I have an instance of the program running in the background, when a user sends files to the application instead of creating a new instance those files are sent to the initial application running...am I right? Is this what you wanted? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 11, 2011 Author Share Posted October 11, 2011 I'm probably not explaining what I'm doing properly. There is no AutoIT program running in the background during normal operation of the pc. You open up Windows Explorer, drag a box around several files and right click the selection. From the Windows context menu you select the entry "Optimise Files" which I have created with the below registry keys in the windows registry: HKEY_CLASSES_ROOT/*/SHELL/MYKEY/(Default)--- Reg_SZ--- Optimise FilesIcon -------Reg_SZ--- C:\Scripts\myicon.icoPosition-----Reg_SZ--- MiddleHKEY_CLASSES_ROOT/*/SHELL/MYKEY/COMMAND(Default)----Reg_SZ----C:\Scripts\myprogram.exe %1Selecting "Optimise Files" from the windows context menu starts the program C:\Scripts\myprogram.exe and passes the selections you made with the drag box as command line parameters to the program. The ProblemIf I drag a box around 3 files in a Windows Explorer window, right click, select Optimise FIles from Widows context menu it successfully starts my program but it will start three instances, passing one of the files to each instance as a command line parameter. My AimWhat I'm trying to achieve is to have one instance of my program launched with all three files passed as command line parameters to that one instance. Link to comment Share on other sites More sharing options...
guinness Posted October 11, 2011 Share Posted October 11, 2011 So I did understand what you required. The workaround I can think of is using a combination of WM_COPYDATA and _Singleton(). 1. First file opens 1 instance and sets _Singleton(), the file is 'optimised.'2. Second file is sent to the first instance to be processed using WM_COPYDATA for 'optimising.'3. Third file is sent to the first instance to be processed using WM_COPYDATA for 'optimising.'N. Nth file is sent to the first instance to be processed using WM_COPYDATA for 'optimising.' I will simplify my WM_COPYDATA and re-post once complete. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 11, 2011 Author Share Posted October 11, 2011 (edited) Thanks for taking the time to help me with this guinness I have managed to find a program that will set registry entries to create a context menu item that will send all the files to a single instance of my program as arguments. Then I'm breaking the CMDLINERAW into an array using $args = StringSplit($CMDLINERAW," ") The webpage is here http://www.lopesoft.com/en/fmtools/info.html and if you create a custom context menu item in the program it works. I just cant figure out how the heck its doing it. The keys it makes are in HKEY_CURRENT_USER\Software\LopeSoft\FileMenu Tools\Commands, in my case subkey is 22 for this command. There are other keys made in the registry by this program for a dll as well so maybe it's not just a matter of setting registry keys. I'm no expert on the registry so this is getting a bit beyond me. Anyway, appreciate your help guinness. Edited October 11, 2011 by gruntydatsun Link to comment Share on other sites More sharing options...
guinness Posted October 11, 2011 Share Posted October 11, 2011 Does this give you a better idea of what I was talking about? I've tried to make the process very easy to understand as you only have to use _WM_COPYDATA_Send() & _WM_COPYDATA_Start(). If this doesn't work then please post the code you tried. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=Y #cs Thanks to the following for helping in the past ... KaFu for the idea from _EnforceSingleInstance(). Yashied for x64 support. #ce #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $__InterCommunication[3] = ["-GUIHandle", "-ControlID", "-Data"] ; Internal array for the WM_COPYDATA functions. _Main() Func _Main() Local $iControlID $iControlID = _WM_COPYDATA_Start() ; Start the communication process. If @error Then If Not _WM_COPYDATA_Send($CmdLineRaw) Then ; Send $CmdLineRaw if there is process already running. MsgBox(64, "2nd Instance: " & @AutoItPID, "Seems there was an @error, but more than likely $CmdLineRaw was blank.") EndIf Exit EndIf While 1 Switch GUIGetMsg() Case $iControlID ; If the WM_COPYDATA message is interecepted then show your optimise function. _Optimise() EndSwitch WEnd EndFunc ;==>_Main Func _Optimise() Return MsgBox(64, "1st Instance: " & @AutoItPID, _WM_COPYDATA_GetFile()) ; Get the WM_COPYDATA file. EndFunc ;==>_Optimise Func _WM_COPYDATA($hWnd, $iMsg, $iwParam, $ilParam) ; WM_COPYDATA function. #forceref $hWnd, $iMsg, $iwParam Local $tData, $tParam, $tString $tParam = DllStructCreate("ulong_ptr;dword;ptr", $ilParam) $tData = DllStructCreate("wchar[" & DllStructGetData($tParam, 2) / 2 & "]", DllStructGetData($tParam, 3)) $tString = DllStructGetData($tData, 1) $__InterCommunication[2] = BinaryToString($tString) GUICtrlSendToDummy($__InterCommunication[1]) EndFunc ;==>_WM_COPYDATA Func _WM_COPYDATA_GetFile() ; Retrieve the file passed via the 2nd instance. Return $__InterCommunication[2] EndFunc ;==>_WM_COPYDATA_GetFile Func _WM_COPYDATA_Send($sString) ; Send data to the 1st instance. Local $hHandle = $__InterCommunication[0], $ilParam, $tData If $hHandle = -1 Then Return SetError(1, 0, 0) EndIf If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf If $hHandle Then $tData = DllStructCreate("wchar[" & StringLen($sString) + 1 & "]") DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ulong_ptr;dword;ptr") DllStructSetData($ilParam, 1, 0) DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hHandle, $WM_COPYDATA, 0, DllStructGetPtr($ilParam)) Return Number(Not @error) EndIf EndFunc ;==>_WM_COPYDATA_Send Func _WM_COPYDATA_Start() ; Start the WM_COPYDATA process. Thanks to KaFu for introducing me to AutoItWinGetTitle()/AutoItWinSetTitle(). Local $hGUI, $hHandle, $sData = "D4672AD6-EA21-4FFD-88F5-4641A2B33E9F" $hHandle = WinGetHandle($sData) If @error Then AutoItWinSetTitle($sData) $hHandle = WinGetHandle($sData) $hGUI = GUICreate("", 0, 0, -99, -99, "", $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $hGUI) ControlSetText($hHandle, "", ControlGetHandle($hHandle, "", 'Edit1'), $hGUI) GUIRegisterMsg($WM_COPYDATA, "_WM_COPYDATA") $__InterCommunication[0] = -1 $__InterCommunication[1] = GUICtrlCreateDummy() Return SetError(0, 0, $__InterCommunication[1]) Else $hHandle = HWnd(ControlGetText($hHandle, '', ControlGetHandle($hHandle, '', 'Edit1'))) $__InterCommunication[0] = $hHandle Return SetError(1, 0, $hHandle) EndIf EndFunc ;==>_WM_COPYDATA_Start UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 11, 2011 Author Share Posted October 11, 2011 Thanks guinness. I will try this tonight after Survivor. (yes I know, I feel shame but can't stop watching). Link to comment Share on other sites More sharing options...
guinness Posted October 11, 2011 Share Posted October 11, 2011 You're welcome. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 11, 2011 Author Share Posted October 11, 2011 Wow guinness. I feel like a bit of a moron being totally swamped by the simplified version! lol I managed to get the program working properly. I made a SendTo folder shortcut and that automatically sends all the arguments to a single instance of the program. I did use your _CmdLineRaw function from your sigblock to replace the clunky one I wrote. It works like a charm now. The program I wrote is a wrapper for nconvert.exe that shrinks photos to the same size that facebook would squeeze them to (after you upload your 5MB photo). This makes it easy for my wife to optimise, then upload copious amounts of photos of our newborn 2nd daughter without monopolising my computer (woeful upload speed here). Thanks for helping Guinness. Below is my program. It's raw and a little nasty bit it works. This is the link to the photo optimiser command line program it uses. I'll end up using file include to install it to the user machine and create the SendTo link from AutoIT installer section in the script aswell.http://www.xnview.com/en/download_nc.html 1:15am here. Need sleep. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: GruntyDatsun Script Function: Optimise photos for upload to facebook. Depends on having a copy of nconvert.exe in the same folder as this executable. Make a shortcut in your SendTo folder pointing to this executable. You can right click a seletion of files, Send To, This Excecutable and they will be squeezed down and inserted into a folder. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <Constants.au3> ;for STDOUT_CHILD, STDERR_CHILD $args = _CmdLineRaw($CMDLINERAW) ;thanks guinness if IsArray($args) Then ;check if command line arguments passed in array if FileGetAttrib($args[0]) = "D" Then ;THIS IS A DIRECTORY local $OutputPath = $args[0] & "\ForFACEBOOK" ;set path to output folder for photos $args = _GetFileList() ;get a listing of all files in folder DirCreate($OutputPath) ;create output folder ElseIf FileGetAttrib($args[0]) = "A" Then ;THIS IS A FILE local $OutputPath = _OutputPathFromFilePath() ;find output folder path based on full file path DirCreate($OutputPath) ;create output folder EndIf ProgressOn("PROCESSING FILES","Processing Files Now") $elements = UBound($args) $step = 100 / $elements local $done ;percentage finished ;step through array and optimise into results folder for $x = 0 to UBound($args)-1 $done += $step ProgressSet($done,"Processing Photos Now") If StringRight($args[$x],4) = ".jpg" OR StringRight($args[$x],5) = ".jpeg" Then $filename = StringSplit($args[$x],"\") $out = '"' & $OutputPath & "\" & $filename[$filename[0]] & '"' $in = '"' & $args[$x] & '"' $PID = RunWait(@ComSpec & " /c " & 'nconvert.exe -out jpeg -quiet -ratio -q 80 -resize 960 0 -o ' & $out & " " & $in, "", @SW_HIDE) STDIOClose($PID) EndIf Next ProgressSet(100 , "Done", "Complete") sleep(1000) ProgressOff() EndIf ;end of if IsArray($args) Func _GetFileList() ;return an array of all files in a folder local $text local $folderpath = $args[0] $StdOut = Run(@ComSpec & " /c " & 'dir "' & $args[0] & '" /s /b', "", @SW_HIDE, $StdOut_CHILD + $STDERR_CHILD) While 1 $line = StdoutRead($StdOut) If @error Then ExitLoop $text &= $line WEnd return StringRegExp($text, '((?<=\s"|^")[^"]+(?=")|[^\s"]+)', 3) ;make array of full paths to files in folders EndFunc ;==>_GetFileList Func _OutputPathFromFilePath() local $TempPath ;var to rebuild path $aPath = StringSplit($args[0],"\") ;split up full path to file into array delim by \ ;rebuild path using 2nd element through to 2nd last element for $x = 1 to $aPath[0] - 1 $TempPath &= $aPath[$x] if $x < $aPath[0]-1 then $TempPath &= "\" Next return $TempPath & "\ForFACEBOOK" EndFunc ; #FUNCTION# ========================================================================================================= ; Name...........: _CmdLineRaw() ; Description ...: Creates an Array of a $CmdLineRaw string. ; Syntax.........: _CmdLineRaw($sString) ; Parameters ....: $cString - $CmdLineRaw string. ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success - Array of $CmdLineRaw string. ; Failure - Returns 0 & sets @error = 1 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _CmdLineRaw($sString) If $sString = "" Then Return SetError(1, 0, 0) EndIf Local $aReturn = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sString, "wstr", "", "dword", 4096) If @error Then Return SetError(1, 0, 0) EndIf Return StringRegExp($aReturn[2], '((?<=\s"|^")[^"]+(?=")|[^\s"]+)', 3) EndFunc ;==>_CmdLineRaw Link to comment Share on other sites More sharing options...
guinness Posted October 11, 2011 Share Posted October 11, 2011 Nice idea! I didn't think about SendTo at the time as I was trying to concentrate on your problem first and foremost. Couple of suggestions, I've just this second updated _CmdLineRaw() with the number of strings found in the first element ($aArray[0]) OR in there is a function which does exactly the same as _CmdLineRaw() but using the Windows API instead >> _WinAPI_CommandLineToArgv(). And if you do go down the route of WinAPIEx.au3 then another function I would suggest is _WinAPI_PathIsDirectory()! Good luck. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JackDinn Posted November 11, 2011 Share Posted November 11, 2011 (edited) Hi,I did not think this project would be such a pain but it is turning out to be just that. Iv got 3 main problems that i just cant figure but this is the one id like to concentrate on atm.Im doing a "re-do" of the send-to context menu for win7 as they decided in there great wisdom to remove the ability to have folded sub-folders since vista.I have added the reg keys below to execute my app "V7SendTo.exe" [HKEY_CLASSES_ROOT*shellV7SendTo]"Icon"="shell32,43[HKEY_CLASSES_ROOT*shellV7SendTocommand]@="E:Program Files (x86)V7SendToV7SendTo.exe" "%1"[HKEY_CURRENT_USERSoftwareClassesFoldershellV7SendTo]"Icon"="shell32,43[HKEY_CURRENT_USERSoftwareClassesFoldershellV7SendTocommand]@="E:Program Files (x86)V7SendToV7SendTo.exe" "%1"which works (with some bugs , but we shall not dwell here atm).Now Iv been hitting my head against the OP's darn problem, thats to say im having real trouble parsing multiple selected files/folders to my app. Iv been working with your (@guinness) UDF WM_COPYDATA and i just cant get it to work properly :-/Heres what iv compiled and named "E:Program Files (x86)V7SendToV7SendTo.exe" , I select several files & click on the context command. It runs from the context fine but the parsed file names are not right ? sometimes it errors with "Seems there was an @error, but more than likely $CmdLineRaw was blank." but more often than not it generates an output with missing and/or multiple duplicate file names.expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ;~ #AutoIt3Wrapper_UseX64=Y #cs Thanks to the following for helping in the past ... KaFu for the idea from _EnforceSingleInstance(). Yashied for x64 support. #ce #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <misc.au3> #include <Timers.au3> #include <Debug.au3> Global $file = $CmdLine[$CmdLine[0]] & @CRLF Global $__InterCommunication[3] = ["-GUIHandle", "-ControlID", "-Data"] ; Internal array for the WM_COPYDATA functions. Global $time _Main() Func _Main() Local $iControlID $iControlID = _WM_COPYDATA_Start() ; Start the communication process. If @error Then If Not _WM_COPYDATA_Send($CmdLineRaw) Then ; Send $CmdLineRaw if there is process already running. MsgBox(64, "2nd Instance: " & @AutoItPID, "Seems there was an @error, but more than likely $CmdLineRaw was blank.") EndIf Exit EndIf _Singleton(@ScriptName) $time = _Timer_Init() While 1 Switch GUIGetMsg() Case $iControlID ; If the WM_COPYDATA message is interecepted then show your optimise function. _Optimise() EndSwitch If _Timer_Diff($time) > 2000 Then ExitLoop WEnd _DebugSetup("output") _DebugOut($file) Exit EndFunc ;==>_Main Func _Optimise() $file &= _WM_COPYDATA_GetFile() & @CRLF ;~ Return MsgBox(64, "1st Instance: " & @AutoItPID, _WM_COPYDATA_GetFile()) ; Get the WM_COPYDATA file. EndFunc ;==>_Optimise Func _WM_COPYDATA($hWnd, $iMsg, $iwParam, $ilParam) ; WM_COPYDATA function. #forceref $hWnd, $iMsg, $iwParam Local $tData, $tParam, $tString $tParam = DllStructCreate("ulong_ptr;dword;ptr", $ilParam) $tData = DllStructCreate("wchar[" & DllStructGetData($tParam, 2) / 2 & "]", DllStructGetData($tParam, 3)) $tString = DllStructGetData($tData, 1) $__InterCommunication[2] = BinaryToString($tString) GUICtrlSendToDummy($__InterCommunication[1]) EndFunc ;==>_WM_COPYDATA Func _WM_COPYDATA_GetFile() ; Retrieve the file passed via the 2nd instance. Return $__InterCommunication[2] EndFunc ;==>_WM_COPYDATA_GetFile Func _WM_COPYDATA_Send($sString) ; Send data to the 1st instance. Local $hHandle = $__InterCommunication[0], $ilParam, $tData If $hHandle = -1 Then Return SetError(1, 0, 0) EndIf If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf If $hHandle Then $tData = DllStructCreate("wchar[" & StringLen($sString) + 1 & "]") DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ulong_ptr;dword;ptr") DllStructSetData($ilParam, 1, 0) DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hHandle, $WM_COPYDATA, 0, DllStructGetPtr($ilParam)) Return Number(Not @error) EndIf EndFunc ;==>_WM_COPYDATA_Send Func _WM_COPYDATA_Start() ; Start the WM_COPYDATA process. Thanks to KaFu for introducing me to AutoItWinGetTitle()/AutoItWinSetTitle(). Local $hGUI, $hHandle, $sData = "D4672AD6-EA21-4FFD-88F5-4641A2B33E9F" $hHandle = WinGetHandle($sData) If @error Then AutoItWinSetTitle($sData) $hHandle = WinGetHandle($sData) $hGUI = GUICreate("", 0, 0, -99, -99, "", $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $hGUI) ControlSetText($hHandle, "", ControlGetHandle($hHandle, "", 'Edit1'), $hGUI) GUIRegisterMsg($WM_COPYDATA, "_WM_COPYDATA") $__InterCommunication[0] = -1 $__InterCommunication[1] = GUICtrlCreateDummy() Return SetError(0, 0, $__InterCommunication[1]) Else $hHandle = HWnd(ControlGetText($hHandle, '', ControlGetHandle($hHandle, '', 'Edit1'))) $__InterCommunication[0] = $hHandle Return SetError(1, 0, $hHandle) EndIf EndFunc ;==>_WM_COPYDATA_StartIt looks like its getting the right number of selected files but why is it repeating some and missing others ? I looked into the suggestions above about using FileMenu Tools but thats not a good answer for me as my app is meant for others to use and i cant really expect them to customize there context menus with another app.Any suggestions here, Cheers. Edited November 11, 2011 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted November 12, 2011 Share Posted November 12, 2011 Well with a little more tinkering and thinking on the problem i decided that it was trying to parse the data to fast, all the instances of the script that are executed (one for each selected file/folder) are trying to send there data across to the first instance at the same time and causing a "traffic jam" kinda thing. So iv tried to put all the subsequent instances (after the first instance) into a queue and then let them out one at a time with a slight delay between. It is working but its really messy, not terribly reliable, uses hight cpu & is to slow if you select a lot of files/folders ! There must be some better way to do all this , this is crazy . Anyhow, heres what iv got :- expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Tidy_Parameters=/rel #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("TrayIconHide", 1) ;~ #AutoIt3Wrapper_UseX64=Y #cs Thanks to the following for helping in the past ... KaFu for the idea from _EnforceSingleInstance(). Yashied for x64 support. #ce #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <misc.au3> #include <Timers.au3> #include <Debug.au3> #include <Array.au3> Global $file = '"' & $CmdLine[$CmdLine[0]] & '"' & @CRLF Global $__InterCommunication[3] = ["-GUIHandle", "-ControlID", "-Data"] ; Internal array for the WM_COPYDATA functions. Global $time _Main() Func _Main() Local $iControlID $iControlID = _WM_COPYDATA_Start() ; Start the communication process. If @error Then Sleep(1000); wait for all the multiples of this script to load (one for each selected file/folder), 1 sec should be enough $proceslist = ProcessList(@ScriptName) For $x = 1 To $proceslist[0][0] ;Hold all the processes with @scriptname in a queue Sleep(300) ;delay for each instance, THIS IS CAUSING A MASSIVE SLOWDOWN when a lot of files/folders are selected but if i lower it it starts "playing up" If $proceslist[$x][1] = @AutoItPID Then ExitLoop ; let out the instances of @scriptname's one at a time (by there PID) Next If Not _WM_COPYDATA_Send($CmdLineRaw) Then ; Send each instances $CmdLineRaw If @error Then Beep(1000, 100) EndIf Exit ; exit each instance of @scriptname as it "should have" sent its message EndIf SplashTextOn("","Processing....",400,100) Sleep(500); wait for the multiples of this script to load (one for each selected file/folder), less that 1 sec as to make sure this part is running before any $CmdLineRaw is sent over $proceslist = ProcessList(@ScriptName) While $proceslist[0][0] > 1 ; repeat checking for data until only 1 instance of @scriptname is left Switch GUIGetMsg() Case $iControlID ; If the WM_COPYDATA message is interecepted then show your optimise function. _Optimise() EndSwitch $proceslist = ProcessList(@ScriptName) WEnd ; wait for there to be only 1 instance of @scriptname left (This one "the first instance") before continuing SplashOff() If Not WinExists("[CLASS:Notepad]") Then Run("notepad.exe") sleep(1000) ControlSetText("[CLASS:Notepad]", "", "Edit1", $file) Exit EndFunc ;==>_Main Func _Optimise() $file &= _WM_COPYDATA_GetFile() & @CRLF EndFunc ;==>_Optimise Func _WM_COPYDATA($hWnd, $iMsg, $iwParam, $ilParam) ; WM_COPYDATA function. #forceref $hWnd, $iMsg, $iwParam Local $tData, $tParam, $tString $tParam = DllStructCreate("ulong_ptr;dword;ptr", $ilParam) $tData = DllStructCreate("wchar[" & DllStructGetData($tParam, 2) / 2 & "]", DllStructGetData($tParam, 3)) $tString = DllStructGetData($tData, 1) $__InterCommunication[2] = BinaryToString($tString) GUICtrlSendToDummy($__InterCommunication[1]) EndFunc ;==>_WM_COPYDATA Func _WM_COPYDATA_GetFile() ; Retrieve the file passed via the 2nd instance. Return $__InterCommunication[2] EndFunc ;==>_WM_COPYDATA_GetFile Func _WM_COPYDATA_Send($sString) ; Send data to the 1st instance. Local $hHandle = $__InterCommunication[0], $ilParam, $tData If $hHandle = -1 Then Return SetError(1, 0, 0) EndIf If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf If $hHandle Then $tData = DllStructCreate("wchar[" & StringLen($sString) + 1 & "]") DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ulong_ptr;dword;ptr") DllStructSetData($ilParam, 1, 0) DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hHandle, $WM_COPYDATA, 0, DllStructGetPtr($ilParam)) Return Number(Not @error) EndIf EndFunc ;==>_WM_COPYDATA_Send Func _WM_COPYDATA_Start() ; Start the WM_COPYDATA process. Thanks to KaFu for introducing me to AutoItWinGetTitle()/AutoItWinSetTitle(). Local $hGUI, $hHandle, $sData = "D4672AD6-EA21-4FFD-88F5-4641A2B33E9F" $hHandle = WinGetHandle($sData) If @error Then AutoItWinSetTitle($sData) $hHandle = WinGetHandle($sData) $hGUI = GUICreate("", 0, 0, -99, -99, "", $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $hGUI) ControlSetText($hHandle, "", ControlGetHandle($hHandle, "", 'Edit1'), $hGUI) GUIRegisterMsg($WM_COPYDATA, "_WM_COPYDATA") $__InterCommunication[0] = -1 $__InterCommunication[1] = GUICtrlCreateDummy() Return SetError(0, 0, $__InterCommunication[1]) Else $hHandle = HWnd(ControlGetText($hHandle, '', ControlGetHandle($hHandle, '', 'Edit1'))) $__InterCommunication[0] = $hHandle Return SetError(1, 0, $hHandle) EndIf EndFunc ;==>_WM_COPYDATA_Start Any help would be gratefully appreciated as im really out of my depth here. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
guinness Posted November 12, 2011 Share Posted November 12, 2011 (edited) This works for me. Also from what I can tell from your code you're closing instances of the application but this is all handled by _WM_COPYDATA_Start. Edited January 2, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JackDinn Posted November 12, 2011 Share Posted November 12, 2011 Hi, thx for your help here. Iv run your code , iv not touched a thing and i still get the same repeated / missed items :-Im using a brand new (well been installed a week or so) win7x64 SP1 installation , I haven't tried it on xp yet but i really need to figure out whats going on here first ? Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted November 12, 2011 Share Posted November 12, 2011 well iv tested on some VM win7 installations , these have just been freshly installed and it still does the sameIv tried it on both x64 and x86 , both fresh installations on VMWare. Iv been trying to debug and trace through whats going on with each instance & what each is trying to send but its really difficult as i cant use ConsoleWrite() , if i try to use a notepad to send data to they all get muddled which notepad window they should be sending there data to and i get all sorts of strange things. Im really scratching my head. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
guinness Posted November 12, 2011 Share Posted November 12, 2011 (edited) See the previous post. Also you will need so just place this in the same directory as where you save the script, as this is the correct approach to show an item in the contextmenu for Directories, Drives and Files. Another point to add is I tested previously using SendTo and not the contextmenu. Edited November 12, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JackDinn Posted November 12, 2011 Share Posted November 12, 2011 ok cheers , i will look into how to create the context menu item properly , thx. Do you think it might be the reason why its acting like this ? Also i know i mentioned "SendTo" but i dont want to run it from the actual sendto context menu i want a separate context menu item for my app. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
guinness Posted November 12, 2011 Share Posted November 12, 2011 Do you think it might be the reason why its acting like this ?Dunno.Updated previous example. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now