ducttapedgoat Posted September 13 Report Share Posted September 13 hello! i am trying to get a specific function and i'm not entirely certain the language that this would be written in... my project here is working on a pos terminal, which doesn't have an inherent macro system, and restoring some functions that are very common in older electronic registers, but not present in this pos - specifically when an employee hits VOID to cancel a transaction, the receipt doesn't drop a print of the activity, which is my entire goal here! to get a simple line of text to print on the uncut archive receipt tape when a section of touchscreen window is selected. i figured what would be optimal is to place a listener type macro over those buttons, which are all different colors, and have it listen for those 3 x/y areas and colors (without using colors as control values, it may affect when other menus are open and provide false positives when that area is selected...) anyways. that all being said - is this something AHK can even do? it seems like people are using it for much more complex things like click here then there then go here, more gaming style rpg macros, so its been tough to find anything already done. i guess macroexpresspro can do color detection but i don't even see any functional instance of it for listening. this is definitely complex for me as a day 1 macroer, as most of the forum posts i've been digging through seem to just be trying to program stuff to autosolve captchas. if there is anyone who can help me with a sample type script or a taglist of what commands i would need to use for these functions i would really appreciate it! i need it to do 4 things basically, listen for mouseclick at x/y-x/y verify color at mouseclick send print return to original window x/y location Quote Link to comment Share on other sites More sharing options...
rberq Posted September 13 Report Share Posted September 13 9 hours ago, ducttapedgoat said: is this something AHK can even do? I don't understand your reference to AHK, but I am going to assume you are controlling the POS terminal with a Windows application. You could have a macro that runs continuously, waiting for a mouse click. When a mouse click occurs, get mouse position and get pixel color under mouse. If appropriate area of the screen, and appropriate color, print -- but I'm not sure how to direct printing to the receipt. Back to waiting for mouse click. In pseudo-code: REPEAT START WAIT FOR LEFT MOUSE CLICK GET MOUSE POSITION INTO INTEGER_X, INTEGER_Y GET PIXEL COLOR UNDER MOUSE INTO INTEGER_COLOR IF MOUSE WITHIN RANGE AND IF INTEGER_COLOR = 1234567 TEXT TYPE "VOID" (I'm not sure where this will go -- usually "TYPE" goes wherever the cursor is) END IF REPEAT END Quote Link to comment Share on other sites More sharing options...
acantor Posted September 13 Report Share Posted September 13 The following approach is supported by Macro Express, but it will only be reliable if the screen size, screen resolution, and program configuration are fixed. Otherwise, it can probably be made to work by tweaking the values before using the macros. When creating a Macro Express script, choose "Mouse Event" as activation. Provide the coordinates of a square that corresponds to the position of a button with respect to the window. For example, the region (0,0) - (30,30) is a 30 x 30 pixel square in the upper-left corner of the window. Then check the pixel colour. Make sure the macro is application (or window) specific to prevent activation of the script when using other programs. Repeat for every button. If the buttons happen to be side-by-side, consider using the coordinates of the rectangle that corresponds to the position of the group of buttons, and then checking the pixel colour to determine which button was clicked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.