Jump to content

Command line support for gui ?


Thlitmi
 Share

Recommended Posts

Have you ever searched in help file?

I assume not. Here one code from the help file:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $file, $btn, $msg

    GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlCreateInput("", 10, 35, 300, 20)     ; will not accept drag&drop files
    $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                ExitLoop
        EndSelect
    WEnd

    MsgBox(4096, "drag drop file", GUICtrlRead($file))
EndFunc   ;==>Example

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I think I need to be more specific.

To start my gui program in command line:

>prog.exe c:\prog\skype\usr\abi\afgr.jpg

It will run my application where there I will see my editbox filled with (c:\prog\skype\usr\abi\afgr.jpg)

Is it what we are talking about ?

I am not talking about dragging file to a proram window.

Link to comment
Share on other sites

Thank you for the code :x

I could not search it, because I did not know what keywords to use. Search does not show drag and drop.

I hope I am gonna be lucky and find the command line section. It is now showed either.

//Biiiig

//Edit:

"It is now showed either."

to

"It is not showed either."

Edited by Thlitmi
Link to comment
Share on other sites

Before I go sleep,

$CmdLine[1] will always hold string c:\prog\skype\usr\abi\afgr.jpg because I started ( >prog.exe c:\prog\skype\usr\abi\afgr.jpg )

?

After reading help file,I think this should be automaticly set.

If $CmdLine[1] will be automaticly created I can easily work with it.

Link to comment
Share on other sites

  • Moderators

Thlitmi

If $CmdLine[1] will be automaticly created

The $CmdLine array is created automatically.

Sleep well! :x

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

So, there is the magic . . . :x

$Form1_1 = GUICreate("Make AVS", 634, 180, 192, 114,-1, $WS_EX_ACCEPTFILES)
-1, $WS_EX_ACCEPTFILES
Dim $param
if $CmdLine[0]=1 Then $param=$CmdLine[1]
$Input1 = GUICtrlCreateInput($param, 8, 32, 601, 21)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
I do not fully know how it works, but it seems I can use it .. . :-D

But, it seems there is no help section for anywhere drop.

Currently I have to drop file to the edit box. How to make it work to drop it anywhere in the program window including buttons ?

and

http://www.youtube.com/watch?v=yb7W8mwYgD4

0:08 , Yes :P It react on a command line :shifty:

0:13 , No :lol: , it mixes file paths :(

0:36 , Yes :nuke: It react on drag&drop and adds filepath

0:51 , No :D It does not react on drag&drop in all of its window,I have to drag it only at input box. (How to make it on full window?)

So, what I need to fix.... :

1.After starting with commandline parameter, it mixes filepaths by drag&drop

2.drag&drop works only on a position of input box, I need full window.

I have really no ideat what search keywords to use to find an answer in help file and forum.

Link to comment
Share on other sites

  • Moderators

Thlitmi,

I hope you slept well. :P

Drag and Drop will only work on controls within a $WS_EX_ACCEPTFILES GUI styled which themselves have the $GUI_DROPACCEPTED state set - you cannot just drop on the GUI itself. In your snippet, you have set the input to that style, so the input will accept the drop. If you set the other controls to the $GUI_DROPACCEPTED state, they too will accept the drop as this short script shows:

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

$hGUI = GUICreate("Test", 500, 500, -1, -1, -1, BitOr($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST))

$hInput = GUICtrlCreateInput("fred fred fred fred", 10, 10, 200, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
ConsoleWrite("Input = " & $hInput & @CRLF)

$hButton = GUICtrlCreateButton("Test", 10, 50, 200, 500)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
ConsoleWrite("Button = " & $hButton & @CRLF)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            ; Just to show that both controls accept the drop
            ConsoleWrite("Control " & @GUI_DropID & " received DragFile " & @GUI_DragFile & @CRLF)
            ; Reset the data in the input to prevent the "mixing"
            GUICtrlSetData($hInput, @GUI_DragFile)
    EndSwitch

WEnd

You can also see how to prevent the "mixing" when you drop - use GUICtrlSetData to put only the dropped filename into the control, overwriting what was there before. :shifty:

All clear? :x

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

:x

"Drag and Drop will only work on controls within a $WS_EX_ACCEPTFILES GUI styled which themselves have the $GUI_DROPACCEPTED state set"

So all buttons, checkboxes etc. will accept drag,drop, but will they send it to input box ? It yet does not mean, that the whole window will accept drag,drop ?

"If you set the other controls to the $GUI_DROPACCEPTED state, they too will accept the drop"

This is what I though too, but I did not know whether they will send it to inputbox and I did not expected it, it seemed like not logic.

Can I ignore this $WS_EX_TOPMOST in this case ? It does not work with dropping right ?

By BitOr you transfer text in to numbers for autoit right ? I think it is not needed,because it worked to me as I showed.

I also do not need to use ConsoleWrite right ? In a button case, this would write file path to a colsole which I dropped to a button right ?

And

Case $GUI_EVENT_DROPPED

GUICtrlSetData($hInput, @GUI_DragFile)

Will overwrite editbox by dragged file path, now I know :P

It seems, the buttons would never send dropped filepath to inputbox

I have to make them aware about dropping(setState) (make them accept dropping)

And it is loop who can read and send dropped filepath from buttons to the inputbox.(GUI_EVENT_DROPPED -- SetData)

And it is probably not possible to drag it here just on a program window:

Posted Image

When you showed me GUI_EVENT_DROPPED in the loop, that was what I was looking for at the begin :shifty: Because it sends dropping to input line.

So now I know how it works in this simple gui :nuke:

When Ill make advanced guis with more stuff and different droppings I expect that I will know all I will need to know and be able to build it thanks to the functions. So I think I do not need to ask now :lol:

So again: :(

1.WS_EX_ACCEPTFILES -- allows gui to accept dragging

2.GUICtrlSetState(-1, $GUI_DROPACCEPTED) -- this is the real first time the input line will start accept dragging

3.anything like step 2. + loop $GUI_EVENT_DROPPED --> GUICtrlSetData($Input1, @GUI_DragFile) will make anything to send dropped filepath to inputline rewriting its value (which is before dropped filepath).

Now it is fully functional program :D

I think all is clear :)

"If you set the other controls to the $GUI_DROPACCEPTED state, they too will accept the drop"

No, until there is a loop watching it, right ? :)

Link to comment
Share on other sites

  • Moderators

Thlitmi,

What a lot of questions! :nuke:

OK, we will work through them one by one:

1. - Drag and Drop:

You seem to have the idea now. You can drop on any controls set to the $GUI_DROPACCEPTED state in a $WS_EX_ACCEPTFILES styled GUI, but you need trap the $GUI_EVENT_DROPPED event to do anything about it. To the best of my knowledge you cannot just drop on the GUI itself - but you can fill those little gaps with labels if you want to - they too will accept the drop if activated as you can see here:

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

$hGUI = GUICreate("Test", 500, 500, -1, -1, -1, BitOr($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST))

$hInput = GUICtrlCreateInput("fred fred fred fred", 10, 10, 200, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
ConsoleWrite("Input = " & $hInput & @CRLF)

$hButton = GUICtrlCreateButton("Test", 10, 50, 80, 30)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
ConsoleWrite("Button = " & $hButton & @CRLF)

$hLabel = GUICtrlCreateLabel("", 10, 100, 200, 200)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetBkColor(-1, 0xFF0000)
ConsoleWrite("Label = " & $hLabel & @CRLF)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            ConsoleWrite("Control " & @GUI_DropID & " received DragFile " & @GUI_DragFile & @CRLF)
            GUICtrlSetData($hInput, @GUI_DragFile)
    EndSwitch

WEnd

But be very careful - if you overlap controls then you run into problems. I would recommend that you colour the labels initially to make sure you have them just filling the space - you can then make them invisible or the same colour as the GUI once you have them the correct size. :shifty:

Even if you trap the $GUI_EVENT_DROPPED event, you still have to code what you want to happen - unless you use the GUICtrlSetData command, the filename will not appear in the input, even though the drop event was trapped.

The ConsoleWrite line was just there to show you that the various controls accepted a drop - you can safely delete it. :x

2. - $WS_EX_TOPMOST

I used this just to keep the GUI on top of my large Explorer window - you do not need it for the drag-and-drop to work.

3. - BitOR

You use this when you combine style and extended styles. Look at the Setting Styles tutorial in the Wiki to see why you need to use this command to get what you want. :P

Any more questions for the moment? :lol:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Thlitmi,

I do not combine, so I do not use it right ?

Right! :x

But read the Wiki tutorial I linked to and you will see why you must use it if you do combine. :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Recently Browsing   0 members

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