Jump to content
Sign in to follow this  
Kovacic

Drag and Drop files not working when compiled and RunAs used

Recommended Posts

Kovacic

I am working on a script that uses drag and drop, but is supposed to be run under different creds. I noticed Drag and dropping a file does nothing when the script is being Runas other credentials..

Try this..

Using the code below, compile it, then runas another user (another domain user preferably) and try to drag a file to it. Then try it without using RunAs..

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    GUICreate("Drop a file here", 220, 200, 100, 100, -1, $WS_EX_ACCEPTFILES)
    $listview = GUICtrlCreateLabel("Drag a file here", 10, 10, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUISetState()

    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_DROPPED
                Msgbox(0,"Found it!","Hey I see you dragged a file over:" & @CRLF & @GUI_DRAGFILE)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc

I tried compiling under X86 and X64 and in both cases, while running using runas does not show the file.

Has anyone found a fix for this?


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites
Jos

Try running SciTE or Notepad under different credentials or "Run as Admin", you will see that drag&drop doesn't work either.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Kovacic

Try running SciTE or Notepad under different credentials or "Run as Admin", you will see that drag&drop doesn't work either.

Jos

 

I dont use SciTE, but you think it might be a windows bug?


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites
Jos

I dont use SciTE, but you think it might be a windows bug?

Run any program that supports drag&drop.

... and likely you call that a feature not a bug.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Kovacic

Confirmed.

I tried running outlook under different credentials and creating a new email and I could not use drag and drop.

Looks like a windows security feature:

This is how the UAC works. Drag- and Drop are messages. And sending messages from a program with normal rights, to an application with admin rights can cause security issue.

Do Drag & Drop only work with application with the same rights (program with Admin rights to program with admin rights or program with normal rights to program with normal rights )

Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites
guinness

Search _WinAPI_ChangeWindowMessageFilterEx() or ...

#include <APIConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>
#include <WindowsConstants.au3>

Global $__aGUIDropFiles = 0

Example()

Func Example()
    Local $hGUI = GUICreate('WM_DROPFILES', 400, 200, Default, Default, Default, $WS_EX_ACCEPTFILES)
    If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW)
    If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW)

    Local Const $iDrop = GUICtrlCreateLabel('', 0, 0, 400, 200)
    GUICtrlSetBkColor($iDrop, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetState($iDrop, $GUI_DROPACCEPTED)

    GUISetState(@SW_SHOW, $hGUI)
    GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES')

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $GUI_EVENT_DROPPED
                For $i = 1 To $__aGUIDropFiles[0]
                    MsgBox($MB_SYSTEMMODAL, '', $__aGUIDropFiles[$i])
                Next

        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example

Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $lParam
    Switch $iMsg
        Case $WM_DROPFILES
            Local Const $aReturn = _WinAPI_DragQueryFileEx($wParam)
            If UBound($aReturn) Then
                $__aGUIDropFiles = $aReturn
            Else
                Local Const $aError[1] = [0]
                $__aGUIDropFiles = $aError
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DROPFILES
  • Like 1

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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  

  • Similar Content

    • robertcollier4
      By robertcollier4
      Hi - I am using $WS_EX_ACCEPTFILES and $GUI_DROPACCEPTED to have an Input control accept a filename. When a file is dragged into the input control and the keyboard caret is also focused in the input control - then the file name gets added at the location of the keyboard caret. What I would like is that whenever a file is dragged into the input control - that the file will replace the entire contents of the input control. Does anyone know how I can do this?
       
      Steps to reproduce problem:
      1. Drag a file into the input control. The filename will show in the input control.
      2. The filename will be selected. Press <right arrow> to unselect the text and move the keyboard caret to the right of the text.
      3. Drag a second file into the input control. PROBLEM: The input control will now have two filenames in it.
       
      Screenshot showing problem after two files have been dragged:

       
      Test Code:

      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $GUI = GUICreate("Test GUI", 800, 100, -1, -1, BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX ), $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_DROPPED, "On_Drop_InFilename") GUISetOnEvent($GUI_EVENT_CLOSE, '_exit') GUICtrlCreateLabel('File:', 2, 2) $inFilename = GUICtrlCreateInput('', 28, 0, 740, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) Func On_Drop_InFilename() Local $filename = GUICtrlRead($inFilename) If $filename <> "" Then ConsoleWrite("Drag drop found filename in input control: " & $filename & @LF) EndIf EndFunc Func _exit() Exit EndFunc While 1 Sleep(100) WEnd
×