 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Starbyter
Joined: 12 Aug 2005 Posts: 12
|
Posted: Fri Aug 12, 2005 10:34 pm Post subject: Inserting text from ComboBox drop-down list into another app |
|
|
Hi Everyone,
I am somewhat new to the GUI stuff with AHK... Anyhow, here's my headache:
1) The macro initially starts by activity an application window (Clarify) and then sends a series of keystrokes.
2) A GUI pops up with a ComboBox list of options for the user to choose or type in text.
3) I have two buttons, GO and CANCEL. When clicking CANCEL, I want the GUI and the macro to exit. (I have the cancel button figured out already.) When clicking GO, I want the macro to insert the selected (or typed in) text from the ComboBox field into the Clarify application window where the cursor currently is.
I've tried all sorts of combinations of GuiControlGet, ControlGetText, etc., but when I click GO, the macro just stops.
I need help!!!! Can someone provide me with a sample script to accomplish this? _________________ The more I learn, the more I know how much I don't know. |
|
| Back to top |
|
 |
tpatel5
Joined: 27 Oct 2004 Posts: 65 Location: GA
|
Posted: Sat Aug 13, 2005 1:01 am Post subject: |
|
|
can you please put that part of your script so someone can figure out what's wrong.
you can use something like this:
| Code: | ButtonGo:
ControlGet, OutputVar, List [, Value, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
Msgbox, %OutputVar%
Return |
Thanks _________________ -Tru  |
|
| Back to top |
|
 |
Starbyter
Joined: 12 Aug 2005 Posts: 12
|
Posted: Mon Aug 15, 2005 5:32 pm Post subject: |
|
|
I apologize, I am a newbie at this...
I've tried so many different combinations, and nothing has worked... starting with what the bits that were in the Help file. The sample you provided is the same as was in the Help file, and it doesn't work.
With the sample you provided, I get an error: "Parameter #2 is not a valid ControlGet command."
Can you please explain to me if "OutputVar" and "List" are literal commands or if they were meant to be replaced by something specific in the combobox code. Also, I don't want a message box, I want the selected item's text to be entered into another application.
The first part of the combobox code looks like this:
Gui, Show, x417 y43 h226 w477, Choose Location
Gui, Add, Button, x46 y150 w140 h40, GO
Gui, Add, Button, x276 y150 w140 h40, CANCEL
Gui, Add, ComboBox, x46 y40 w380 h3600 gLocationID vLocationID, List Item 1|List Item 2|List Item 3|
So, specifically what should my ControlGet lines look like in order to send the text of the selected list item to another application?
To throw another wrench in it, I want my output to input only part of the result - for example, instead of inserting "List Item 3" I want it to input just "List."
Thanks in advance...  _________________ The more I learn, the more I know how much I don't know. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Mon Aug 15, 2005 7:01 pm Post subject: |
|
|
Hi Startbyter,
I hope the following will give you some help. As far as I understood, you have problem to get the value from your AHK Gui to send it to the app, right? You can use Gui,Submit to get the data from your list. If you do not use the option "NoHide", the AHK Gui will disappear and you can immediatly send the value to the app. StringSplit will in this case be used to get only the first item from the string. | Code: | Gui, 1:Add, Button, gBtnGo, GO
Gui, 1:Add, Button, gBtnCancel, CANCEL
Gui, 1:Add, ComboBox, w380 h10 gLocationID vLocationID, List Item 1|List Item 2|List Item 3
Gui, 1:Show,, Choose Location
return
LocationID:
BtnGo:
Gui, 1:Submit
StringSplit, Array, LocationID, %A_Space%
Send, %Array1%
Gosub, GuiClose
return
BtnCancel:
GuiClose:
GuiEscape:
ExitApp
return
| *not tested* _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Starbyter
Joined: 12 Aug 2005 Posts: 12
|
Posted: Mon Aug 15, 2005 8:25 pm Post subject: COOL! It worked! Just one more thing... |
|
|
THANKS!!!! That did the trick. However, how can I make this work using two comboboxes in the single GUI?
I need to add a second combobox - the user will first need to choose a location and then a floor number. The macro will then need to insert the location, a space and then the floor number into the macro.
This is what I have tried:
Gui, 1:Add, Text, x46 y10 w180 h20, Select or Type LID
Gui, 1:Add, Button, x46 y150 w140 h40 gBtnGo, GO
Gui, 1:Add, Button, x276 y150 w140 h40 gBtnCancel, CANCEL
Gui, 1:Add, ComboBox, x46 y40 w380 h3600 gLocationID vLocationID, List Item 1|List Item 2|List Item 3|
Gui, 1:Add, Text, x46 y70 w180 h20, Select or Type Floor Number
Gui, 1:Add, ComboBox, x46 y100 w120 h300 gFloor vFloor, 01|02|03|04|05|06
Gui, 1:Show, x417 y43 h226 w47, Choose Location
Return
LocationID:
BtnGo:
Gui, 1:Submit
StringSplit, Array, LocationID, %A_Space%
Send, %Array1%
Send, {SPACE}
Gui, 2:Submit
StringSplit, Array, Floor, %A_Space%
Send, %Array2%
Gosub, GuiClose
It errors out at the second combobox line, saying "Error: This control's target label does not exist. The current thread will exit. Specifically: gFloor
I have also tried using Gui, 1:Add for all lines instead of 2:Add. I get teh same error. _________________ The more I learn, the more I know how much I don't know. |
|
| Back to top |
|
 |
Starbyter
Joined: 12 Aug 2005 Posts: 12
|
Posted: Mon Aug 15, 2005 8:52 pm Post subject: One problem fixed, another begins |
|
|
OK, I was able to resolve the target name issue. I changed the codes a bit to add the second combo box.
BtnGo:
FloorNo:
Gui, 1:Submit
StringSplit, Array, FloorNo, %A_Space%
Send, %Array2%
LocationID:
Gui, 1:Submit,
StringSplit, Array, LocationID, %A_Space%
Send, %Array1%
Send, {SPACE}
The problem now is that as soon as I choose a location ID, the GUI goes away. It does not give me the opportunity to choose a floor number or even click on Go or Cancel. The same thing happens if I choose a floor number. The good news is, I'm not getting any error messages and the item I selects is inserting into the application the way I want. How do I keep the GUI on top so I can choose items from both comboboxes and not submit it until I click Go?
Thanks in advance again... we almost have it nailed down!  _________________ The more I learn, the more I know how much I don't know. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Tue Aug 16, 2005 6:45 am Post subject: |
|
|
Hi Starbyter,
Yeah, you nearly did it.
The problme is that you tell AHK to do what it does. So instead of this | Code: | BtnGo:
FloorNo:
Gui, 1:Submit
StringSplit, Array, FloorNo, %A_Space%
Send, %Array2%
LocationID:
Gui, 1:Submit,
StringSplit, Array, LocationID, %A_Space%
Send, %Array1%
Send, {SPACE}
|
Try this | Code: | LocationID:
;you could fill the floor combobox depending of the location selection.
; and enable the floor combobox, if it had been inactive before.
return
FloorNo:
;if this combobox has been activated by LocationID,
; then a selection of the floor could be used to trigger the GO.
; But then the user has no chance to check if he has
; selected everything correctly.
; So I advice to do it with a default button for GO
return
BtnGo:
Gui, 1:Submit
StringSplit, FloorArray, FloorNo, %A_Space%
StringSplit, LocationArray, LocationID, %A_Space%
Send, %LocationArray1%{SPACE}%FloorArray2%
return | Think about it. What is the difference between your and my code?
And if the sending of the text is is too slow, try this:
| Code: | BtnGo:
Gui, 1:Submit
StringSplit, FloorArray, FloorNo, %A_Space%
StringSplit, LocationArray, LocationID, %A_Space%
ClipBoard = %LocationArray1%{SPACE}%FloorArray2%
Send, ^v
return |
_________________ Ciao
toralf  |
|
| Back to top |
|
 |
Starbyter
Joined: 12 Aug 2005 Posts: 12
|
Posted: Wed Aug 17, 2005 7:08 pm Post subject: It WORKS! :) |
|
|
I made a few tweaks to this, including putting my values for the first combobox in a separate ini file. This makes it easier for me to manage the values if they change - I won't have to update 65+ macros that will be using this list, just the one ini file. Too cool. I am very happy.
Here is what the final code looks like:
| Code: |
#SingleInstance force
IniRead, value_list, J:\TSC Macros\LID_values.ini, Section, value_list
; Generated by SmartGUI Creator 3.1
Gui, 1:Add, Text, x46 y10 w180 h20, Choose or Type Location ID
Gui, 1:Add, Button, x46 y150 w140 h40 gBtnGo, Go
Gui, 1:Add, Button, x276 y150 w140 h40 gBtnCancel, Cancel
Gui, 1:Add, ComboBox, x46 y40 w400 h420 0x2000 0x100 0x200000 gLocationID vLocationID, %value_list%
Gui, 1:Add, Text, x46 y70 w180 h20, Choose or Type Floor Number
Gui, 1:Add, ComboBox, x46 y100 w120 h300 gFloorNo vFloorNo, 01|02|03|04|05|06|
Gui, 1:Show, NoHide h226 w477, Choose Location
return
BtnCancel:
GuiClose:
ExitApp
Return
LocationID:
return
FloorNo:
return
BtnGo:
Gui, 1:Submit
StringSplit, FloorArray, FloorNo, %A_Space%
StringSplit, LocationArray, LocationID, %A_Space%
ClipBoard = %LocationArray1% %FloorArray1%
Send, {CTRLDOWN}v{CTRLUP}
|
I have another question about adding something to enhance the first combobox, but I will post that in a new thread.
Thanks SO MUCH for your help. This forum is a wonderful resource!!! _________________ The more I learn, the more I know how much I don't know. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|