Jump to content

Drag and Drop files not working when compiled and RunAs used


Kovacic
 Share

Recommended Posts

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( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

  • Developers

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

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

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

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

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

×
×
  • Create New...