Page 1 of 1
send . . . at ?
Posted: Sat May 27, 2023 10:11 am
by richmond62
The Richmond Fantasy Machine gets into top gear . . .
Is it possible to do this sort of thing in some sort of way?
Pseudocode [possibly]
send "mouseDown" at the mouseLoc
or
send "mouseDown" at 300,300
Re: send . . . at ?
Posted: Sat May 27, 2023 10:21 am
by richmond62
OR . . .
is it possible to do this sort of thing?
Pseudocode:
get the short name of the object at 300,300
Re: send . . . at ?
Posted: Sat May 27, 2023 10:40 am
by Klaus
Hi Richmond,
real code:
Code: Select all
...
get controlAtLoc((300,300))
## returns -> control (number of control)
put the short name of it
...
Best
Klaus
Re: send . . . at ?
Posted: Sat May 27, 2023 11:04 am
by richmond62
Fantastic, Thank you
Klaus.
BUT:
a cardScript does not work:
Code: Select all
on mouseUp
put the mouseLoc into ZZZZ
get controlAtLoc((ZZZZ))
put the short name of it into fld "XXX"
end mouseUp
Re: send . . . at ?
Posted: Sat May 27, 2023 11:07 am
by SWEdeAndy
Alternative:
Code: Select all
send "mouseDown" to the mouseControl
Re: send . . . at ?
Posted: Sat May 27, 2023 11:21 am
by Klaus
richmond62 wrote: ↑Sat May 27, 2023 11:04 am
Fantastic, Thank you
Klaus.
BUT:
a cardScript does not work:
Code: Select all
on mouseUp
put the mouseLoc into ZZZZ
get controlAtLoc((ZZZZ))
put the short name of it into fld "XXX"
end mouseUp
Just tested and works here!?
Of course you need to click on an existing control!
Re: send . . . at ?
Posted: Sat May 27, 2023 11:26 am
by richmond62
It DOES work if the pointer is over a button, but NOT if it is over a card: that throws an error:
-
-
And that is predictable because a card is an object, not a control.
What I am looking for a something that will report what is UNDER the mouseLoc regardless of whether it is a control or an object.
AND . . .
objectAtLoc does not exist.
It also does not do much good over a field.
Re: send . . . at ?
Posted: Sat May 27, 2023 11:39 am
by SWEdeAndy
richmond62 wrote: ↑Sat May 27, 2023 11:26 am
What I am looking for a something that will report what is UNDER the mouseLoc regardless of whether it is a control or an object.
Something like this (in the card script)?
Code: Select all
on mouseUp
put the mouseControl into tObject
if tObject is empty then put the name of the current card of the mouseStack into tObject
put tObject
pass mouseUp
end mouseUp
on openField
put the mouseControl
pass openField
end openField
Re: send . . . at ?
Posted: Sat May 27, 2023 11:49 am
by richmond62
Exactly.
Love you!
Re: send . . . at ?
Posted: Sat May 27, 2023 4:01 pm
by richmond62
So: obviously I have gone wrong somewhere here as my list field is only filling up with something a bit meaningless:
-
-
script of button "Detector":
Code: Select all
on mouseUp
put empty into fld "PIX"
put item 1 of the topLeft of this stack into stLR
put item 2 of the topLeft of this stack into stUD
put 280 into UD
set the screenMouseLoc to (300 + stLR), (UD + stUD)
repeat until UD > 320
put the mouseControl into XYZ
if XYZ is empty then
put the name of the current card of the mouseStack after fld "PIX"
else
put XYZ after fld "PIX"
end if
put (":" && 300 & "," & UD && cr) after fld "PIX"
add 1 to UD
set the screenMouseLoc to (300 + stLR), (UD + stUD)
end repeat
end mouseUp
Re: send . . . at ?
Posted: Wed May 31, 2023 1:26 pm
by bn
richmond62 wrote: ↑Sat May 27, 2023 4:01 pm
So: obviously I have gone wrong somewhere here as my list field is only filling up with something a bit meaningless:
Richmond,
this works in your stack for button "Detector" for me. Don't ask me why.
Code: Select all
on mouseUp
put empty into fld "PIX"
put item 1 of the topLeft of this stack into stLR
put item 2 of the topLeft of this stack into stUD
put 280 into UD
set the screenMouseLoc to stLR, stUD -- added
set the screenMouseLoc to (300 + stLR), (UD + stUD)
wait 30 milliseconds with messages -- added
repeat until UD > 320
put the mouseControl into XYZ
if XYZ is empty then
put the name of the current card of the mouseStack after fld "PIX"
else
put XYZ after fld "PIX"
end if
put (":" && 300 & "," & UD && cr) after fld "PIX"
add 1 to UD
set the screenMouseLoc to stLR, stUD -- added
set the screenMouseLoc to (300 + stLR), (UD + stUD)
wait 30 milliseconds with messages -- added
end repeat
end mouseUp
I hardcoded a wait 30 milliseconds with messages. If it does not work for you try to increase the milliseconds.
But I still do not understand why you would want to use the screenMouseLoc and why you do not use the mouseLoc and test if it is within the rect of any of the controls of the card.
Kind regards
Bernd
Re: send . . . at ?
Posted: Wed May 31, 2023 1:48 pm
by richmond62
why you would want to use the screenMouseLoc
because
mouseLoc was not working.
Re: send . . . at ?
Posted: Wed May 31, 2023 9:48 pm
by bn
Hi Richmond,
What I was asking is why you do not use something like this:
Code: Select all
on mouseUp
put empty into field "PIX"
put the name of this card into tCdName
repeat with i = the number of controls of this card down to 1
put the rect of control i into tArray[i]
end repeat
put the keys of tArray into tKeys
sort tKeys descending numeric
repeat with y = 280 to 320
put false into tFoundOne
put 300,y into tTestLoc
repeat for each line aKey in tKeys
if tTestLoc is within tArray[aKey] then
put "control" && aKey && tTestLoc & cr after tCollect
put true into tFoundOne
exit repeat
end if
end repeat
if tFoundOne is false then
put tCdName && tTestLoc & cr after tCollect
end if
end repeat
delete char -1 of tCollect -- a return
put tCollect into field "PIX"
end mouseUp
The code I posted earlier did work this morning, but not this evening. It seems to need a special time of the day to work....
However the code I post here is supposed to work at any time of the day.
Kind regards
Bernd