Posts: 11
Threads: 3
Joined: Oct 2008
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
Posts: 12,097
Threads: 142
Joined: Dec 2002
Control id can be changed
Macro
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
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
;/
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
;/
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+
Posts: 11
Threads: 3
Joined: Oct 2008
I was hoping to hard code this into the .NET program.
Do you know how I would set the Button ID in .NET?
Thanks
Posts: 12,097
Threads: 142
Joined: Dec 2002
Use Windows API function SetWindowLong.
Posts: 12,097
Threads: 142
Joined: Dec 2002
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.
Posts: 11
Threads: 3
Joined: Oct 2008
Thanks for the information.
How would I change the code to work in an exe?
Thanks
Posts: 12,097
Threads: 142
Joined: Dec 2002
Posts: 11
Threads: 3
Joined: Oct 2008
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
Posts: 12,097
Threads: 142
Joined: Dec 2002