Sign in to follow this  
Followers 0
bennyvo

listbox help

10 posts in this topic

hi,

i need help create a list box that work with my example below.

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$List_1 = GuiCtrlCreateList("List1", 20, 70, 120, 162)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit

Currenly i have a list box in a blank form, so far it got 1 entrie called "list1", i want to add more, eg the alphabet.

then i got this examle script

while 1 = 1
    WinWaitActive("Untitled - Notepad")
send ("A")

wend

Instead of writing key "A", i want it to write whatever key is selected in the listbox.

can anyone help me with this

thank you :)

Share this post


Link to post
Share on other sites



I don't understand the second code section.

You send an "A" to a notepad windows not the gui you create with the first code.

Difficult to help you. :) Describe really what you have done.

Share this post


Link to post
Share on other sites

I want to have a form, with a list box or a drop down menua contain

A

B

C

D

E

F

G

and so on...as a list of entries

So when i click on to select any of the entry(alphabet in this case), then it will write that letter to notepad. eg, if i select B, then it will write B to notepad, if i select F then it will write F to notepad.

The first problem i got is i don't know how to create a list box or a drop down menu with a list of entries in it.

The seond problem is i don't know how to combine 2 script together for it to work as i want above.

I hope you see what i try to do now...

thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ControlSend("Untitled", "", "Edit1", GUICtrlRead("Name of combo box"))

It reads whats in the combo box then sends that to a Notepad window, assuming the notepads window title is "Untitled".

Edit: To create a Combo Box read and learn this eg. script form the help file.

#include <GUIConstants.au3>

GUICreate("My GUI combo"); will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("a", 10,10); create first item
GUICtrlSetData(-1,"b|c","c"); add other item and set a new default

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

If you want to completely 'renew' the combo box you need to set the data to nothing first via.

GUICtrlSetData(-1,"")
Then put what you want.

Or if you just wish to add to what is there, use the above code without setting it to nothing first.

Try this example script I just made.

#include <GUIConstants.au3>

GUICreate("My GUI combo"); will create a dialog box that when displayed is centered

WinSetOnTop("My GUI combo","",1); Sets the GUI window on top

$Combo = GUICtrlCreateCombo ("a", 10,10); create first item
GUICtrlSetData(-1,"b|c","c"); add other item and set a new default

GUISetState ()

Run("Notepad.exe"); Start Notepad

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
   ;If the combo box is clicked then its value is sent to the notepad window.
    If $msg = $Combo Then
       ControlSend("Untitled", "", "Edit1", GUICtrlRead($Combo))
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then 
       ProcessClose("Notepad.exe")
       ExitLoop
    EndIf
Wend
Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thank you so much for your reply and the great example, i discover you have something i really like. instead of using WinWaitActive, you use WinSetOnTop which doesn't require notepad to be active and on top of all other application for the data to send.

wow thank you so much...i really appreciate it. :)

one more thing, i want it to keep sending the data to notepad, not only once but forever, if A is selected, keep send A, then if B is selected, then keep sending B. there's while 1 but it doesn't loop. Is it possible to have A,B,C etc... as a Key press, intead of letters or words.

I'm think of when A, or B or C is selected, then it store that Key in a variable then call it with this script.

while 1 = 1

$KeyfromCombo = $combo

WinWaitActive("Untitled - Notepad")

send ("$KeyfromCombo")

would it be posible to have something like that?

thanks

Edited by bennyvo

Share this post


Link to post
Share on other sites

I took out the if and it loop fine.

Bump for my old question

Is it possible to have A,B,C etc... as a Key press, intead of letters or words.

I'm think of when A, or B or C is selected, then it store that Key in a variable then call it with this script.

while 1 = 1

$KeyfromCombo = $combo

WinWaitActive("Untitled - Notepad")

send ("$KeyfromCombo")

would it be posible to have something like that?

thanks

Share this post


Link to post
Share on other sites

You mean when you press the "a" key it will send "a" to the notepad window?


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

sorry, i guess i made a mistake. The reason i want it to send as a Key is because i want to implement it to a game.

For some reason,

ControlSend("Untitled", "", "Edit1", GUICtrlRead($Combo))

work fine to notepad but not for the game, even i change the Untitled to GameWindow's Name but still not work.

while this code here work fine in the game.

while 1 = 1

WinWaitActive("GameWindow's Name")
send ("A")

wend

I guess, it must use WinWaitActive, so is there a way you can do this?

I try to do it like this but it doesn't turn out right.

#include <GUIConstants.au3>

GUICreate("My GUI combo"); will create a dialog box that when displayed is centered

$Combo = GUICtrlCreateCombo ("a", 10,10); create first item
GUICtrlSetData(-1,"b|c","c"); add other item and set a new default

GUISetState ()

While 1
    $msg = GUIGetMsg()

   IF $msg = $Combo Then
       WinWaitActive("GameWindow's Name")
       Send ($Combo)
    EndIf

Wend

It work in the game, but not as i expect it to be, suppose I select "b" in the combo box, then in the game, it must send "b", but it doesn't, it send number 3. whatever i selected in the combo box, it still send number 3. Not only in the game, but also in notepad, i change it to WinWaitActive("Untitled - Notepad"), it still write number 3.

I have no idea why, can you have a look at it.

thanks.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You need to read the control first, which is the Combo box. If it was something like this...

$var = 1
Send($var)

It would work but because its a control, a GUI one, you need to do this

Send(GUICtrlRead($Combo))

;or

$var = GUICtrlRead($combo)
Send($var)
Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

Yep, now it work perfectly. thank you so much.

#include <GUIConstants.au3>

GUICreate("My GUI combo"); will create a dialog box that when displayed is centered

;WinSetOnTop("My GUI combo","",1); Sets the GUI window on top

$Combo = GUICtrlCreateCombo ("", 10,10); create first item
GUICtrlSetData(-1,"item1|item2|{F5}|b|a|","a"); add other item snd set a new default

GUISetState ()

While 1

    $msg = GUIGetMsg()

    $msg = $Combo
    
WinWaitActive("GameWindow's Name")
Send(GUICtrlRead($Combo))

Wend

before i ask a question about send a key intead of a letters, i use A,B,C is a bad example because its still the same, it still send letters or key the same way. But if I use F1, F2, F3, TAB, SHIFT etc... then its difference. It will send a word F1, F2, F3, TAB, SHIFT etc... to notepad intead of a Key. So you see the script above, I try to put a {......} in F5 and it turn out as a Key, not a word.

So my last question is, can you mask it someway that it show F5 (not {F5}) in the combo box but work as a Key? It show as F5 but work as {F5}.

sorry to bothering you so much. :)

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