Tyler72738 Posted April 4, 2022 Posted April 4, 2022 Hi!! really sorry I’m very new in auto it and need some assistance, I’m trying to automate a programme where when it’s connected through Ethernet it will start a stream and log the data for me. however sometimes power can be turned on and off and I won’t be there mostly to start the script again. I have tried to get the script to look at a colour change of a certain button as I wasn’t too sure in how to use the state of the button, as the state and the class of the button seemed to stay the same in auto help. so at the moment I have used pixel get color, it does have 2 different color changes as I have used this in its own and it comes back different when the button has changed however when I use this in my script it does not work and I think I have worded my script incorrectly, can I change the wording somehow? script below with the button I’m trying to get it to look at
Moderators Melba23 Posted April 4, 2022 Moderators Posted April 4, 2022 Moved to the appropriate forum. Moderation Team 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
Moderators Melba23 Posted April 4, 2022 Moderators Posted April 4, 2022 Tyler72738, Welcome to the AutoIt forums. Posting an image of the script is not going to help us much. To post code use Code tags - see here how to do it - then we might be able to offer some assistance. 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
Tyler72738 Posted April 4, 2022 Author Posted April 4, 2022 Really sorry! script below: expandcollapse popupLocal $missonsystems = 1 Local $timer = 0 Func connect() Sleep(3000) $startstream = PixelGetColor(291,100) Sleep(5000) MouseClick("left", 207, 69) ;click connect While $disconnectcolor == $startstream Do sleep(5000) $startstream = PixelGetColor(291,100) Sleep(5000) MouseClick("left", 207, 69) Sleep(5000) Until $startstream Not = $disconnectcolor ; keeps trying to connect while in discconect mode sleep(5000) MouseClick("left", 486, 93); tick log ascii Sleep(3000) MouseClick("left", 601, 469); click save on file dialogue sleep(5000) MouseClick("left", 313, 82); press start stream Sleep(5000) WEnd EndFunc WinActivate("SV Telem Viewer v1.0.35") sleep(3000) $disconnectcolor = PixelGetColor(291,100) connect() while $missonsystems If PixelGetColor(291,100) == $disconnectcolor Then ; If disconnected i.e. Mission Systems Off $missonsystems = 0 $timer = 0 MouseClick("left", 488, 98); untick log ascii connect() ElseIf $timer >= 3600 Then Sleep(3000) MouseClick("left", 486, 93); untick log ascii Sleep(3000) MouseClick("left", 486, 94); re-tick log ascii Sleep(3000) MouseClick("left", 601, 469); click save on file dialogue $timer = 0 EndIf Sleep(1000) $timer = $timer + 1 WEnd
636C65616E Posted April 5, 2022 Posted April 5, 2022 (edited) I'm not sure what you're trying to do, but for automation purpose your way to handle the problem is a bit innapropriate. If you're trying to automaticly interact with a program on your computer, you should log the control_id (or any information(s) you could use to identify uniquely each component of the window you want to interact with) of the buttons etc, and send_message to them based on their fetched state(s). This will ensure every action is processed in the right order and way (avoiding the use of dirty sleeps, pixel_colors, ... and taking advantage of the windows message system instead of 'clicking'). By the way: take a look at $timer = TimerInit() ; ... if ( TimerDiff($timer) > 5000 ) then ; ... endif Edited April 5, 2022 by 636C65616E
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