I have some new wishes
The code below contains a begin, but I do not really know how I can proceed.
(excuse some text in the code is in Swedish - I hope it does not pose a problem)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Point One:
Background
When I filled out the information in the "Edit field"
I want to press the button "Sök Produkt" it's OK.
But
When I press the button, the program jumps to the label "ButtonSökProdukt"
My first problem: the window closes
My wish
When the button is pressed, I would jump to a subroutine or function (not a label)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Point Two:
I write numerals and / or characters in "Edit field"
but if the "Enter" key is pressed, I want to do the same thing as the Button "Sök Produkt" would be done.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Point Three:
If I press the Button "Sök Produkt" or "Enter" key without any text in the "Edit field". I get a message and a new attempt.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Code:
#SingleInstance force
#NoEnv
SetBatchLines -1
Start:
Menu Tray, NoStandard
Menu Tray, Add, Exit, GuiClose
Menu Tray, Default, Exit
; Storleken på fönstret
; Gui, Show, x250 y250 w350 h1000, Produktkontroll - Hemsidan
Gui 1:Show, x131 y91 h570 w993, Produktkontroll - Hemsidan
Gui 1:Font, cBlue s18 bold, Verdana
Gui 1:Add, Text, Center x0 y20 w330 h40 , Produktidentifikation
Gui 1:Font, S12 CDefault, Verdana; ; Önskad font, storlek och färg.
Gui 1:Add, Radio, x20 y60 w160 h30 glblSend gFocus Checked vRadio1, Best. Nr ; Radiobutton
Gui 1:Add, Radio, x20 y85 w160 h30 glblSend gFocus vRadio2, EAN - kod ; Radiobutton
Gui 1:Add, Edit, x20 y125 w160 h25 gInput vInput
Gui 1:Add, Button, x200 y60 w80 h90, Sök Produkt
; Rita linjer
Gui 1:Add, Text, x0 y170 w330 h1 0x7 ;Horizontal Line > Black
Gui 1:Add, Text, x330 y0 w1 h170 0x7 ;Vertical Line > Black
Gui 1:Add, Text, x656 y20 w110 h30, Best.nr .:
Gui 1:Add, Text, x776 y20 w190 h30 vTxtChk1
Gui 1:Add, Text, x656 y60 w100 h30, EAN ......:
Gui 1:Add, Text, x776 y60 w190 h30 vTxtChk2
Gui Show
Gosub Focus
Return
lblSend:
iNbr := SubStr(a_GuiControl, 0, 1)
GuiControlGet myText,, edtInput
GuiControl ,, txtchk%iNbr%, %myText%
Return
Focus:
GuiControl Focus, Input ; Sätt fokus på inmatande fältet
Send ^a ; Markera hela fältet
Send {Delete} ; Töm fältet
Return
Input:
Gui Submit, NoHide
If Radio1
{
GuiControl ,, TxtChk1, %Input%
GuiControl ,, TxtChk2,
}
else
{
GuiControl ,, TxtChk2, %Input%
GuiControl ,, TxtChk1,
}
Return
ButtonSökProdukt:
; MsgBox knapp tryckt
Gui Submit ; Save each control's contents to its associated variable.
; MsgBox Radio1 = %Radio1% `n Radio2 = %Radio2%
If Radio1
RadioVal = BestNr
else
RadioVal = EAN
If not Input
{
MsgBox Inget beställningsnr eller EAN - Problem
}
MsgBox RadioVal = %RadioVal% `nInput = %Input%
Goto End
GuiEscape:
{
MsgBox 48, Programavslut,
(
Du kommer att avsluta programmet med ESC-knappen.
Börja om genom att starta programmet igen `n
Tack för denna gång!
)
}
GuiClose:
ExitApp
End:
ExitApp
I do not understand everything in the script, but it works so far.
There are certainly things that could write better / nicer
//Jan