Jump to content

Another use for pixel get Color, or help on why my script is not working - (Moved)


Recommended Posts

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 

6F38F5AF-621C-4670-999C-85F8D550AEA9.jpeg

53000120-8B33-40FB-9977-AF0CCA2F786C.jpeg

C1FF5418-2BD8-46CC-ABF2-3CBEA9CE0E08.jpeg

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Really sorry! 

 

script below:
 

Local $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

 

Link to comment
Share on other sites

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 by 636C65616E
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...