small project Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

small project

17 Nov 2017, 16:32

Hello i am working on a small project and need help to make the scrips.

I am using AutoGUI.
I created 2 edit boxes with 2 variables.
vVouch to input names
vReason to input reasons
And i have 2 buttons
vVouchUser
vAddToList
And a ListBox
vListBox
so i need help making scrips that can do this:
when i type names in vVouch i need to things to happen
1 if i press on the vVouchUser i want to sendinput the a string and vVouch
2 if i press on the vAddToList every type i type a name in vVouch i want the names to show in vListBox so i will have many names.

Code:

Code: Select all

; Generated by AutoGUI 1.4.9a
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Gui Add, Edit, vVouch x56 y56 w120 h21
Gui Add, Edit, vReason x56 y96 w120 h21
Gui Add, Button, vVouchUser x192 y56 w80 h18, &VouchUser
Gui Add, Button, vAddToList x280 y56 w80 h19, &AddToList
Gui Add, ListBox, vListBox x56 y152 w121 h199

Gui Show, w481 h379, Window
Return

GuiEscape:
GuiClose:
    ExitApp
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: small project

17 Nov 2017, 18:57

See glabels for executing actions when buttons are pressed, Gui, Submit command to retrieve the values of the Edit controls, and GuiControl for updating the contents of ListBox.
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

Re: small project

18 Nov 2017, 18:46

ok so i took a look and came up with this but its still not showing my input in the listbox when ever i press AddToList
i want every time i type a name it show up in the List box

Code: Select all

Gui, Add, Text,, Nick name:
Gui, Add, Text,, Reason:
Gui, Add, Text,, Duration:
Gui, Add, Edit, vNickname ym
Gui, Add, Edit, vReason
Gui, Add, Edit, vDuration
Gui, Add, ListBox, vMyListBox
Gui, Add, Button, default, Ban
Gui, Add, Button, default, AddtoList
Gui, Show


ButtonAddToList:
GuiControl,, MyListBox, %Nickname%
Gui, Show
return
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: small project

18 Nov 2017, 18:54

Mightykiller wrote:ok so i took a look and came up with this but its still not showing my input in the listbox when ever i press AddToList
i want every time i type a name it show up in the List box

Code: Select all

Gui, Add, Text,, Nick name:
Gui, Add, Text,, Reason:
Gui, Add, Text,, Duration:
Gui, Add, Edit, vNickname ym
Gui, Add, Edit, vReason
Gui, Add, Edit, vDuration
Gui, Add, ListBox, vMyListBox
Gui, Add, Button, default, Ban
Gui, Add, Button, default, AddtoList
Gui, Show


ButtonAddToList:
GuiControl,, MyListBox, %Nickname%
Gui, Show
return
The variable associated to your edit box has no way to pass any values.
You need to either attach a label to your edit box that has Gui,Submit,NoHide
or your button label needs to have it.

Just because you type in the edit box does not mean that things are automatically going to happen.
As far as it is concerned it is just a bunch of pixels on your screen, you need to program what happens when there is some sort of interaction with those pixels.

The simplest way for what you have is to just add "Gui,Submit,NoHide" as soon as the "ButtonAddToList" label is entered.
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

Re: small project

18 Nov 2017, 19:10

Every time i add a label i get an error "target label does not exist" in Gui, Add, Edit, vNickname gNickname ym

Code: Select all

Gui, Add, Text,, Nick name:
Gui, Add, Text,, Reason:
Gui, Add, Text,, Duration:
Gui, Add, Edit, vNickname gNickname ym
Gui, Add, Edit, vReason
Gui, Add, Edit, vDuration
Gui, Add, ListBox, vMyListBox
Gui, Add, Button, default, Ban
Gui, Add, Button, default, AddtoList
Gui, Show
Gui,Submit, NoHide
GuiControl, , MyListBox, %gNickname%
Gui, Show
return
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

Re: small project

18 Nov 2017, 19:12

i am just new i don't understand how this works :s
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: small project

18 Nov 2017, 19:17

I have a video series that can help.
https://www.youtube.com/playlist?list=P ... 4yy8y7m7US

Check video 3 for attaching labels

Check videos 9 and 10 for passing values
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: small project  Topic is solved

18 Nov 2017, 20:15

In order for your buttons to do anything, you need to define subroutines to call, and those subroutines should contain the Gui, Submit and GuiControl lines. Try something like this:

Code: Select all

Gui, Add, Text,, Nick name:
Gui, Add, Edit, vNickname
Gui, Add, Text,, Reason:
Gui, Add, Edit, vReason
Gui, Add, Text,, Duration:
Gui, Add, Edit, vDuration
Gui, Add, Button, gBan, Ban
Gui, Add, Button, default gAddtoList, Add to List
Gui, Add, Text,, Ban list:
Gui, Add, ListBox, vMyBanListBox
Gui, Add, Text,, Add list:
Gui, Add, ListBox, vMyListBox
Gui, Show
return

Ban:
Gui, Submit, NoHide
GuiControl,, MyBanListBox, %Nickname% %Reason% %Duration%
GuiControl,, Nickname
GuiControl,, Reason
GuiControl,, Duration
return

AddtoList:
Gui, Submit, NoHide
GuiControl,, MyListBox, %Nickname% %Reason% %Duration%
GuiControl,, Nickname
GuiControl,, Reason
GuiControl,, Duration
return
For example, when you press the button labeled "Add to list", it'll call the subroutine named AddtoList, which will save (submit) the contents of your three edit fields to their respective variables, then GuiControl will update your list box with their contents.

Edit: Here's a version for you with better positioning of elements and a separate ban list:

Code: Select all

Gui, Add, Text, x10 y10 h25, Nickname:
Gui, Add, Edit, x70 y7 w320 vNickname
Gui, Add, Text, x10 y35 h25, Reason:
Gui, Add, Edit, x70 y32 w320 vReason
Gui, Add, Text, x10 y60 h25, Duration:
Gui, Add, Edit, x70 y57 w320 vDuration
Gui, Add, Button, x95 y85 w100 h25 default gAddtoList, Add to List
Gui, Add, Button, x215 y85 w100 h25 gBan, Ban
Gui, Add, Text, x10 y120, Add list:
Gui, Add, ListBox, x10 y135 w380 h150 vMyListBox
Gui, Add, Text, x10 y295, Ban list:
Gui, Add, ListBox, x10 y310 w380 h150 vMyBanListBox
Gui, Show, w400 h468
return

AddtoList:
Gui, Submit, NoHide
GuiControl,, MyListBox, %Nickname% %Reason% %Duration%
GuiControl,, Nickname
GuiControl,, Reason
GuiControl,, Duration
return

Ban:
Gui, Submit, NoHide
GuiControl,, MyBanListBox, %Nickname% %Reason% %Duration%
GuiControl,, Nickname
GuiControl,, Reason
GuiControl,, Duration
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: dipahk, Nerafius and 198 guests