AutoHotkey Community

It is currently May 27th, 2012, 3:06 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: "Dynamic" - GUI
PostPosted: March 1st, 2010, 1:27 am 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 5:56 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Code:
YourHotkey:: GoSub, YourLabel

:?:

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 8:54 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 1:36 pm 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
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. :D
(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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 6:01 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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." :lol:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 6:26 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 7:50 pm 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 8:30 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2010, 12:18 am 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
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 :D

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&highlight=

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 :D )
My problem is to manage the GUI format in the right way


//Jan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 4:04 pm 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 4:54 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
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 March 20th, 2010, 6:03 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 5:33 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
I suggest using GuiControl, Focus rather than ControlFocus and using the Checked option for the first radio button (as in my second post above).
:idea: The focus subroutine is probably more useful if it selects all the text in the edit control rather than just moving the caret there.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 7:07 pm 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
Thank you!

It works for me :-)

//Jan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 7:39 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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.
Code:
Gosub Focus
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2010, 8:32 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
@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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], rbrtryn, Yahoo [Bot] and 29 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group