Golbez 2 Posted May 6, 2022 Share Posted May 6, 2022 (edited) expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: Ray Smith Script Function: help add tip numbers into the db #ce ---------------------------------------------------------------------------- #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", 2) Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client Global $tipnum, $mousemovespeed = 2, $title = "Microsoft Access - [tblPreformData]" Global $guiSTART, $guiEND, $start, $end, $Button1, $sendnum $Form1 = GUICreate("Machine Data Helper", 178, 116, 301, 270) $label1 = GUICtrlCreateLabel("Input starting tip #", 8, 8, 89, 17) $Label2 = GUICtrlCreateLabel("Input last tip #", 8, 40, 71, 17) $guiSTART = GUICtrlCreateInput("", 104, 8, 65, 21) $guiEND = GUICtrlCreateInput("", 88, 40, 81, 21) $Button1 = GUICtrlCreateButton("Start", 8, 72, 161, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE terminate() Case $Button1 GUICtrlSetState($Button1,$GUI_DISABLE) If GUICtrlRead($guiSTART) <> "" Then $start = GUICtrlRead($guiSTART) Else $start = InputBox("enter starting tip #: ", "", 0) GUICtrlSetData($guiSTART, $start) EndIf Sleep(10) If GUICtrlRead($guiEND) <> "" Then $end = GUICtrlRead($guiEND) Else $end = InputBox("Enter last tip #: ","") GUICtrlSetData($guiEND, $end) EndIf sendtipnumbers() EndSwitch WEnd Func sendtipnumbers() setupwindow() Sleep(10) If Not WinActive($title) Then WinActivate($title) MouseClick("left", 219, 331, 1, $mousemovespeed) Sleep(10) If ControlGetText($title, "", "OKttbx2") = "" Then ; click header button If $sendnum= 0 Then $sendnum = 1 inputheaderinfo() Sleep(10) inputTipNum() Else ; skip header button and send tip data") inputTipNum() EndIf EndFunc Func setupwindow() If Not WinActive($title) Then WinActivate($title) WinMove ($title, "", @DesktopWidth/4, @DesktopHeight/4, 725 , 615) EndFunc func inputheaderinfo() If Not WinActive($title) Then WinActivate($title) MouseClick("left", 400, 100, 1, $mousemovespeed) If $sendnum= 1 Then $sendnum = 0 inputTipNum() EndIf EndFunc Func inputTipNum() For $tipnum = $start to $end step 1 If Not WinActive($title) Then WinActivate($title) MouseClick("left", 241, 364,1, $mousemovespeed) Sleep(10) Send(StringFormat('%03i',$tipnum), 1) Sleep(10) Send("{TAB 9}") ;Presses TAB 9 times if $tipnum <> $end then inputheaderinfo() Next GUICtrlSetState($Button1,$GUI_ENABLE) EndFunc Func terminate() Exit EndFunc soo this code is to help make my life easier at work, it interacts with a microsoft access document. clicks a button to input data, then i have my script input into based on what the use has in 2 input fields. my issue is it seems to run the for x loop an extra time unwantedly and the information is wrong. what it looks like before i run it: my issue is it send the 049 again on the next record (record 50). not sure why. (sorry i had to black out stuff due to it being related to company info) - none of it is important to the script it was working find without the gui, everything seemed to stop working after i added the gui, im not sure what i did wrong as i feel it should work without running the for x loop again Edited May 6, 2022 by Golbez Link to post Share on other sites
Golbez 2 Posted May 6, 2022 Author Share Posted May 6, 2022 wow, sometimes all you need to do is take a break. walked away for a hour to eat lunch, to come back and fix my script. idk why i had: If $sendnum= 1 Then $sendnum = 0 inputTipNum() EndIf Link to post Share on other sites
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