Kovacic Posted February 21, 2014 Share Posted February 21, 2014 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 More sharing options...
Developers Jos Posted February 21, 2014 Developers Share Posted February 21, 2014 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 More sharing options...
Kovacic Posted February 21, 2014 Author Share Posted February 21, 2014 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( ͡° ͜ʖ ͡°) Link to comment Share on other sites More sharing options...
Developers Jos Posted February 21, 2014 Developers Share Posted February 21, 2014 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 More sharing options...
Kovacic Posted February 21, 2014 Author Share Posted February 21, 2014 (edited) 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 February 21, 2014 by Kovacic C0d3 is P0etry( ͡° ͜ʖ ͡°) Link to comment Share on other sites More sharing options...
guinness Posted February 21, 2014 Share Posted February 21, 2014 Search _WinAPI_ChangeWindowMessageFilterEx() or ... expandcollapse popup#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 Xandy 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
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