Rishav Posted August 11, 2008 Posted August 11, 2008 (edited) Hi guys Just picked up AutoIt yesterday so don't know much about it. been playing with it, trying to automate some processes but didn't have much success with one action, which i am sure is quite easy. What i want to do is to select an entry from the windows context menu and click on it without using the keyboard shortcuts for the entries, mouse clicks or the arrow keys. I want to select the context menu entry based on the text label for that entry. so say, i have selected a folder and opened the right click context menu with the following items --Open --Edit --Close i want to click on Edit using its text label "Edit". But am out of ideas on how to proceed with it. The help file really wasn't much help with this. Most of the stuff went over my head. Searching the forum also didn't help much as i guess my keywords weren't good enough. Can anyone point me to the right direction with this? thanks and regards. Edited August 11, 2008 by Rishav
ptrex Posted August 11, 2008 Posted August 11, 2008 @Rishav If it is File related then this will get you going. ; Check if a valid file was specified $objFSO = ObjCreate( "Scripting.FileSystemObject" ) $strFile = "C:\_FileCopy.au3" ;!! If Not $objFSO.FileExists( $strFile ) Then ConsoleWrite($strFile & " Does not exist" & @CRLF) EndIf $strFolder = $objFSO.GetParentFolderName( $strFile ) $objFSO = "" ; Open the Shell Folders object $objShell = ObjCreate( "Shell.Application" ) ; Create an object for the specified file's parent folder $objFolder = $objShell.Namespace( $strFolder ) ; Create a collection for the folder's contents $colFiles = $objFolder.Items ; Loop through the collection to find the file specified If $colFiles.Count > 0 Then For $objFile In $colFiles If StringLower( $objFile.Path ) = StringLower($strFile ) Then ; Edit the file with its associated Context Menu command $objFile.InvokeVerbEx( "Edit Script" ) EndIf Next EndIf Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Rishav Posted August 12, 2008 Author Posted August 12, 2008 Thanks for the reply ptrex. perhaps it will be better if i am more specific.The exact action i want to perform is to click the "TortoiseSVN" and then the "Export" entry from the windows context menu.Selecting the proper folder and bringing up the right click menu has been somewhat easy with the following code.ShellExecute("explorer.exe", "/n,/select," & "C:\TEMP\Test") WinWaitActive("[CLASS:CabinetWClass]") Send("{APPSKEY}")but i don't know how to go about selecting a specific context menu element.currently i am doingSend("{down}") 15 timesand thenSend("{Enter}")which i feel to be extremely inelegant.
weaponx Posted August 14, 2008 Posted August 14, 2008 (edited) You are going about this the wrong way altogether. The context menus are all stored in the registry, along with the actual instruction itself. In this case clicking TortoiseSVN -> Export actually just passes the name of the folder to a command line exe.You need to find the command that is passed and simply write a function that takes a folder path as a parameter, none of this silly trying to automate explorer.exe.See here to find the command:http://windowsxp.mvps.org/context_folders.htmEven better, here are the TortoiseSVN command line options:http://tortoisesvn.net/docs/release/Tortoi...automation.htmlIt looks like export just copies the folder to another location, are you sure this is something you can't do with DirCopy? Edited August 14, 2008 by weaponx
Rishav Posted August 14, 2008 Author Posted August 14, 2008 I didn't know that at all. I'll spike a bit with that. Thanks a lot weaponx and ptrex. you guys were quite helpful.
Rishav Posted August 14, 2008 Author Posted August 14, 2008 weird. i can't edit my posts anymore... @weapon, about the export, it isn't really the option i need. i just want to update svn but those options weren't available while i was taking the screenshot. it was just a general example i wanted to give. we can also take Context Menu >> "Winrar">> "Add to zip" as the example. by the way, i did read those articles you pointed me to. i think the tortoise command line parameters will serve my purpose but i am sure that sooner or later i will come across an issue where i have to use the windows context menus. while i did get the idea of registry entries from the first article, i still don't know how to invoke them. googling didn't help much either. any further advices?
weaponx Posted August 14, 2008 Posted August 14, 2008 (edited) When you right click a folder/file and choose a context menu entry, the only "magic" that is performed is inserting the path into a command line string.Check out this program called ShellMenuView, it will list most of the context menu handlers on your system:http://www.nirsoft.net/utils/shell_menu_view.htmlFor example, the handler for right-clicking on an mp3:Open:"C:\Program Files\Winamp\winamp.exe" "%1"Enqueue:"C:\Program Files\Winamp\winamp.exe" /ADD "%1"The %1 is replaced with the filename you clicked on, thats all there is to it. Edited August 14, 2008 by weaponx
Rishav Posted August 14, 2008 Author Posted August 14, 2008 like appwiz just invokes the msiexec /y {reg uninstall key} command? Neat! will read some more and experiment, and let you know if i was successful. thanks a lot for pointing me in the right direction.
aria Posted September 4, 2008 Posted September 4, 2008 (edited) .... and simply write a function that takes a folder path as a parameter, none of this silly trying to automate explorer.exe.....Little confused - how do I get the %1% value (which is the file/folder path) of the selected object ?? (I see similar command strings in the registry)If this is possible, then I would love to write a keyboard shortcut which will copy the selected file/folder path to clipboard! - without having to open the context menu. Edited September 4, 2008 by aria
speck Posted November 13, 2009 Posted November 13, 2009 Little confused - how do I get the %1% value (which is the file/folder path) of the selected object ?? (I see similar command strings in the registry) If this is possible, then I would love to write a keyboard shortcut which will copy the selected file/folder path to clipboard! - without having to open the context menu. I've not fully understanding of your problem but you should take a look at this ShellExecute($var,"","","Enqueue") $var is the path.... Hope i helped.. SpecK the finest Blues Jazz Rock by VL and SpecKtotallynoob.com tutorials about SysAdmins NetAdmins SecAdmins
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