Simulate input/Mouse: Difference between revisions

(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 216:
{Delay 500}
{Tk.send event(generate Button "<ButtonRelease-1>")}</lang>
 
=={{header|Phix}}==
{{libheader|Phix/pGUI}}
Note that CUSRORPOS, SCREENPOSITION, and MOUSEBUTTON are known to be a little flaky and/or system-dependent, ymmv.
<lang Phix>include pGUI.e
include timedate.e
integer delay = 16 -- (4s @ 250ms)
Ihandle button1
 
function action_cb(Ihandle /*button1*/)
string t = format_timedate(date(),"hh:mm:sspm")
IupSetStrAttribute(button1,"TITLE","Clicked at %s",{t})
return IUP_IGNORE
end function
 
integer cx, cy
 
function timer_cb(Ihandle timer)
if delay then
IupSetStrAttribute(button1,"TITLE","%3.2f",{delay/4})
delay -= 1
{cx,cy} = IupGetGlobal("CURSORPOS")
else
integer {btnx,btny} = IupGetIntInt(button1,"SCREENPOSITION"),
{sx,sy} = IupGetIntInt(button1,"SIZE"),
{dx,dy} = {btnx+sx/2,btny+sy/2}
if {dx,dy}!={cx,cy} then
if IupGetAttribute(timer,"TIME")="250" then
IupSetAttribute(timer,"TIME","40")
IupSetAttribute(timer,"RUN","NO")
IupSetAttribute(timer,"RUN","YES")
end if
for i=1 to 15 do
if cx<dx then cx += 1 end if
if cx>dx then cx -= 1 end if
if cy<dy then cy += 1 end if
if cy>dy then cy -= 1 end if
end for
string cxcy = sprintf("%dx%d ",{cx,cy})
IupSetGlobal("CURSORPOS",cxcy)
else
string s = sprintf("%dx%d 1 2",{btnx+sx/2,btny+sy/2})
IupSetStrGlobal("MOUSEBUTTON", s)
IupSetAttribute(timer,"RUN","NO")
end if
end if
return IUP_CONTINUE
end function
IupOpen()
button1 = IupButton("button1",Icallback("action_cb"),"SIZE=100x12")
Ihandle dlg = IupDialog(button1,`TITLE="Simulate mouse input", CHILDOFFSET=10x40, SIZE=200x80`)
IupShow(dlg)
Ihandle timer = IupTimer(Icallback("timer_cb"), 250)
IupMainLoop()
IupClose()</lang>
 
=={{header|PicoLisp}}==
7,803

edits