ShadowElf Posted October 29, 2009 Posted October 29, 2009 I want to do functions for all buttons from 0 to 9 and when press, to send 0 to 9, but not working I have the code: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <StructureConstants.au3> #include <GUIListView.au3> #Include <WinAPI.au3> #Include <MySQL.au3> main() func time() while 1 Global $time $time = "DATA:" & @YEAR & ":" & @MON & ":" & @MDAY & " | ORA: " & @hour & ":" & @MIN & ":" & @SEC GUICtrlSetData ($do, $time) sleep (1000) WEnd EndFunc ;~ MsgBox(0,"Guest List",$xnume) Func main() Global $Form1, $Codbar, $Cantitate, $List1, $inchide, $acc, $acc1, $sterge, $tot, $Benter, $Bback Global $acc2, $acc3, $acc4, $acc5, $acc6, $acc7, $acc8, $acc9, $acc10, $total, $do, $b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8, $b9, $b10 Global $bx, $bpunct, $bminus, $bpartial, $Picture, $braport, $bcauta, $submit Opt("GUIOnEventMode", 1) $Form1_1 = GUICreate("ShadowPOS", 801, 601, 217, 156) $Codbar = GUICtrlCreateInput("", 438, 41, 137, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetOnEvent (-1, "citeste") $Cantitate = GUICtrlCreateInput("1", 438, 85, 137, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $submit = GUICtrlCreateButton("Submit", 1, 1, 1, 1) GUICtrlSetState(-1, $GUI_HIDE) Dim $Form1_AccelTable[1][2] = [["{ENTER}", $submit]] GUISetAccelerators($Form1_AccelTable) $do = GUICtrlCreateLabel("", 24, 16, 197, 17) $List1 = GUICtrlCreateListView("Codbar|Produs|Cant|PV|Total", 22, 120, 553, 260) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 50) $inchide = GUICtrlCreateButton("Inchide", 21, 530, 57, 57) GUICtrlSetOnEvent(-1, "cancel") $sterge = GUICtrlCreateButton("Sterge", 505, 470, 65, 57) $total = GUICtrlCreateInput("0", 23, 41, 249, 72, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) GUICtrlSetFont(-1, 40, 400, 0, "MS Sans Serif") $acc = GUICtrlCreateGroup("Acceleratori", 615, 198, 177, 393) $acc1 = GUICtrlCreateButton("Button1", 625, 222, 161, 33) $acc2 = GUICtrlCreateButton("Button2", 625, 257, 161, 33) $acc3 = GUICtrlCreateButton("Button3", 625, 292, 161, 33) $acc4 = GUICtrlCreateButton("Button4", 625, 328, 161, 33) $acc5 = GUICtrlCreateButton("Button5", 625, 364, 161, 33) $acc6 = GUICtrlCreateButton("Button6", 625, 400, 161, 33) $acc7 = GUICtrlCreateButton("Button7", 625, 435, 161, 33) $acc8 = GUICtrlCreateButton("Button8", 625, 470, 161, 33) $acc9 = GUICtrlCreateButton("Button9", 625, 507, 161, 33) $acc10 = GUICtrlCreateButton("Button10", 625, 543, 161, 33) GUICtrlCreateGroup("", -99, -99, 1, 1) $tot = GUICtrlCreateButton("TOTAL", 80, 409, 115, 121) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $Benter = GUICtrlCreateButton("Enter", 439, 408, 57, 118) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Bback = GUICtrlCreateButton("<<", 439, 529, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b3 = GUICtrlCreateButton("3", 378, 529, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b6 = GUICtrlCreateButton("6", 378, 469, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b9 = GUICtrlCreateButton("9", 378, 408, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b2 = GUICtrlCreateButton("2", 318, 530, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b5 = GUICtrlCreateButton("5", 318, 470, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b8 = GUICtrlCreateButton("8", 318, 409, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b1 = GUICtrlCreateButton("1", 259, 530, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "unu") $b4 = GUICtrlCreateButton("4", 259, 470, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b7 = GUICtrlCreateButton("7", 258, 409, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b0 = GUICtrlCreateButton("0", 198, 409, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $bminus = GUICtrlCreateButton("-", 198, 470, 57, 57) GUICtrlSetFont(-1, 40, 400, 0, "MS Sans Serif") $bpunct = GUICtrlCreateButton(".", 198, 530, 57, 57) GUICtrlSetFont(-1, 40, 400, 0, "MS Sans Serif") $gfidelizare = GUICtrlCreateGroup("Card Fidelizare", 616, 128, 176, 57) GUICtrlCreateInput("", 628, 150, 153, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $bcauta = GUICtrlCreateButton("Cauta", 505, 409, 65, 57) $cpartial = GUICtrlCreateButton("Partial", 21, 409, 57, 118) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $braport = GUICtrlCreateButton("Raport", 79, 531, 57, 57) $bx = GUICtrlCreateButton("X", 138, 531, 57, 57) ;~ $Picture = GUICtrlCreatePic("", 624, 16, 161, 81, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) While 1 time() WEnd EndFunc Func citeste() Global $totall Global $c, $cc Local $user, $pass, $db, $server, $connect, $niciuncod=1 Local $query, $continut, $xcod, $xnume, $xpv $c=GUICtrlRead($Codbar) $cc=GUICtrlRead($Cantitate) $user = "xxx" $pass = "xxx" $db = "xxx" $server = "xxx" $connect = _MySQLConnect($user,$pass,$db,$server) $query = "SELECT * FROM magazies WHERE CODBAR='"&$c&"'" $continut = _Query($connect,$query) With $continut if .EOF Then MsgBox(0,"Atentie!","Nu am gasit nici un produs cu acest cod") $niciuncod=0; EndIf EndWith if $niciuncod > 0 Then With $continut While Not .EOF $xcod = .Fields ("CODBAR").value $xnume= .Fields ("Articol").value $xpv= .Fields ("pv").value .MoveNext WEnd EndWith _MySQLEnd($connect) GUICtrlCreateListViewItem(''&$xcod&'|'&$xnume&'|'&$cc&'|'&$xpv&'|'&$cc * $xpv&'', $list1) $totall = $totall+($cc * $xpv) GUICtrlSetData ($total, $totall) EndIf GUICtrlSetData ($Codbar, "") GUICtrlSetData ($Cantitate, "1") GUICtrlSetState($codbar, $GUI_FOCUS) EndFunc Func unu() Send("1") EndFunc Func cancel() Exit EndFunc I like IT: php, mysql, codeingiter, css, jquery and AUTOIT
Moderators Melba23 Posted October 29, 2009 Moderators Posted October 29, 2009 ShadowElf,At the moment you script will do absolutely nothing except update the time. :) You call function main which ends:While 1 time() WEndThis is an infinite loop which does nothing but run function time - the rest of your script will never be used!I suggest looking at Adlib to run function time every second - that way you can exit function main and run a While...WEnd loop in your main code to look for key presses etc. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ShadowElf Posted October 29, 2009 Author Posted October 29, 2009 There is GUICtrlSetOnEvent(-1, "cancel") That's a function execute when a button is pressed it exit GUICtrlSetOnEvent(-1, "citeste") (not in script post) activate function citeste when i press a button I want GUICtrlSetOnEvent(-1, "unu") to write in a test area where it is selected "1" Func unu() Send("1") EndFunc I like IT: php, mysql, codeingiter, css, jquery and AUTOIT
Moderators Melba23 Posted October 29, 2009 Moderators Posted October 29, 2009 ShadowElf,Apologies - I missed the GUISetOnEvents buried in the rest of the code.to write in a test area where it is selected "1"Where do you want the "1" to appear? In the input which has focus as you start the script?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ShadowElf Posted October 29, 2009 Author Posted October 29, 2009 (edited) In any input (3 input in form). If I focus on $cantitate write there, if I focus other input, write there And... how to use Adlib AdlibEnable ("time", 1000) Then before While 1 time() WEnd I write time() And I remove it from while... Edited October 29, 2009 by ShadowElf I like IT: php, mysql, codeingiter, css, jquery and AUTOIT
martin Posted October 29, 2009 Posted October 29, 2009 (edited) In any input (3 input in form). If I focus on $cantitate write there, if I focus other input, write there And... how to use Adlib AdlibEnable ("time", 1000) Then before While 1 time() WEnd I write time() And I remove it from while... I think you need to do something like this maybe. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <StructureConstants.au3> #include <GUIListView.au3> #Include <WinAPI.au3> ;#Include <MySQL.au3>;<------------so I could run this Global $IPFocused = 0 main() Func time() While 1 Global $time $time = "DATA:" & @YEAR & ":" & @MON & ":" & @MDAY & " | ORA: " & @HOUR & ":" & @MIN & ":" & @SEC GUICtrlSetData($do, $time) Sleep(1000) WEnd EndFunc ;==>time ;~ MsgBox(0,"Guest List",$xnume) Func main() Global $Form1, $Codbar, $Cantitate, $List1, $inchide, $acc, $acc1, $sterge, $tot, $Benter, $Bback Global $acc2, $acc3, $acc4, $acc5, $acc6, $acc7, $acc8, $acc9, $acc10, $total, $do, $b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8, $b9, $b10 Global $bx, $bpunct, $bminus, $bpartial, $Picture, $braport, $bcauta, $submit Global $b[10] Opt("GUIOnEventMode", 1) $Form1_1 = GUICreate("ShadowPOS", 801, 601, 217, 156) $Codbar = GUICtrlCreateInput("", 438, 41, 137, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "citeste") $Cantitate = GUICtrlCreateInput("1", 438, 85, 137, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $submit = GUICtrlCreateButton("Submit", 1, 1, 1, 1) GUICtrlSetState(-1, $GUI_HIDE) Dim $Form1_AccelTable[1][2] = [["{ENTER}", $submit]] GUISetAccelerators ($Form1_AccelTable) $do = GUICtrlCreateLabel("", 24, 16, 197, 17) $List1 = GUICtrlCreateListView("Codbar|Produs|Cant|PV|Total", 22, 120, 553, 260) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 50) $inchide = GUICtrlCreateButton("Inchide", 21, 530, 57, 57) GUICtrlSetOnEvent(-1, "cancel") $sterge = GUICtrlCreateButton("Sterge", 505, 470, 65, 57) $total = GUICtrlCreateInput("0", 23, 41, 249, 72, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetFont(-1, 40, 400, 0, "MS Sans Serif") $acc = GUICtrlCreateGroup("Acceleratori", 615, 198, 177, 393) $acc1 = GUICtrlCreateButton("Button1", 625, 222, 161, 33) $acc2 = GUICtrlCreateButton("Button2", 625, 257, 161, 33) $acc3 = GUICtrlCreateButton("Button3", 625, 292, 161, 33) $acc4 = GUICtrlCreateButton("Button4", 625, 328, 161, 33) $acc5 = GUICtrlCreateButton("Button5", 625, 364, 161, 33) $acc6 = GUICtrlCreateButton("Button6", 625, 400, 161, 33) $acc7 = GUICtrlCreateButton("Button7", 625, 435, 161, 33) $acc8 = GUICtrlCreateButton("Button8", 625, 470, 161, 33) $acc9 = GUICtrlCreateButton("Button9", 625, 507, 161, 33) $acc10 = GUICtrlCreateButton("Button10", 625, 543, 161, 33) GUICtrlCreateGroup("", -99, -99, 1, 1) $tot = GUICtrlCreateButton("TOTAL", 80, 409, 115, 121) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $Benter = GUICtrlCreateButton("Enter", 439, 408, 57, 118) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Bback = GUICtrlCreateButton("<<", 439, 529, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[3] = GUICtrlCreateButton("3", 378, 529, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[6] = GUICtrlCreateButton("6", 378, 469, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[9] = GUICtrlCreateButton("9", 378, 408, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[2] = GUICtrlCreateButton("2", 318, 530, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[5] = GUICtrlCreateButton("5", 318, 470, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[8] = GUICtrlCreateButton("8", 318, 409, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[1] = GUICtrlCreateButton("1", 259, 530, 57, 57) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "unu") $b[4] = GUICtrlCreateButton("4", 259, 470, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[7] = GUICtrlCreateButton("7", 258, 409, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $b[0] = GUICtrlCreateButton("0", 198, 409, 57, 57) GUICtrlSetOnEvent(-1, "unu") GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $bminus = GUICtrlCreateButton("-", 198, 470, 57, 57) GUICtrlSetFont(-1, 40, 400, 0, "MS Sans Serif") $bpunct = GUICtrlCreateButton(".", 198, 530, 57, 57) GUICtrlSetFont(-1, 40, 400, 0, "MS Sans Serif") $gfidelizare = GUICtrlCreateGroup("Card Fidelizare", 616, 128, 176, 57) GUICtrlCreateInput("", 628, 150, 153, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $bcauta = GUICtrlCreateButton("Cauta", 505, 409, 65, 57) $cpartial = GUICtrlCreateButton("Partial", 21, 409, 57, 118) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $braport = GUICtrlCreateButton("Raport", 79, 531, 57, 57) $bx = GUICtrlCreateButton("X", 138, 531, 57, 57) ;~ $Picture = GUICtrlCreatePic("", 624, 16, 161, 81, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) $IPFocused = $Codbar GUIRegisterMsg($WM_COMMAND, "MYWM_COMMAND") While 1 time() WEnd EndFunc ;==>main Func citeste() Return;<---------------so I could run this Global $totall Global $c, $cc Local $user, $pass, $db, $server, $connect, $niciuncod = 1 Local $query, $continut, $xcod, $xnume, $xpv $c = GUICtrlRead($Codbar) $cc = GUICtrlRead($Cantitate) $user = "xxx" $pass = "xxx" $db = "xxx" $server = "xxx" $connect = _MySQLConnect ($user, $pass, $db, $server) $query = "SELECT * FROM magazies WHERE CODBAR='" & $c & "'" $continut = _Query ($connect, $query) With $continut If .EOF Then MsgBox(0, "Atentie!", "Nu am gasit nici un produs cu acest cod") $niciuncod = 0; EndIf EndWith If $niciuncod > 0 Then With $continut While Not .EOF $xcod = .Fields ("CODBAR").value $xnume = .Fields ("Articol").value $xpv = .Fields ("pv").value .MoveNext WEnd EndWith _MySQLEnd ($connect) GUICtrlCreateListViewItem('' & $xcod & '|' & $xnume & '|' & $cc & '|' & $xpv & '|' & $cc * $xpv & '', $List1) $totall = $totall + ($cc * $xpv) GUICtrlSetData($total, $totall) EndIf GUICtrlSetData($Codbar, "") GUICtrlSetData($Cantitate, "1") GUICtrlSetState($Codbar, $GUI_FOCUS) EndFunc ;==>citeste Func unu() Local $g If $IPFocused = 0 Then ConsoleWrite("no focus" & @CRLF) Return EndIf ControlFocus("ShadowPOS", "", $IPFocused) For $g = 0 To 9 If @GUI_CtrlId = $b[$g] Then If $IPFocused = $total Then GUICtrlSetData($IPFocused,$g,1) Else Send(String($g)) ConsoleWrite($g & @CRLF) EndIf Return EndIf Next EndFunc ;==>unu Func cancel() Exit EndFunc ;==>cancel Func MYWM_COMMAND($hW, $iM, $wP, $lP) Local $iN = BitShift($wP, 16) Local $iID = BitAND($wP, 0xffff) ConsoleWrite(Hex($wP) & ', ' & Hex($iID) & @CRLF) Switch $iID Case $Cantitate, $Codbar, $total If $iN = $EN_SETFOCUS Then ConsoleWrite("focus" & @CRLF) $IPFocused = $iID Else ;$IPFocused = 0 EndIf EndSwitch ;wParam ;The low-order word specifies the edit control identifier. ;The high-order word specifies the notification message EndFunc ;==>MYWM_COMMAND Edited October 29, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
ShadowElf Posted October 29, 2009 Author Posted October 29, 2009 Thx a lot. It work perfect I like IT: php, mysql, codeingiter, css, jquery and AUTOIT
martin Posted October 29, 2009 Posted October 29, 2009 Thx a lot. It work perfectReally? I must have made a mistake somewhere Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now