Sign in to follow this  
Followers 0
ViciousXUSMC

Drag Drop GUi working in Win7 but not Win8

4 posts in this topic

I just finished this up the other day and was all happy about it, today I go to put it to work and find that for some reason Windows 8 is not taking any drag/drop input.  So the Edit boxes in this GUI never get the file path or trigger the functions.

I only found one thread searching for similar issues and its over a year old with no answer so I hope to maybe figure this out.

My Code:

#RequireAdmin
#Include <_Startup.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Run At Startup Installer", 530, 186, 192, 124, -1, $WS_EX_ACCEPTFILES)
$Edit1 = GUICtrlCreateEdit("", 24, 72, 185, 89)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetData(-1, "")
$Edit2 = GUICtrlCreateEdit("", 248, 72, 185, 89)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("Install To Startup", 64, 32, 84, 17)
$Label2 = GUICtrlCreateLabel("Install To Registry", 296, 32, 88, 17)
$Checkbox1 = GUICtrlCreateCheckbox("All Users", 64, 48, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("All Users", 296, 48, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Uninstall", 64, 162, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Uninstall", 296, 162, 97, 17)
$Label3 = GUICtrlCreateLabel("Drag and Drop Item to Install", 112, 0, 238, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Radio1 = GUICtrlCreateRadio("Always", 438, 76, 113, 17)
$Radio2 = GUICtrlCreateRadio("RunOnce", 438, 92, 113, 17)
$Radio3 = GUICtrlCreateRadio("RunOnceEX", 438, 108, 113, 17)
GUICtrlSetState($Radio1, $GUI_CHECKED)
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
GUICtrlSetState($Checkbox2, $GUI_CHECKED)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            If @GUI_DropId = 3 AND GUICtrlRead($Checkbox3) = $GUI_UNCHECKED Then LeftBoxInstall()
            If @GUI_DropID = 3 AND GUICtrlRead($Checkbox3) = $GUI_CHECKED Then LeftBoxUninstall()
            If @GUI_DropID = 4 AND GUICtrlRead($Checkbox4) = $GUI_UNCHECKED Then RightBoxInstall()
            If @GUI_DropID = 4 AND GUICtrlRead($Checkbox4) = $GUI_CHECKED Then RightBoxUnInstall()

    EndSwitch
WEnd

Func LeftBoxInstall()
            If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $data =  GUICtrlRead($Edit1)
            $aSplitData = StringSplit($data, @CRLF, 3)
            ;Debut See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupFolder_Install($sName, $sFilePath, "", $bAllusers)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit1, "")
EndFunc

Func LeftBoxUninstall()
    If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $data =  GUICtrlRead($Edit1)
            $aSplitData = StringSplit($data, @CRLF, 3)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupFolder_Uninstall($sName, $sFilePath, $bAllusers)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit1, "")
EndFunc

Func RightBoxInstall()
    If GUICtrlRead($CheckBox2) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $iRunOnce = CheckRadio()

            $data =  GUICtrlRead($Edit2)
            $aSplitData = StringSplit($data, @CRLF, 3)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupRegistry_Install($sName, $sFilePath, "", $bAllusers, $iRunOnce)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit2, "")
EndFunc

Func RightBoxUnInstall()
    If GUICtrlRead($CheckBox2) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $iRunOnce = CheckRadio()

            $data =  GUICtrlRead($Edit2)
            $aSplitData = StringSplit($data, @CRLF, 3)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupRegistry_Uninstall($sName, $sFilePath, $bAllusers, $iRunOnce)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit2, "")
EndFunc

Func CheckRadio()
    If GUICtrlRead($Radio1) = $GUI_CHECKED Then Return $STARTUP_RUN
    If GUICtrlRead($Radio2) = $GUI_CHECKED Then Return $STARTUP_RUNONCE
    If GUICtrlRead($Radio3) = $GUI_CHECKED Then Return $STARTUP_RUNONCEEX
EndFunc

If you want to try full working function the UDF is Guinness's

Share this post


Link to post
Share on other sites



A program run with admin privileges can't accept dropped files from a program at a lower privilege setting. An easy way to demonstrate it is to open a command prompt as Administrator, then open Windows Explorer using regular account access (even if you're an admin on the computer) and try to drag a file to the command window, it won't allow it to happen.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I am both domain and local admin on the Windows 8 machines that I have tested this one.

While what you said does make sense, I do not see how that is the issue.  However I will take out #RequireAdmin and see what happens.

My concern at that point however is you need Admin level privileges to write to HKLM registry or place files in the All Users Startup Folder. 

Edit: Yes this seems to be the issue, but odd the Windows 8 exibits it while Windows 7 does not.  If I take out #RequireAdmin I can use the drag & drop, but as expected I can only work on current user changes not global as those take admin rights. 

Edited by ViciousXUSMC

Share this post


Link to post
Share on other sites

Ok due to the circumstances I re-worked this and while it has drag/drop still built in.  For situations where it does not work, there is now Browse capabilities.

A few new tricks I learned and also my first time using FileOpenDialog wich proposed a neat challenge with how it writes the string for multiple files.

Everything appears working and maybe a few of the little tricks I used could be of help to somebody else or get me some critique from the more expert users.

#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <_Startup.au3>
#include <FileConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Users\it022565\Desktop\Install Startup Browse.kxf
$Form1 = GUICreate("Black Magic Automation", 576, 216, 192, 124, -1, $WS_EX_ACCEPTFILES)
$Label1 = GUICtrlCreateLabel("Browse or Drag/Drop Item(s) to Install", 102, 0, 327, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Install To Startup Folder", 72, 24, 116, 17)
$Label3 = GUICtrlCreateLabel("Install To Registry", 344, 24, 88, 17)
$Edit1 = GUICtrlCreateEdit("", 40, 72, 185, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetData(-1, "")
$Edit2 = GUICtrlCreateEdit("", 296, 72, 185, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Browse", 88, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Browse", 352, 40, 75, 25)
$Radio1 = GUICtrlCreateRadio("Always", 488, 80, 113, 17)
$Radio2 = GUICtrlCreateRadio("RunOnce", 488, 96, 113, 17)
$Radio3 = GUICtrlCreateRadio("RunOnceEX", 488, 112, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("All Users", 40, 160, 73, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Uninstall", 160, 160, 73, 17)
$Button3 = GUICtrlCreateButton("GO!", 88, 184, 75, 25)
$Checkbox3 = GUICtrlCreateCheckbox("All Users", 296, 160, 73, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Uninstall", 416, 160, 65, 17)
$Button4 = GUICtrlCreateButton("GO!", 352, 184, 75, 25)
GUISetState(@SW_SHOW)
GUICtrlSetState($Radio1, $GUI_CHECKED)
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
GUICtrlSetState($Checkbox3, $GUI_CHECKED)
#EndRegion ### END Koda GUI section ###

Global $vParsedLeft
Global $vParsedRight

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $vLeftBrowse = FileOpenDialog("Please Select Files", @ScriptDir, "All (*.*)", $FD_MULTISELECT)
            $aLeftParsed = StringSplit($vLeftBrowse, "|", $STR_NOCOUNT)
            If UBound($aLeftParsed) = 1 Then
                $vParsedLeft &= $aLeftParsed[0] & @CRLF
            Else
                For $i = 1 to UBound($aLeftParsed) -1
                $vParsedLeft &= $aLeftParsed[0] & "\" & $aLeftParsed[$i] & @CRLF
                Next
            EndIf
            $vParsedLeft = StringReplace($vParsedLeft, @CRLF, "", -1)
            GUICtrlSetData($Edit1, $vParsedLeft)
            $vParsedLeft = ""
        Case $Button2
            $vRightBrowse = FileOpenDialog("Please Select Files", @ScriptDir, "All (*.*)", $FD_MULTISELECT)
            $aRightParsed = StringSplit($vRightBrowse, "|", $STR_NOCOUNT)
            If UBound($aRightParsed) = 1 Then
                $vParsedRight &= $aRightParsed[0] & @CRLF
            Else
                For $i = 1 to UBound($aRightParsed) -1
                $vParsedRight &= $aRightParsed[0] & "\" & $aRightParsed[$i] & @CRLF
                Next
            EndIf
            $vParsedRight = StringReplace($vParsedRight, @CRLF, "", -1)
            GUICtrlSetData($Edit2, $vParsedRight)
            $vParsedRight = ""
        Case $Button3
            If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then
            LeftBoxInstall()
            Else
            LeftBoxUninstall()
            EndIf
        Case $Button4
            If GUICtrlRead($Checkbox4) = $GUI_UNCHECKED Then
            RightBoxInstall()
            Else
            RightBoxUninstall()
            EndIf
    EndSwitch
WEnd

Func LeftBoxInstall()
            If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $data =  GUICtrlRead($Edit1)
            $aSplitData = StringSplit($data, @CRLF, $STR_ENTIRESPLIT + $STR_NOCOUNT)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupFolder_Install($sName, $sFilePath, "", $bAllusers)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit1, "")
EndFunc

Func LeftBoxUninstall()
    If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $data =  GUICtrlRead($Edit1)
            $aSplitData = StringSplit($data, @CRLF, $STR_ENTIRESPLIT + $STR_NOCOUNT)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupFolder_Uninstall($sName, $sFilePath, $bAllusers)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit1, "")
EndFunc

Func RightBoxInstall()
    If GUICtrlRead($CheckBox3) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $iRunOnce = CheckRadio()

            $data =  GUICtrlRead($Edit2)
            $aSplitData = StringSplit($data, @CRLF, $STR_ENTIRESPLIT + $STR_NOCOUNT)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupRegistry_Install($sName, $sFilePath, "", $bAllusers, $iRunOnce)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit2, "")
EndFunc

Func RightBoxUnInstall()
    If GUICtrlRead($CheckBox3) = $GUI_CHECKED Then
                $bAllusers = True
            Else
                $bAllusers = False
            EndIf

            $iRunOnce = CheckRadio()

            $data =  GUICtrlRead($Edit2)
            $aSplitData = StringSplit($data, @CRLF, $STR_ENTIRESPLIT + $STR_NOCOUNT)
            ;Debug See what is in Array
            ;_ArrayDisplay($aSplitData)
            For $i = 0 to UBound($aSplitData) - 1
            ;Debug See what current file is in Array
            ;MsgBox(0, "", $aSplitData[$i])
            $sFilePath = ($aSplitData[$i])
            $sName = StringTrimLeft($sFilePath, StringinStr($sFilePath, "\", 0, -1))
            _StartupRegistry_Uninstall($sName, $sFilePath, $bAllusers, $iRunOnce)
            ;Debug See full varible list sent to Function
            ;MsgBox(0, "", $sName & @CRLF & $sFilePath & @CRLF & $bAllusers)
            Next

            GUICtrlSetData($Edit2, "")
EndFunc

Func CheckRadio()
    If GUICtrlRead($Radio1) = $GUI_CHECKED Then Return $STARTUP_RUN
    If GUICtrlRead($Radio2) = $GUI_CHECKED Then Return $STARTUP_RUNONCE
    If GUICtrlRead($Radio3) = $GUI_CHECKED Then Return $STARTUP_RUNONCEEX
EndFunc

 

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