Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling All Talented Macro Creaters
#1
Hello, i manage the IT department for a company and we have been toying with using macros to automate part of an existing system. The tests have show that it does work but unfortunately i dont have much knowledge when it comes to writing macros to be able to write it a well rounded more stable way.

Let me set the scene:

A window called "dispatch console" is open with the curser ready in the text input box.
[Image: 2013-05-10_1336.png]

Theres a scanner linked up to machine, when a barcode is scanned (from a packing invoice) the text is input into the field and then if the order number exists it then pops up another screen which is when the main "function" macro kicks in.
[Image: 2013-05-10_1340.png]

the function macro as i have written it clicks the print button then "wait 6" the click into when it says "freight" up on the dpad twice then clicks save "waits 2" then closes ready for the next order.

the main problem i am having is that A) im not an advanced user B) this is an internet based program so if the internet goes slow for a moment it can increase the time it takes for the buttons to become active and if the macro wait time is less than it actually takes then it will just stop, i know i can increase the time but it doesnt happen all the time and in honesty to slow it down for this will drastically affect the printing time for the 99% orders when the internet is fine. I Understand you can have the macro triggered when buttons become active but i dont have the skills or time to gain the skills so im hoping some one could help me.

Here's the macros i have currently written (main is the function, the others are refresh/ error correction)
We would possibly be able to pay for advanced onsite help

Function Macro
Code:
Copy      Help
int hwnd=val(_command)
int w1=act(win("Process Order" "WindowsForms10.Window.8.app.0.2780b98"))
lef 522 10 w1 1 ;; 'RadControl', push button
wait 5
lef 276 209 w1 1 ;;editable text
'UU             ;; UP UP
lef 704 17 w1 1 ;; 'RadControl', push button
wait 2
lef 790 16 w1 1 ;; 'RadControl', push button

Refresh/ Clear Errors
Code:
Copy      Help
int hwnd=val(_command)
int w1=act(win("Not found" "#32770"))
wait 0.2
lef 461 5 w1 ;;push button 'Close'
int w2=act(win("Dispatch Console" "WindowsForms10.Window.8.app.0.2780b98"))
lef 595 10 w2 ;;push button 'Close'
shutdown -7

Restart Dispatch Console Once Button Becomes Active
Code:
Copy      Help
int hwnd=val(_command)
int w1=act(win("LinnWorks - Order Management - Release 4 - 4.1.1.1 - 380" "WindowsForms10.Window.8.app.0.2780b98"))
lef 1456 201 w1 1 ;; 'RadControl'
int w2=wait(5 win("Dispatch Console" "WindowsForms10.Window.8.app.0.2780b98"))
lef 224 54 w2 1 ;;editable text
shutdown -7

would any one be willing to help me develop this please
#2
Try 'Find image' dialog. It is in the floating toolbar. Creates code to find (on screen) a captured image or wait for it. It is the most universal way to wait for UI state change, for example until button state changes from disabled to enabled.

Other way - accessible objects. Use 'Find accessible object' dialog to see whether the buttons are accessible objects. The dialog also can create code to wait until the button has certain state. But not all UI objects are accessible. If you cannot capture the button using the dialog, you cannot use this.

Or maybe the button is a control (a window in a window). Then use the 'Wait' dialog to wait until window (the control) is enabled. It would be the fastest and most reliable, however not all UI objects are controls. If you cannot capture the button using the dialog, you cannot use this.
#3
Hello Gintaras, thank you for you reply.

would i select "window" or "control" when using "find image"?

and then once i have parent and child name how would i insert that into the macro? like this?

amended script
Code:
Copy      Help
int hwnd=val(_command)
int w1=act(win("LinnWorks - Order Management - Release 4 - 4.1.1.1 - 380" "WindowsForms10.Window.8.app.0.2780b98"))
win("LinnWorks - Order Management - Release 4 - 4.1.1.1 - 380" "WindowsForms10.Window.8.app.0.2780b98") w1 1 ;; 'RadControl'
int w2=wait(5 win("Dispatch Console" "WindowsForms10.Window.8.app.0.2780b98"))
lef 224 54 w2 1 ;;editable text
shutdown -7

if i used the child reference for the window would that be better than using the parent?
orginal script
Code:
Copy      Help
int hwnd=val(_command)
int w1=act(win("LinnWorks - Order Management - Release 4 - 4.1.1.1 - 380" "WindowsForms10.Window.8.app.0.2780b98"))
lef 1456 201 w1 1 ;; 'RadControl'
int w2=wait(5 win("Dispatch Console" "WindowsForms10.Window.8.app.0.2780b98"))
lef 224 54 w2 1 ;;editable text
shutdown -7
#4
Usually it is better to use the smallest possible UI object. With 'Find image' the code will be faster. With 'Find image', if the button is a control, then may even don't need to capture image, instead use 'Wait until something changes' (to wait until the button is enabled).

The 'Find image' dialog will insert the window/control names etc into the macro. Like this:
Code:
Copy      Help
int w=win("Calculator" "CalcFrame")
wait 0 S "Macro2039.bmp" id(83 w) 0 1|16|0x400 ;;push button 'Backspace'
#5
Macro Tutorial. Wait for image when button is enabled.
Code:
Copy      Help
;Assume the macro runs Notepad, pastes some text and opend the Find dialog.
run "notepad.exe"
wait 10 "Notepad"
paste "text to find"
key Cf

;Then you want the macro to wait until the 'Find Next' button is enabled.
;One of possible ways - capture button image in enabled state, and let the macro wait for the image.
;To create code, use the 'Find image' dialog. It's in the floating toolbar, 'Windows, controls' menu.
;At first open Notepad and its Find dialog, let the 'Find Next' button be enabled.
;Open the 'Find image' dialog and click Capture.
;Draw a small rectangle inside the 'Find Next' button. Note that the F is sometimes underlined sometimes not, therefore it's better to not include that part.
;Click OK in the popup menu.
;Click Test. It should show a rectangle around the captured image in the Find dialog.
;In the first combo box select 'Wait for'. Initially it is 'Find'.
;Optionally set timeout, eg 60.
;Uncheck 'Move mouse' if don't need it.
;OK. It creates code like this:
int w=win("Find" "#32770")
wait 60 S "Macro2001.bmp" id(1 w) 0 16|0x400 ;;push button 'Find Next'

;Then the macro continues. If the image not found in 60 s, the macro ends with error.
mes "The button now is enabled."
#6
Macro Tutorial. Wait for control enabled state.
Code:
Copy      Help
;Assume the macro runs Notepad, pastes some text and opend the Find dialog.
run "notepad.exe"
wait 10 "Notepad"
paste "text to find"
key Cf

;Then you want the macro to wait until the 'Find Next' button is enabled.
;One of possible ways - let the macro wait until the button control state is enabled.
;A control is a child window in a window, eg button, edit box, list view. However not all UI objects are controls.
;At first open Notepad and its Find dialog, let the 'Find Next' button be enabled.
;Open the 'Wait' dialog and select 'Wait for window enabled'.
;Select 'Control'. Drag the Drag tool to the 'Find Next' button.
;If the button is a control, you can see a rectangle around it. Else you cannot use this.
;Click Test. It should show a rectangle around the button in the Find dialog.
;Optionally set timeout, eg 60.
;Uncheck 'Get handle' if don't need it.
;OK. It creates code like this:
int w=win("Find" "#32770")
wait 60 WE id(1 w) ;;push button 'Find Next'

;Then the macro continues. If the button is not enabled in 60 s, the macro ends with error.
mes "The button now is enabled."

;This is the best way, however does not work in web pages and with many UI objects in applications where controls (as child windows) are not used.
#7
Macro Tutorial. Wait for accessible object enabled state.
Code:
Copy      Help
;Assume the macro runs Notepad, pastes some text and opend the Find dialog.
run "notepad.exe"
wait 10 "Notepad"
paste "text to find"
key Cf

;Then you want the macro to wait until the 'Find Next' button is enabled.
;One of possible ways - let the macro wait until the button accessible object state is enabled.
;An accessible object is an UI object in a window, eg button, edit box, list view. Not all UI objects are accessible objects.
;At first open Notepad and its Find dialog, let the 'Find Next' button be enabled.
;Open the 'Find accessible object' dialog. It's in the floating toolbar, 'Windows, controls' menu.
;Drag the Drag tool to the 'Find Next' button.
;If the button is an accessible object, you can see a rectangle around it. Else you cannot use this.
;Click Test. It should show a rectangle around the button in the Find dialog. Note: in this case it fails because finds the 'Find accessible object' dialog itself. Need to edit window definition, eg add program name.
;Set timeout, eg 60. Else the code will not wait.
;Check 'state' in the grid. Click the numbers and the small button next to it. Click the Use cell in the 'unavailable' row to make it 'Yes'. It means that the object must not be disabled. OK.
;Test again. It should find the button when it is enabled, and not find when disabled.
;OK. It creates code like this:
int w=wait(60 WV win("Find" "#32770" "notepad"))
Acc a.Find(w "PUSHBUTTON" "Find Next" "class=Button[]id=1[]state=0x100000 1" 0x1005 60)

;Then the macro continues. If the button is not enabled in 60 s, the macro ends with error.
mes "The button now is enabled."


Forum Jump:


Users browsing this thread: 1 Guest(s)