Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assigning Static Button IDs
#1
Hi,

I have several applications that I would like to use Quick Macros with.
Many of the buttons have the same name and the positions of the buttons change.
The button ID reported by Quick Macros shows that the button ID changes everytime the program is restarted.
How do I make the button ID static?
I don't see an ID property for buttons in .NET.

Thanks
#2
Control id can be changed

Macro
Code:
Copy      Help
SetWindowLong hwnd GWL_ID newId

but the program will not know about it and possibly will stop working.

--------

Maybe you can instead use match index.
Macro
Code:
Copy      Help
int w1=child("text" "class" hwnd 0 0 0 1)
int w2=child("text" "class" hwnd 0 0 0 2)
;...

---------

Or set a property and then find control that has the property.

Function TagControl
Code:
Copy      Help
;/
function hwndControl $tag

;Assigns a string (tag) to the control. The control then can be found by FindTaggedControl.

;hwndControl - control handle.
;tag - some unique string. Use the same string with FindTaggedControl.


SetProp hwndControl tag 1

Function FindTaggedControl
Code:
Copy      Help
;/
function# hwndParent $tag [$text] [$classname] [flags] [ctrlId]

;Finds control previously tagged by TagControl. Returns its handle. If does not find, returns 0.

;tag - the same string that used with TagControl.
;other arguments - the same as with function child.

;See also: <TagControl>

;EXAMPLE
;int hwndParent=win("Calculator")
;int w1=id(126 hwndParent) ;;button "2"
;TagWindow w1 "b2"
;int w2=FindTaggedControl(hwndParent "b2")


ARRAY(int) a; int i h
if(ctrlId) h=child(ctrlId text classname hwndParent flags 0 0 a)
else h=child(text classname hwndParent flags 0 0 a)

for(i 0 a.len) if(GetProp(a[i] tag)) ret a[i]

err+
#3
I was hoping to hard code this into the .NET program.
Do you know how I would set the Button ID in .NET?

Thanks
#4
Use Windows API function SetWindowLong.
#5
It is possible to find .NET controls by name (Button1, TextBox3, etc).

-------
attachment removed,
now here:
Find .NET (WindowsForms) controls. For QM < 2.3.4.
#6
Thanks for the information.

How would I change the code to work in an exe?

Thanks
#7
Tomorrow.
#8
Thanks

The ideal solution I am looking for is a button press using the .NET control name like it is done for ID:
but id(129 win("Calculator" "SciCalc"))
except instead of ID use the control name:
but dotNetControl(btn_name win("Calculator" "SciCalc"))

Thanks
#9
Find .NET (WindowsForms) controls. For QM < 2.3.4.

now works in exe too


Forum Jump:


Users browsing this thread: 1 Guest(s)