Share your advanced PureBasic knowledge/code with the community.
Peyman
Enthusiast
Posts: 203 Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran
Post
by Peyman » Tue Apr 07, 2009 4:57 pm
Lets Fun
Code: Select all
Procedure ShakeMouse(shakiness.l)
rect.POINT
GetCursorPos_(rect)
randX = Random(1)
randY = Random(1)
If randX = 0
XX = rect\x - shakiness
Else
XX = rect\x + shakiness
EndIf
If randY = 0
YY = rect\y - shakiness
Else
YY = rect\y + shakiness
EndIf
SetCursorPos_(XX, YY)
EndProcedure
For a=0 To 1000
Delay(1)
ShakeMouse(2)
Next
Kaeru Gaman
Addict
Posts: 4826 Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany
Post
by Kaeru Gaman » Tue Apr 07, 2009 5:04 pm
what's your PB version?
the SetCursorPos call is not correct that way.
oh... and have a nice day.
Hroudtwolf
Addict
Posts: 803 Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:
Post
by Hroudtwolf » Tue Apr 07, 2009 5:13 pm
Hi,
Nice idea. Funny ^^
Just another try.
Code: Select all
Procedure ShakeMouse( nIntensity.i , tmTimeMS.i )
Protected ptMouse.POINT
Protected nX .i
Protected nY .i
Protected tmEndMS.i
Protected nCount .i
GetCursorPos_( ptMouse )
tmEndMS = ElapsedMilliseconds () + tmTimeMS
While tmEndMS > ElapsedMilliseconds ()
nX = ptMouse\x + ( Sin ( nCount ) * Random ( nIntensity ) )
nY = ptMouse\y + ( Cos ( nCount ) * Random ( nIntensity ) )
SetCursorPos_( nX , nY )
nCount = ( nCount + 1 ) % 360
Delay ( 10 )
Wend
ProcedureReturn #Null
EndProcedure
ShakeMouse ( 15 , 500 )
Regards
Wolf
Sparkie
PureBatMan Forever
Posts: 2307 Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA
Post
by Sparkie » Tue Apr 07, 2009 5:14 pm
Kaeru Gaman wrote: the SetCursorPos call is not correct that way.
Looks correct to me. What would you consider the correct way
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
Kaeru Gaman
Addict
Posts: 4826 Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany
Post
by Kaeru Gaman » Tue Apr 07, 2009 5:29 pm
did I mix momething up?
I thought, API calls awaiting a POINT meanwhile expect the full 64bit Struct as parameter, not two separated 32bit values.
just like WindowFromPoint etc.
oh... and have a nice day.
Sparkie
PureBatMan Forever
Posts: 2307 Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA
Post
by Sparkie » Tue Apr 07, 2009 9:16 pm
SetCursorPos_ doesn't use a POINT structure, it uses two integers, x and y.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
Kaeru Gaman
Addict
Posts: 4826 Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany
Post
by Kaeru Gaman » Tue Apr 07, 2009 10:07 pm
ok, sorry....
the API is inconsistent there, but I could have looked it up.
oh... and have a nice day.
Andesdaf
User
Posts: 85 Joined: Sun Mar 22, 2009 2:53 pm
Location: GER, Saxony
Post
by Andesdaf » Thu Apr 09, 2009 3:05 pm
@Peyman & Wolf:
funny idea.
It ist difficult to click on the "kill program" button with this
code
Demivec
Addict
Posts: 4270 Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA
Post
by Demivec » Thu Apr 09, 2009 3:42 pm
Andesdaf wrote: @Peyman & Wolf:
funny idea.
It ist difficult to click on the "kill program" button with this
code
I tested the code with a drawing program. I started the MouseShake, then I switched to the drawing program and held down the mouse buttons to draw. It produced a rather nice scribble pattern.
Andesdaf
User
Posts: 85 Joined: Sun Mar 22, 2009 2:53 pm
Location: GER, Saxony
Post
by Andesdaf » Sat Apr 11, 2009 4:52 pm
Demivec wrote: Andesdaf wrote: @Peyman & Wolf:
funny idea.
It ist difficult to click on the "kill program" button with this
code
I tested the code with a drawing program. I started the MouseShake, then I switched to the drawing program and held down the mouse buttons to draw. It produced a rather nice scribble pattern.
Oh yes, that's funny
.
With Hroudtwolf's code, i can't move the mouse no longer and so it draws
a thing like a ball.
pdwyer
Addict
Posts: 2813 Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan
Post
by pdwyer » Sat Apr 11, 2009 5:02 pm
Imagine a "nag" that did that to you while the software was unregistered
Paul Dwyer
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein