Jump to content

It_is_me_Me

Members
  • Posts

    12
  • Joined

  • Last visited

Recent Profile Visitors

228 profile views

It_is_me_Me's Achievements

  1. That is so good Dan_555. I'll try that in my code. I already made some makeshift code where I am entering the setting locally in my .ini file. But yours is way better.
  2. ;Sample only. I only pick these two lines of code but actually they are more and are linked to the code below it. Global $input_tcpPort = GUICtrlCreateInput("502", 196, 81, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUICtrlSetData($input_tcpPort, IniRead ("Ini File.ini", "TCP", "Port", "")) Case $btn_runTest ;--GUI INI File Start-- IniWrite('Ini File.ini', "Serial-485", "Protocol", GUICtrlRead($comboBox_serialProtocol)) IniWrite("Ini File.ini", "Serial-485", "BaudRate", GUICtrlRead($comboBox_serialBaudrate)) IniWrite("Ini File.ini", "Serial-485", "Port", GUICtrlRead($comboBox_serialPort)) IniWrite("Ini File.ini", "Serial-485", "Address", GUICtrlRead($input_serialAddress)) IniWrite('Ini File.ini', "USB", "Protocol", GUICtrlRead($comboBox_usbProtocol)) IniWrite("Ini File.ini", "USB", "BaudRate", GUICtrlRead($comboBox_usbBaudrate)) IniWrite("Ini File.ini", "USB", "Port", GUICtrlRead($comboBox_usbPort)) IniWrite("Ini File.ini", "USB", "Address", GUICtrlRead($input_usbAddress)) IniWrite('Ini File.ini', "Optical", "Protocol", GUICtrlRead($comboBox_opticalProtocol)) IniWrite("Ini File.ini", "Optical", "BaudRate", GUICtrlRead($comboBox_opticalBaudrate)) IniWrite("Ini File.ini", "Optical", "Port", GUICtrlRead($comboBox_opticalPort)) IniWrite("Ini File.ini", "Optical", "Address", GUICtrlRead($input_opticalAddress)) IniWrite("Ini File.ini", "TCP", "Address", GUICtrlRead($input_tcpDevAddress)) IniWrite("Ini File.ini", "TCP", "Port", GUICtrlRead($input_tcpPort)) SO I made some adjustments to my code. I just use INI file so the script can get its data from it.
  3. So far, I am planning to make an INI file and use the INIWrite so the settings on my combobox will remember it.
  4. I am making some GUI with combobox for the Baudrates communications and I listed 9600, 57600, 115200. I wrote the code to be defaulted to 57600 like this: GUICtrlSetData($comboBox_opticalBaudRate, "9600|57600|115200", "57600") But I wanted the GUI to remember the last item the user picks so the baudrates will NOT be defaulted to 57600. Example, I pick 9600 as my baudrates, then I close the GUI, after opening it, it always prompt 57600 since that is what I did in my code. But I want that if I choose 9600 and close the GUI, opening it again will show 9600 now instead of 57600. Is there a way to do it in GUI setting? Thanks.
  5. I did this to manage to minimize the line of codes.. but I am somewhat not satisfied since what I made is kinda silly. #include <GUIConstantsEx.au3> #include <AutoItConstants.au3> Global $comms $commsTCP = "TCP" $comms485 = "485" $commsUSB = "USB" $commsOptics = "Optical" Example() Func Example()     ; Create a GUI with various controls.     Local $hGUI = GUICreate("Example", 300, 200)     ; Create a button control.     Local $idButton_runtest = GUICtrlCreateButton("Run Test", 120, 170, 85, 25)     Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)     ; Display the GUI.     GUISetState(@SW_SHOW, $hGUI)     Local $iPID = 0     ; Loop until the user exits.     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE, $idButton_Close                 ExitLoop             Case $idButton_runtest                ;TCP                test1($commsTCP)                all()                ;Serial 485                test1($comms485)                all()                ;USB                test1($commsUSB)                all()                ;Optical                test1($commsOptics)                all()         EndSwitch     WEnd     ; Delete the previous GUI and all controls.     GUIDelete($hGUI)     ; Close the Notepad process using the PID returned by Run.     If $iPID Then ProcessClose($iPID)     EndFunc   ;==>Example Func all()    test2()    test3()    test4()    test5() EndFunc Func test1($comms)    SplashTextOn("", "Communicating via " & $comms, 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test2()    SplashTextOn("", "Test Case 2", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test3()    SplashTextOn("", "Test Case 3", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test4()    SplashTextOn("", "Test Case 4", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test5()    SplashTextOn("", "Test Case 5", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc
  6. I am writing scripts to test four communications... TCP, Serial, USB, and Optical. Let's say that I have 5 test cases: TC#1 is communicating TCP TC#2 is do A TC#3 is do B TC#4 is do C TC#5 is do D Next test case 1 is communicating via Serial 485 now since TCP just finished testing. Then TC#2 to #5 will be used again but not in TCP but in serial 485 now which is identical test. Same goes to USB and Optical ports.. So basically, the test case #1 is the only different to the steps while test #2 to 5 will be reused to all comms (tcp, serial, usb, optical) What would be the best approach to code this so the line of code will be minimized? I want to reduce the redundant use of test cases 2 to 5 since those test are the same to all comms. Any help and critics are welcome. Here are my sample scripts: #include <GUIConstantsEx.au3> #include <AutoItConstants.au3> Global $comms $commsTCP = "TCP" $comms485 = "485" $commsUSB = "USB" $commsOptics = "Optical" Example() Func Example()     ; Create a GUI with various controls.     Local $hGUI = GUICreate("Example", 300, 200)     ; Create a button control.     Local $idButton_runtest = GUICtrlCreateButton("Run Test", 120, 170, 85, 25)     Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)     ; Display the GUI.     GUISetState(@SW_SHOW, $hGUI)     Local $iPID = 0     ; Loop until the user exits.     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE, $idButton_Close                 ExitLoop             Case $idButton_runtest                ;TCP                test1($commsTCP)                test2()                test3()                test4()                test5()                ;Serial 485                test1($comms485)                test2()                test3()                test4()                test5()                ;USB                test1($commsUSB)                test2()                test3()                test4()                test5()                ;Optical                test1($commsOptics)                test2()                test3()                test4()                test5()         EndSwitch     WEnd     ; Delete the previous GUI and all controls.     GUIDelete($hGUI)     ; Close the Notepad process using the PID returned by Run.     If $iPID Then ProcessClose($iPID)     EndFunc   ;==>Example Func test1($comms)    SplashTextOn("", "Communicating via " & $comms, 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test2()    SplashTextOn("", "Test Case 2", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test3()    SplashTextOn("", "Test Case 3", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test4()    SplashTextOn("", "Test Case 4", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc Func test5()    SplashTextOn("", "Test Case 5", 280, 60, -1, -1, $DLG_CENTERONTOP , "", 14)    Sleep(1000)    SplashOff() EndFunc I'm somewhat new to programming and just barely manage to write something good (so far).
  7. I can't believe it somewhat simple as that that I can't believe I miss that out. Thanks a lot Zedna.
  8. I have provided a portion of my script (seen below) and I wanted to use what the USER will input into my IP address box and input box for TCP port. I set the IP address to use 0.0.0.0 as default and the Port to 502. But I want to let the user change it and when they click the buttons (IP Address and Port), the tooltip will show what the USER entered. How can I use the details that the User will input into my input box and IP address box and let them see what they entered when they click the buttons? Here are the scripts: ;------------------------------------------------------------- #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <TabConstants.au3> #include <GuiTab.au3> Global $Form1 = GUICreate("Security Automation", 490, 339, -1, -1) ;MAIN Tab Global $TAB = GUICtrlCreateTab(0, 0, 489, 337) Global $tab_main = GUICtrlCreateTabItem("Main") $label_Title = GUICtrlCreateLabel("ETP-073 Security", 12, 33, 103, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") ;-----------------TCP User input information------------------------------------------------------------------------------- $groupBox_TCP = GUICtrlCreateGroup("TCP", 12, 49, 289, 57, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) ;TCP IP address Global $IPAddress1 = _GUICtrlIpAddress_Create($Form1, 20, 81, 170, 21) $Label_ipAddress = GUICtrlCreateLabel("Host IP Address", 20, 65, 80, 17) $userInputIP = _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0") ;TCP Port $label_tcpPort = GUICtrlCreateLabel("Port", 196, 65, 23, 17) Global $input_tcpPort = GUICtrlCreateInput("502", 196, 81, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $userPort = GUICtrlRead($input_tcpPort) ;TCP Address $label_tcpAddress = GUICtrlCreateLabel("Addr.", 260, 65, 29, 17) Global $input_tcpDevAddress = GUICtrlCreateInput("1", 260, 81, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) ;Buttons Global $btn_userIP = GUICtrlCreateButton("User IP", 308, 297, 81, 25) Global $btn_Port = GUICtrlCreateButton("Port", 404, 297, 75, 25) ;Showing the GUI GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn_userIP ToolTip($userInputIP) Case $btn_Port ToolTip($userPort) EndSwitch WEnd ;--------------end of script ------------------ Note: There will be a "!->Includefile <WMDebug.au3> not found." Pay no attention to it.
  9. Hi. I am just a week-old AutoIt user and having lots of fun and also tons of problems with it including this: I have made some scripts using auto-clicking the one part of the list. It seems that the list is in GRID. So the list indicates User1, User2, upto User10. I wanted to pick for my test the User5 and the Coords of that particular list in the window are 64, 117 (but I'm using 65, 115 which is still in range). Here are the Autoit details that I get and used: >>>> Control <<<< Class: WindowsForms10.Window.8.app.0.297b065_r61_ad1 Instance: 5 ClassnameNN: WindowsForms10.Window.8.app.0.297b065_r61_ad15 Name: grid_Users Advanced (Class): [NAME:grid_Users] ID: 7997658 Text: Position: 6, 161 Size: 155, 409 ControlClick Coords: 64, 117 Style: 0x56010000 ExStyle: 0x00000200 Handle: 0x00000000007A08DA ------------------------ So I am using the SCRIPT seen at the bottom but it seems that the ControlClick("[CLASS:WindowsForms10.Window.8.app.0.297b065_r61_ad1]", "","WindowsForms10.Window.8.app.0.297b065_r61_ad15", "left", 1,65,115) is not clicking. It is just selecting. I tried to add Send("{ENTER}") but it does not help at all and not clicking. The SCRIPT that I make (sorry if I use Sleep more than often): Local $_userPW = "1234AbCd" Local $_userName = "UserMe" If WinExists("[CLASS:WindowsForms10.Window.8.app.0.297b065_r61_ad1]") Then ; for TCP comm only ControlClick("[CLASS:WindowsForms10.Window.8.app.0.297b065_r61_ad1]", "","WindowsForms10.Window.8.app.0.297b065_r61_ad15", "left", 1,65,115) Sleep(1000) ControlSetText ( "Shark 250 Security Editor", "", "[CLASS:WindowsForms10.EDIT.app.0.297b065_r61_ad1; INSTANCE:5]", $_userMe) Sleep(700) ControlSetText ( "Shark 250 Security Editor", "", "[CLASS:WindowsForms10.EDIT.app.0.297b065_r61_ad1; INSTANCE:4]", $_userPW) Sleep(700) ControlSetText ( "Shark 250 Security Editor", "", "[CLASS:WindowsForms10.EDIT.app.0.297b065_r61_ad1; INSTANCE:3]", $_userPW) Sleep(1000) ;ControlClick("Shark 250 Security Editor", "", "[CLASS:WindowsForms10.BUTTON.app.0.297b065_r61_ad1; INSTANCE:7]") ;Sleep(2000) ;ControlClick("Shark 250 Security Editor", "", "[CLASS:WindowsForms10.BUTTON.app.0.297b065_r61_ad1; INSTANCE:8]" , "" ) ElseIf WinExists("[CLASS:WindowsForms10.Window.8.app.0.297b065_r60_ad1]") Then ; for Serial comm only ControlClick("[CLASS:WindowsForms10.Window.8.app.0.297b065_r60_ad1]", "","WindowsForms10.Window.8.app.0.297b065_r60_ad15", "left", 1,65,115) Sleep(1000) ControlSetText ( "Shark 250 Security Editor", "", "[CLASS:WindowsForms10.EDIT.app.0.297b065_r60_ad1; INSTANCE:5]", $_userMe) Sleep(700) ControlSetText ( "Shark 250 Security Editor", "", "[CLASS:WindowsForms10.EDIT.app.0.297b065_r60_ad1; INSTANCE:4]", $_userPW) Sleep(700) ControlSetText ( "Shark 250 Security Editor", "", "[CLASS:WindowsForms10.EDIT.app.0.297b065_r60_ad1; INSTANCE:3]", $_userPW) Sleep(1000) ControlClick("Shark 250 Security Editor", "", "[CLASS:WindowsForms10.BUTTON.app.0.297b065_r60_ad1; INSTANCE:7]") Sleep(2000) ControlClick("Shark 250 Security Editor", "", "[CLASS:WindowsForms10.BUTTON.app.0.297b065_r60_ad1; INSTANCE:8]" , "" ) Else ; for other comms like USB and optics. ToolTip("Other Comms Ongoing!") Exit EndIf I tried mouseclick and it is working well in my scripts but I dont want to rely on mouseclicks because it could cause errors when the window is blocked by other apps. Anything to give me insights to fix my problem to click the portion of the window I wanted to click and not just selecting it? Thanks very much - Me -
  10. @JockoDundee, Yes, that's what I'm looking. It works in my code. Thanks.
  11. I am writing codes where there are same windows showing up. That window can be accessed using two communications: TCP and Serial comm. Both communications have same window when I tried to access it but the class name is different for Serial and for TCP. I would like to make an IF statement using the CLASS name of Basic control info but unable to find one. Can we do that? Thanks.
×
×
  • Create New...