Jump to content

Recommended Posts

Posted (edited)

hi i did this to create a mutliline inputbox,

Local $edit = GUICtrlCreateEdit("Drop Here", 20, 60, 400, 200, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE) ;

But i have some problems:

1. I want the box to empty, but if i remove "Drop here" i get an error

2. If i drop multiple files , each file has its own line like the documentation says, but if i want to add just one file to list, it is in the same line as the last one. So need an option like newContent -> newLine

3. After dropping files the dropped files are highlighted, and if i drop new the old entries are overwritten, i dont want the text to be highlighted after dropping

 

andy ideas?

Edited by apbonn
Posted (edited)

something like this ? 

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



Example()

Func Example()
    $mg=GUICreate("", 320,300, -1, -1, -1, $WS_EX_ACCEPTFILES) ; will create a dialog box that when displayed is centered

    Local $idMyedit = GUICtrlCreateEdit("" & @CRLF, 2, 2, 300, 300, bitOr($ES_AUTOVSCROLL , $WS_VSCROLL , $ES_MULTILINE ,$ES_WANTRETURN))
    GUISetState(@SW_SHOW)
    GUICtrlSetState($idMyedit,$GUI_DROPACCEPTED )
    
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $GUI_EVENT_DROPPED         
                ControlSend ($mg,"",$idMyedit,"^{end}")
                ControlSend ($mg,"",$idMyedit,"{enter}")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

 

Edited by Dan_555
Updated the code

Some of my script sourcecode

Posted

super nice, thank you :)

i dont know why, but if i drop i file there, i will also open the file in the application for it, so i drop a word file there, word will also open with the file?!

have an idea?

Posted (edited)

From the example which i have posted ?

The code does not open any external applications, at least not here. 

Maybe it is up to the

send ("{enter}")

?

Eventually you could add

WinWaitActive ($mg,"",2)

after 

 WinActivate ($mg) 

 

and see if that fixes the problem. 

After dropping a file, the code needs the gui window of the auto-it app to be active, then it first sends an "ctrl-end" key ( this removes the selection and places the cursor to the end of the file) and then the "enter" key to it, assuming that it is activated. 

if it is not activated, this enter key may get sent to your file manager, and execute the selected file there. But it does not do this here ...

 

And it looks like it does not do anything, if i drop files from the windows explorer.

I'm using FreeCommanderXE here, and it works as expected.

Edited by Dan_555

Some of my script sourcecode

Posted

i activated the wrong window, my fault, sorry :) now it works

and may you also know how i read every line after pressing the "check" button?

i a way where i call my function for each line ?

 

Posted

ok i got another idea, which sends the keys directly to the editbox:

 

use this code

; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $GUI_EVENT_DROPPED
                ControlSend ($mg,"",$idMyedit,"^{end}")
                ControlSend ($mg,"",$idMyedit,"{enter}")
        EndSwitch
    WEnd

 

Some of my script sourcecode

Posted

yes

here is a code, which i used to save the contents of an editbox into a file:

;Local $hFile = FileOpen($folder & $fname, $savetype)
        Local $LC = _GUICtrlEdit_GetLineCount($idMyedit)
        _GUICtrlEdit_BeginUpdate($idMyedit)
        For $x = 0 To $LC
            ;FileWriteLine($hFile, _GUICtrlEdit_GetLine($idMyedit, $x))            
            MsgBox (0,"Line " & $x, _GUICtrlEdit_GetLine($idMyedit, $x),3)
        Next
        _GUICtrlEdit_EndUpdate($idMyedit)

it should work with the above example, if you add it after the last ControlSend line.

And it needs #include <GuiEdit.au3> at the top.

Some of my script sourcecode

Posted

update, i did this

 

local $sFile1 = GUICtrlRead($hEdit)

Local $each = StringSplit($sfile1, "@CR") 
For $xyz = 1 to UBound($each) -1 
  MsgBox($MB_SYSTEMMODAL, "", $each[$xyz])
Next

this gives my by this input:

C:\Users\xy\Documents\sourcetree\resources\a\packages\graphics\cliparts\wedding.xml
C:\Users\xy\Documents\sourcetree\resources\a\packages\graphics\cliparts\nature.xml
C:\Users\xy\Documents\sourcetree\resources\a\packages\graphics\cliparts\ornaments.xml

this output by the MsgBox

EMPTY FIELD
:\Users\xy\Documents\sourcetree\resources\a\packages\graphics\cliparts\wedding.xml
:\Users\xy\Documents\sourcetree\resources\a\packages\graphics\cliparts\nature.xml
:\Users\xy\Documents\sourcetree\resources\a\packages\graphics\cliparts\ornaments.xml

why is there an empty field and why is the "C" missing of "C:\...." `?

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
  • Recently Browsing   0 members

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