Jump to content

ControlSend Not Always Sending To Active Window


Recommended Posts

To grab the selected file names from the active windows explorer, I've been using a trick from this thread (code below):

http://www.autoitscript.com/forum/index.php?showtopic=96598&st=0&p=695101&hl=egg%20crack&fromsearch=1&#entry695101

It's been working like a charm, but yesterday, when I had a bunch of explorer windows open, it stopped working. After investigating, I figured out that my script was sending its keystroke to the wrong explorer window. If I closed all the windows, and re-opened just the window I wanted, it worked again.

However, I was under the impresson that ControlSend would default to the active window when it could match more than one window. Is this incorrect? Is there a way to make it default to the active window, as this is the behavior I want?

Thanks,

Jonah

;returns an array of full pathnames to selected files
Func _ExplorerGetSelectedItems()
    Local $sOrigin_ClipGet = ClipGet()
    ClipPut("")
   
    If ControlSend("[CLASS:CabinetWClass]", "", "SysListView321", "^{INSERT}") = 0 Then 
        MsgBox(4096, "Error", "Clipboard copy error")
        Return ClipPut($sOrigin_ClipGet)
    EndIf
   
    Local $sClipGet = ClipGet()
    Local $iTimer = TimerInit()
   
    While $sClipGet == "" And TimerDiff($iTimer) < 7000 ;wait for filenames to copy to clipboard
        Sleep(10)
        $sClipGet = ClipGet()
    WEnd
   
    ClipPut($sOrigin_ClipGet)
   
    If $sClipGet == "" Then 
        MsgBox(4096, "Error", "No files Selected")
        Return -1
    EndIf
    Return StringSplit($sClipGet, @LF)
EndFunc
Edited by gamingmouse
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...