Sign in to follow this  
Followers 0
Bert

combo copy problem

12 posts in this topic

#1 ·  Posted (edited)

I made a combo box to allow the user to select the choice they like, then when they click ok, the selection will be sent to the edit field in the application they are using. I get the choices to show up in the drop down, and I can select the one I wish. The proble is when I click ok, the information is not sent to the edit field of the application? I'm stumped. Here is the code:

fileopen ("bucket.ini", 0)
$note1 = FileReadLine ("bucket.ini")

;-------------------------------------
#include <GuiConstants.au3>

GUICreate("Bucket Name", 300, 75)
$Combo_2 = GuiCtrlCreateCombo("", 20, 20, 200, 21)
GuiCtrlSetData($combo_2, $note1)
$button1 = GuiCtrlCreateButton("OK", 230, 20, 60, 20)

; Run the GUI until it is closed
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
   ;When button is pressed, information is copied to 
   ;edit field in ticket
    Case $msg = $button1
      $data = GUICtrlRead($Combo_2)
      $Label_1 = Send($data, 1)
      GuiCtrlSetData($Label_1, $data)
      exit
     
    EndSelect
WEnd
Exit
Edited by Larry

Share this post


Link to post
Share on other sites



At the time you do the Send() command your GUI probably still has the focus.

Can't you work with ControlSend() and specify the correct Edit control in the correct window ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Actually, with $Label_1, you've never created an Edit Box. If you create the edit box you don't need send, just the GUICtrlSetData().


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

The edit box is in the application, not in my script. My goal is to provide some choices, and have the choice selected sent to the application's edit field via the send command.

<{POST_SNAPBACK}>

As said.. try using ControlSend() ...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

As said.. try using ControlSend() ...

<{POST_SNAPBACK}>

Oops, ^^^ that should work ;)

Edit:

Example,

$data = GUICtrlRead($Combo_2)

ControlSend("My Application Title", "", "Control ID from AutoInfo Tool of Edit Box to Send To", $data)

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

small problem with the solution:

The window name can change depending on which function the user is performing. The best way I can explain how this program works is its like the clipboard function, except the user only has certain choices, and once the user picks what they want, the information is pasted to the application.

I'll try your solution tomorrow. Maybe I can figure out a variable that will work.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

How about the Class?

AutoInfo:

Title: Untitled - Notepad

Class: Notepad

Example:

Opt("WinTitleMatchMode", 4)
Run("Notepad.exe")
Sleep(1000)
$HANDLE = WinGetHandle("classname=Notepad")
ControlSend($HANDLE, "", "Edit1", $data)

Just replace the:

WinGetHandle("classname=YOUR_CLASS_FROM_THE_APPLICATION")

ControlSend($HANDLE, "", "YOUR_CONTROL_ID_FROM_EDIT_BOX", $data)

Edit: Fixed typo

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I got to thinking about the focus problem, and I realized I could simply use clipPut to put the information to the clipboard. Then have it pasted to the edit field in the application. I should have it ready in a while. I will post my code when I get it working.

Share this post


Link to post
Share on other sites

I got it working. This is the code:

;I will need to cut and paste the information from the below listed file here

#include <GuiConstants.au3>

;-----------------------------

fileopen ("bucket.ini", 0)

$note1 = FileReadLine ("bucket.ini")

GUICreate("Bucket Name", 300, 75)

$Combo_2 = GuiCtrlCreateCombo("", 20, 20, 200, 21)

GuiCtrlSetData($combo_2, $note1)

$button1 = GuiCtrlCreateButton("OK", 230, 20, 60, 20)

; Run the GUI until it is closed

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

;When button is pressed, label text is copied to the clipboard

Case $msg = $button1

$data = GUICtrlRead($Combo_2)

ClipPut($data)

exit

EndSelect

WEnd

Exit

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