Jump to content

way to test color of a pixel?


dkh
 Share

Recommended Posts

i need to test the state of a setting in an application, which would easily done by seeing whether a button on a certain window were green or grey.

(details: in Ableton Live - i think it's Java-based, as no GUI control info shows up for the app - i need to see if a MIDI port is set to "on". if i could query whether a given pixel on the button is green or grey, it would be tremendously easier than any of the other contortions required if i couldn't query it directly.)

thanks!

dkh

Link to comment
Share on other sites

  • Moderators

dkh,

Try looking at PixelGetColor. :-)

M23

P.S. Is everything else working now?

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

hey there,

well, i got it all working, then decided i need to go the route you suggested - e.g., using ControlSetText to update a label in the GUI - and that has been going well, until i ran into a string parsing problem!

;this works in a command window
;AutoIt3.exe /autoit3executeline "ControlSetText('huffhead','',6,@min&':'&@sec)"

;but if i put it into this ShellExecute statement, there's a syntax error because of the sequential use of double quotes
ShellExecute("cmd", " /C onmessage --in 7 --program-command 116 AutoIt3.exe /autoit3executeline "ControlSetText('huffhead','',6,@min&':'&@sec)" ")

I've tried double double quotes around the ControlSetText statement. AutoIt's ok with the parsing, but when i actually run the script, the shell doesn't like it. So to test, I put this into a command window:

onmessage --in 7 --program-command 116 AutoIt3.exe /autoit3executeline ""ControlSetText('huffhead','',6,@min&':'&@sec)""

and command barfs with:

The system cannot find the drive specified.
'sec)""' is not recognized as an internal or external command,
operable program or batch file.

I've tried double single quotes in the ShellExecute statement (AutoIt doesn't like it), and inside the ControlSetText statement (command doesn't like it).

So, I'm stuck. The alternative is to create a dozen or two scripts and call those from OnMessage, but I was hoping to get this working to avoid that "layer" of translation.

Any thoughts? Would using Run generate different results?

dkh

Link to comment
Share on other sites

  • Moderators

dkh,

I cannot get it to work either - but then I always have problems with this single/double quote nonsense. Did you not have a way of passing the label text to the GUI before? Surely the same syntax would work here?

I strongly suggest opening a new thread to try and attract some better brains- no-one will ever look here with the title it has! ;-)

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

dkh,

I cannot get it to work either - but then I always have problems with this single/double quote nonsense. Did you not have a way of passing the label text to the GUI before? Surely the same syntax would work here?

I strongly suggest opening a new thread to try and attract some better brains- no-one will ever look here with the title it has! ;-)

M23

You're right, no-one looks here :)

I'm lost with your problem dkh. I don't see why you are trying to use ShellExecute to do something that would normally be in your script. Can't you just have

ControlSetText('huffhead','',6,@min&':'&@sec)

In case there is some reason I would expect that anything that works on the command line will work using run so try

$AutoItProdexePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir");installDir for production
;ConsoleWrite($AutoItProdexePath & @CRLF)

Run('"' & $AutoItProdexePath & '\AutoIt3.exe" /AutoIt3ExecuteLine ' & "ControlSetText('huffhead','',6,@min&':'&@sec)")
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.
Link to comment
Share on other sites

I'm lost with your problem dkh. I don't see why you are trying to use ShellExecute to do something that would normally be in your script.

I'm using a script to start up a small "listener" app called "OnMessage.exe" which listens for MIDI messages and kicks off scripts. Here's the current ShellExecute, which runs fine:

ShellExecute("cmd", "/C onmessage --in 7 " & _
                " --program-command 45 left.au3 " & _
                " --program-command 46 right.au3 " & _
                " --program-command 40 left_toggle.au3 " & _
                " --program-command 41 right_toggle.au3 " & _
                " --program-command 127 space.au3 " & _
                " --program-command 35 select.au3 " & _
                " --program-command 30 send_left.au3 " & _
                " --program-command 31 send_right.au3 " & _
                " --program-command 33 delete.au3 " & _
                " --program-command 127 space.au3 " & _
                " --program-command 26 insert_stop.au3 " & _
                " --program-command 27 dupandloop.au3 " & _
                " --program-command 20 send_left.au3 " & _
                " --program-command 21 send_right.au3 " & _
                " --program-command 23 delete.au3 " & _
                " --program-command 127 space.au3 " & _
                " --program-command 15 PERFORM.au3 " & _
                " --program-command 16 GUI2.au3 " & _
                " --program-command 17 KILL.au3 " & _
                " --program-command 10 Selection_LOAD.au3 " & _
                " --program-command 11 Selection_SWITCH.au3 " & _
                " --program-command 12 Selection_PLAY.au3 " & _
                " --program-command 127 space.au3 " & _
                " --program-command 115 Selection_TOGGLE.au3 " & _
                " --program-command 119 getPixelColor.au3 ")

I'm not sure how I'd run OnMessage inside a script. It sems like it has to run outside the script, unless AutoIt can "hear" MIDI messages.

The problem, though, is that I'm switching from an old way of triggering scripts inside a CASE/SELECT loop to a new way. The old way was that the script (e.g., Selection_LOAD) would temporarily create a GUI called "Selection_LOAD", which would then be "seen" by a WinExists("Selection_") inside the loop, then trigger the LOAD script with a Selection="Selection_LOAD".

The new way (suggested by M23) is much more elegant, and involves having a ControlSetText update the value of a label in the GUI, which can then be read and used to select a case.

My hope was to have OnMessage kick off a one line ControlSetText command which updated the Label, rather than have to have a whole layer of one line scripts which do nothing but execute the corresponding ControlSetText. This would be handy because there are a lot of them, they change whenever I change the configuration of my rig, and I generate the OnMessage script from a spreadsheet, so it'd be quick and easy if I didn't have to set up all the individual scripts. I'm also guessing that it may be faster and more consistent in execution, which is important because I'm trying to implement a "double-click" capability with my MIDI foot pedals using AutoIt (e.g., one click triggers script A, two clicks triggers script B).

So, when I try to get the one line command inserted into the ShellExecute that kicks off OnMessage, I run into all the string quoting issues I mentioned in my first post.

Further news making me think that i just need to go ahead on have a bunch of one-line scripts: when i put the OnMessage command into a DOS batch file,

OnMessage --in 7 --program-command 115 Selection_TOGGLE.au3 --program-command 119 "AutoIt3.exe /autoit3executeline "ControlSetText('huffhead','',6,'hello')""

I still can't get it to work because OnMessage seems to have trouble running the AutoIt3 command. There's a cmd.exe - Application Error popup that says "The application was unable to start correctly (0x00000142). Click OK to close the application."

So, perhaps I bite the bullet and use intermediate script files!

thanks!

dkh

(BTW: after some jiggering, the PixelGetColor is working beautifully.)

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...