Sign in to follow this  
Followers 0
taras di

Perform functions usually in context menu

6 posts in this topic

Hi everyone,

Is there a way of writing a script that, when executed, will perform a specific action to the currently selected file in the active window that appears in the context menu?

(the action I'm trying to achieve is to obtain a lock on a file, which is actually a level deeper in the context menu)

I started to write this script by maneuvering the mouse pointer to the co-ordinates of the selected file (which I couldn't do), sending a 'right click', and then a series of arrow presses to navigate to the required context menu item, but I realised that, because my comptuer is awefully slow, the time between pressing right click and the context menu appearing can be quite long, and I don't want to have to hardcode the worst case wait into the script.

Thanks

Taras

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What you are probably needing to do is to get an object reference or other reference to the files and folders selected in explorer windows or the desktop. I haven't come across a way to do that in the forums yet, but I did find this code in VBScript that I converted into .au3 for executing a context menu items:

; Unpin from Start Menu
    $objShell = ObjCreate("Shell.Application")
    If IsObj($objShell) Then
        If FileExists($Registered_Install_Dir) Then
            $objFolder = $objShell.Namespace($Registered_Install_Dir)
            If IsObj($objShell) Then
                If FileExists($Registered_Install_Dir & "\" & $AppLinkName) Then
                    $objFolderItem = $objFolder.ParseName($AppLinkName)
                    If IsObj($objShell) Then
                        $objFolderItem.InvokeVerb("P&in to Start Menu")
                        Sleep(800)
                        $objFolderItem.InvokeVerb("Unp&in from Start menu")
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    Sleep(800)
    $objShell = ""
    $objFolder = ""
    $objFolderItem = ""

Notice that "P&in to Start Menu" is a string having the ampersand before the underlined keyboard shortcut key. If your keyboard shortcut keys aren't displaying, turn them on by using Control Panel > Display Properties > Appearance tab > Effects button and uncheck the last checkbox: Hide underlined...

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

Is there a way of writing a script that, when executed, will perform a specific action to the currently selected file in the active window that appears in the context menu?

You can deal with files direct. There is nothing special needed to do this and going through the explorer shell itself is a very much harder and no more of a solution then I mention of direct file interaction.

Share this post


Link to post
Share on other sites

I started to write this script by maneuvering the mouse pointer to the co-ordinates of the selected file (which I couldn't do), sending a 'right click', and then a series of arrow presses to navigate to the required context menu item, but I realised that, because my comptuer is awefully slow, the time between pressing right click and the context menu appearing can be quite long, and I don't want to have to hardcode the worst case wait into the script.

Once the file is selected, why not just send the <SHIFT><F10> key combo followed by arrow keys to simulate the right-click and navigation of the menu?

Doesn't help you with the wait but should save you having to find the selected file and right-click on it.

Share this post


Link to post
Share on other sites

How can I make the script wait for a context menu to appear?

I made a script that configures a fresh installation of Windows XP SP2 completely to my likeness (most of it from the registry), well, almost. I want to right click the desktop (I use controlsend +{F10} to progman) and make the script to wait for the context menu then I send CN (in spanish arrange/by name).

The script has been made for WXP in spanish but if you want I cant post it here (I have met AutoIt a couple of months ago so it grew very much. I still remember when it was just 30 lines and if I moved the mouse: crash. Now it has more than 100 lines to do the same thing and it is still growing :-D).

The problem is that, as a fresh installation, the display driver works awfully and the menu takes a while to appear on some machines. Also, one of the options that the script sets is the driver signing (none) and the windows update (not). That's why I don't install the drivers first. :)

If I can't figure it out I will put a sleep. :D


AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S

Share this post


Link to post
Share on other sites

Well... I think I will use Sleep(2500) after the mouse click

ControlClick("Program Manager","FolderView",1,"Right");Yes, although it's an spanish copy, this is in english :-#
Sleep(2500)
Send("CN!{F4}");Organizar i&conos/&Nombre | Arrange by name then Restart OS

AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0