 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Mon Mar 01, 2010 12:27 am Post subject: "Dynamic" - GUI |
|
|
I have done a test window (the code is below).
where you can select either "one" or" two" and give a value in a "box".
that's OK!
But Now I want, either "directly" or when I press the button -
Example:
If I chose "One", I want the value in the box will come to place "one" to the right and
if I chose "Two", I want the value in the box will come to place "two" to the right
(have tried to explain the concept that does not work in the code)
Hope I could explain my desire
| Code: | Gui 1:Show, x130 y90 h570 w1000, Test
Gui 1:Font, cBlue s18 bold, Verdana
Gui 1:Add, Text, Center x0 y20 w330 h40 , Test - Window
Gui 1:Font, S12 CDefault, Verdana
Gui 1:Add, Radio, x20 y60 w160 h30 vMyRadio Checked, One
Gui 1:Add, Radio, x20 y90 w160 h30, Two
Gui 1:Add, Edit, x20 y120 w160 h30 vInput
Gui 1:Add, Button, x200 y60 w80 h90 , Press
Gui 1:Add, Text, x0 y170 w330 h1 0x7 ;Horizontal Line > Black
Gui 1:Add, Text, x330 y0 w1 h170 0x7 ;Vertical Line > Black
Return
ButtonPress:
{
Gui Submit ; Save each control's contents to its associated variable.
If Input
{
If Radio = 1
{
MsgBox %Input%
Gui 1:Add, Text, x656 y20 w110 h30 , Choice One
Gui 1:Add, Text, x776 y20 w190 h30 , %Input%
}
else
{
Gui 1:Add, Text, x656 y80 w100 h30 , Choise Two
Gui 1:Add, Text, x776 y60 w190 h30 , %Input%
}
}
}
1GuiClose:
ExitApp |
//Jan |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Mon Mar 01, 2010 4:56 am Post subject: |
|
|
| Code: | | YourHotkey:: GoSub, YourLabel |
 _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Mon Mar 01, 2010 7:54 am Post subject: |
|
|
I think this might be what you want. | Code: | #SingleInstance force
#NoEnv
SetBatchLines, -1
Gui, Font, cBlue s18 Bold, Verdana
Gui, Add, Text,,Test - Window
Gui, Font, S12 cDefault, Verdana
Gui, Add, Radio, wp vMyRadio Checked, One
Gui, Add, Radio, wp, Two
Gui, Add, Edit, wp vInput
Gui, Add, Button, wp Default, Press
Gui, Show
return
GuiClose:
ExitApp
ButtonPress:
Gui, Submit, NoHide ;Save each control's contents to its associated variable.
If MyRadio = 1
num = One
Else num = Two
GuiControl,,Input,% Input A_Space num
return |
|
|
| Back to top |
|
 |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Mon Mar 01, 2010 12:36 pm Post subject: |
|
|
Thank you! But not really what I want
I try to explain again
I added these 4 lines to better show my desire:
| Code: | Gui Add, Text, x300 y130 w200 h30 , Header One ...:
Gui Add, Text, x450 y130 w200 h30 , Result One
Gui Add, Text, x300 y160 w200 h30 , Header Two ...:
Gui Add, Text, x450 y160 w200 h30 , Result Two |
But what I would like to:
Depending on which radio button is pressed,
I want the text, from the input, go to different places
Example
When something is written down in the "InputBox"
and the "One" is selected, I want the text would come in "Result One"
and if the "Two" is selected, I want the same text would come to the other place "Result Two"
(In the code below I explain where the place "Result One" and "Result Two" are)
| Code: | #SingleInstance force
#NoEnv
SetBatchLines, -1
Gui Font, cBlue s18 Bold, Verdana
Gui Add, Text,,Test - Window
Gui Font, S12 cDefault, Verdana
Gui Add, Radio, wp vMyRadio Checked, One
Gui Add, Radio, wp, Two
Gui Add, Edit, wp vInput
Gui Add, Button, wp Default, Press
Gui Add, Text, x300 y130 w200 h30 , Header One ...:
Gui Add, Text, x450 y130 w200 h30 , Result One
Gui Add, Text, x300 y160 w200 h30 , Header Two ...:
Gui Add, Text, x450 y160 w200 h30 , Result Two
Gui, Show
return
GuiClose:
ExitApp |
I suppose one solution would be to use "GuiControl, .." properly (but I do not know how)
Another (nicer?) solution would be:
When something is written down in the "InputBox" field.
You see the same text in the selected field directly and when "the button" is pressed, all the other field is filled in. (is that possible?)
An even nicer solution, (but maybe it takes too long to run - I don't know)
"Radio Button" "One" stands for article number
and "Radio Button" "Two" is the EAN-code.
Other information retrieved from, inter alia, a comma separated (CSV file) with about 35 000 rows.
It's been cool if the choice had always approached, the selected product, and finally made a prefect match. Perhaps all the text doesn't need to be written, before the right product was found.
(I have no idea how to solve this with AutoHotkey )
Can you use
| Quote: | | SetTimer, Label [, Period|On|Off, Priority] |
in any way to update any information at all times?
//Jan |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Mon Mar 01, 2010 5:01 pm Post subject: |
|
|
Ah, I think I get it now. You want to populate a form with information from a database using incremental search.
We will probably need at least a sample of the database (CSV) and ideally a picture of what the form should look like. Actually, it sounds more ambitious than what I'm interested in right now, so when I say "we" I mean "somebody else."
P.S. I wrote this little bit before it occurred to me that it's not what you want; but you might learn something from it anyway, so here it is. | Code: | #SingleInstance force
#NoEnv
SetBatchLines, -1
Gui, Font, cBlue s18 Bold, Verdana
Gui, Add, Text, w500 Center, Test - Window
Gui, Font, S12 cDefault, Verdana
Gui, Add, Radio, wp vMyRadio1 Checked, One
Gui, Add, Radio, wp vMyRadio2, Two
Gui, Add, Edit, wp vInput gInput
Gui, Show
return
GuiClose:
ExitApp
Input:
Gui, Submit, NoHide
If MyRadio1
GuiControl,,MyRadio1, One: %Input%
Else GuiControl,,MyRadio2, Two: %Input%
return |
|
|
| Back to top |
|
 |
da_boogie_man Guest
|
Posted: Mon Mar 01, 2010 5:26 pm Post subject: |
|
|
Is this something like you wanted?:
>>TESTED<<
| Code: |
#SingleInstance force
#NoEnv
SetBatchLines, -1
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, GuiClose
Menu, Tray, Default, Exit
Gui Font, cBlue s18 Bold, Verdana
Gui Add, Text,,Test - Window
Gui Font, S12 cDefault, Verdana
Gui Add, Radio, wp vradchk1 checked, One
Gui Add, Radio, wp vradchk2, Two
Gui Add, Edit, wp vedtInput
Gui Add, Button, wp Default glblsend, Press
Gui Add, Text, x300 y130 w200 h30 , Header One ...:
Gui Add, Text, x450 y130 w200 h30 vtxtchk1, Result One
Gui Add, Text, x300 y160 w200 h30 , Header Two ...:
Gui Add, Text, x450 y160 w200 h30 vtxtchk2, Result Two
Gui, Show
return
GuiClose:
ExitApp
Return
lblSend:
Loop, 2
{
GuiControlGet, isChkd,, radchk%a_Index%
If isChkd = 1
{
iNbr := a_Index
Break
}
}
GuiControlGet, myText,, edtInput
GuiControl,, txtchk%iNbr%, %myText%
Return
|
>>OR if you want to just click the Radio's and make the change:
>>ALSO TESTED<<
| Code: |
#SingleInstance force
#NoEnv
SetBatchLines, -1
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, GuiClose
Menu, Tray, Default, Exit
Gui Font, cBlue s18 Bold, Verdana
Gui Add, Text,,Test - Window
Gui Font, S12 cDefault, Verdana
Gui Add, Radio, wp glblSend vradchk1, One
Gui Add, Radio, wp glblSend vradchk2, Two
Gui Add, Edit, wp vedtInput
Gui Add, Text, x300 y130 w200 h30 , Header One ...:
Gui Add, Text, x450 y130 w200 h30 vtxtchk1, Result One
Gui Add, Text, x300 y160 w200 h30 , Header Two ...:
Gui Add, Text, x450 y160 w200 h30 vtxtchk2, Result Two
Gui, Show
return
GuiClose:
ExitApp
Return
lblSend:
iNbr := SubStr(a_GuiControl, 0, 1)
GuiControlGet, myText,, edtInput
GuiControl,, txtchk%iNbr%, %myText%
Return
|
DBM |
|
| Back to top |
|
 |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Mon Mar 01, 2010 6:50 pm Post subject: |
|
|
Thank you every one!
Yes, it was something like that I wanted from the beginning.
All 3 examples have their advantages.
I'll shall feel which solution makes the most sense.
But above all, I got ideas on possible solutions.
____________________________
It was now at the end, I thought that, maybe an
"incremental search" would feel most natural.
The wish is probably not so unusual?.
But I don't really know what to look at
Does anyone know any examples about that?
the problem is:
While you press in character for character,
there is a "loop" to compare a variable string with a field and get the "best" value from that.
I have no idea to do that
Anyway. Thanks so long.
//Jan |
|
| Back to top |
|
 |
da_boogie_man Guest
|
Posted: Mon Mar 01, 2010 7:30 pm Post subject: |
|
|
Can you give us an example of a string you would need to search?
If the field you want is structured string and would always be in the same position within the structure you can Parse the string until you hit that field:
Let's say we want the last field {the easiest in this case}:
| Code: |
myString = http://www.autohotkey.com/forum/topic55137.html
Loop, Parse, myString, `/
useString := a_loopfield
msgbox, %useString% ; Would give us [u]topic55137.html[/u]
|
Or if you want the 4th field {remembering that the "//" would be a field}
| Code: |
myString = http://www.autohotkey.com/forum/topic55137.html
Loop, Parse, myString, `/
{
If a_index = 4
{
useString := a_loopfield
Break
}
}
msgbox, %useString% ; Would give us [b]forum[/b]
|
AFAIK you can use anything as the Delimiter and with the Loop, Parse you don't have to know what the word is going to be. You just have to know which "field" it's going to be in.
DBM |
|
| Back to top |
|
 |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Mon Mar 01, 2010 11:18 pm Post subject: |
|
|
Thank you!
| da_boogie_man wrote: | | Can you give us an example of a string you would need to search?........ |
The search is not the problem (below I give the code to search in the CSV-file - ( I apologize for the Swedish comments )
Certainly it is possible to write a bit smoother, but it works
I send to the "search function" => infile - search string - and number of the field to search in.
| Code: | ; Förutsättningar
; Infilen innehåller artikelregistret (T.ex. Out_FDT_100.txt)
; Nedanstående uppgifter används på hemsidan och respektive fält syns (och måste ha den placeringen):
; BestNr = Fält_1
; Benämning = Fält_2
; Pris = Fält_4
; ExTxt1 = Fält_8
; ExTxt2 = Fält_9
; ExTxt3 = Fält_10
; Begränsningar:
; Priset Måste vara i hela kronor (ören syns inte på nätet)
;
SetBatchLines -1 ; Sätt högsta hastighet i skriptet
InFil = C:\Documents and Settings\Jan\Mina dokument\EXPO\OUT_FDT_100.txt
AllRows := ReadInfil(InFil)
; - - - - - - - - - - -
Sök=026102858097
Fält=1 ; (1=best nr - 3= EAN)
SeachField(AllRows,Sök,fält)
MsgBox Utanför loopen: `n`nBestNr = %BestNr%`nBenämning = %Benämning%`nPris = %Pris%`nExTxt1 = %ExTxt1%`nExTxt2 = %ExTxt2%`nExTxt3 = %ExTxt3%
ExitApp
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - F I L - I N L Ä S N I N G - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ReadInfil(Fil_In) {
; Läs in hela filen till "var: AllRows"
; "Var: TotRow" innehåller antal rader
Global Support
, SupportEpost ; Innehållar alla rader från infilen i en variabel
FileRead AllRows, %Fil_In% ; Läs in hela filen till variabel "AllRows"
If ErrorLevel ; Om inga fel uppstått vid inläsning av filen - över för den till en index variabel
{
; Notera i logfil - "Error"
FileAppend ,
(LTrim Join
Den exporterade filen från FDT: %Fil_In%`n
Kunde inte hittas - programkörningen avslutas.
), %KonvErr%
MsgBox Den önskade filen ....: %Fil_In% `tKunde inte hittas.`n`n`t Kontakta ......: %Support%`n`teller E-Post ....: %SupportEpost% `n`n`tProgramkörningen avslutas.
; Lägg in här - skicka ett SMS / Mail - att ett "allvarligt" fel uppstått
ExitApp
}
Return AllRows
}
; - - - - - - - - - - - S L U T P Å F I L I N L Ä S N I N G - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - S Ö K I E T T F Ä L T - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SeachField(Fil_In,Search,Field) {
Global Infil, BestNr, Benämning, Pris, ExTxt1, ExTxt2, ExTxt3
Found = 0
; Local Point_Art, TotRow, CountRow, RubrikTmp, Pos
; Gå igenom hela filen, modifiera fält för fält
Loop parse, Fil_In, `n, `r
{
; Initiera variabler för varje artikel - Lägg varje artikel i en Indexerad variabel
Array%A_Index% := A_LoopField
ArtRow := Array%A_Index% ; Enklare att hantera en enkel variabel
StringSplit Fält_, ArtRow, `;, %A_Space%%A_TAB%`" ; Dela upp och rensa alla fält frånStringLen RowLength, ArtRow ; Spara längden på fältet
Point_Art := A_Index ; Lägg på minnet vilken rad som behandlas just nu
If Fält_%Field% = %Search%
{
BestNr = %Fält_1%
Benämning = %Fält_2%
Pris = %Fält_4%
ExTxt1 = %Fält_8%
ExTxt2 = %Fält_9%
ExTxt3 = %Fält_10%
Found=1
Break
}
}
; MsgBox Found = %Found%
If Found = 0 ; Om sökningen inte hittades i artikelregistret
{
If Field = 1
MsgBox BestNr: %Search% kunde inte hittas i infilen:`n%Infil%
If Field = 3
MsgBox EAN-koden: %Search% kunde inte hittas i infilen:`n%Infil%
ExitApp
}
; MsgBox I Loopen: `n`nBestNr = %Fält_1%`nBenämning = %Fält_2%`nPris = %Fält_4%`nExTxt1 = %Fält_8%`nExTxt2 = %Fält_9%`nExTxt3 = %Fält_10%
Return
} |
My problem is to easy handle this - show the result in a GUI-window
(And I wonder how the easiest way would be - I havn't the answer right now)
I have to try some different alterantiv to know what feel best.
Right now I'm testing the suggestions I received
and it is possible that it will be good.
_____________________________________________
As I said to search in different fields is not difficult, but to make the right link to a GUI window.....
There are more areas / detail that I don't know how to do
one are:
http://www.autohotkey.com/forum/viewtopic.php?t=55130
one another is:
Based on the input data, I have made a program that seeks out an original image.
The images is converted into two new formats.
Now I want to see these images in the same GUI window as the input field
(I think this is not easy )
My problem is to manage the GUI format in the right way
//Jan |
|
| Back to top |
|
 |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Sat Mar 20, 2010 3:04 pm Post subject: |
|
|
Will develop the functionality even more.
Take this example because. the code is short and clear
| Code: | #SingleInstance force
#NoEnv
SetBatchLines, -1
Gui Font, cBlue s18 Bold, Verdana
Gui Add, Text, w500 Center, Test - Window
Gui Font, S12 cDefault, Verdana
Gui Add, Radio, wp vRadio1, One
Gui Add, Radio, wp vRadio2, Two
Gui Add, Edit, wp vInput gInput
Gui Show
return
GuiClose:
ExitApp
Input:
Gui Submit, NoHide
If Radio1
GuiControl ,,Radio1, One: %Input%
else GuiControl ,,Radio2, Two: %Input%
Return
|
I have a few desire. (Here is one to begin with )
Direct after I have chose "RadioButton One" or "RadioButton Two" with the mouse
I want that the cursor is jumping direct to the "edit field".
(so I don't have to click on "edit field" with the mouse)
or (maybe better)
When the program is started the "RadioButton One" is default
and the "cursor" is pointing on the "edit field" directly
(you can enter the value direct into the "edit field" without using the mouse.).
If I want to select "RadioButton Two"
- The choice is done with the mouse.
Directly the choice is done,
I want to be able to write the value in the "edit field"
(without that choice of the "edit field" was made with the mouse)
Hope I could explain this desire
Is that possible?
//Jan |
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Sat Mar 20, 2010 3:54 pm Post subject: |
|
|
| Code: | #SingleInstance force
#NoEnv
SetBatchLines, -1
Gui Font, cBlue s18 Bold, Verdana
Gui Add, Text, w500 Center, Test - Window
Gui Font, S12 cDefault, Verdana
Gui Add, Radio, Checked wp gFocus vRadio1, One
Gui Add, Radio, wp gFocus vRadio2, Two
Gui Add, Edit, wp vInput gInput
Gui Show
Gosub Focus
return
Focus:
GuiControl, Focus ,Input
Send ^a
Return
GuiClose:
ExitApp
Input:
Gui Submit, NoHide
If Radio1
GuiControl ,,Radio1, One: %Input%
else GuiControl ,,Radio2, Two: %Input%
Return |
Edit: Changed as jaco0646 suggested
Last edited by None on Sat Mar 20, 2010 5:03 pm; edited 1 time in total |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Mar 20, 2010 4:33 pm Post subject: |
|
|
I suggest using GuiControl, Focus rather than ControlFocus and using the Checked option for the first radio button (as in my second post above).
The focus subroutine is probably more useful if it selects all the text in the edit control rather than just moving the caret there. |
|
| Back to top |
|
 |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Sat Mar 20, 2010 6:07 pm Post subject: |
|
|
Thank you!
It works for me
//Jan |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Mar 20, 2010 6:39 pm Post subject: |
|
|
I have one more suggestion, since it's on my mind from a different thread. I often see code, even from veteran scripters, that ends the auto-execute section (with a return) but GoSubs over that return to the next subroutine rather than just including the subroutine in the auto-execute section.
In this case deleting two lines produces the same functionality by lettting the auto-execute section fall through. |
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Sat Mar 20, 2010 7:32 pm Post subject: |
|
|
@jaco0646
I thought about it but left it that way because I thought it would make it clearer what was happening. If the code was for my own use I would have changed it. |
|
| 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
|