Jump to content

combo copy problem


Bert
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Developers

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 ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Developers

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() ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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.

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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.

Link to comment
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

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...