I wrote a question here on how to simulate human-like cursor movement with Selenium Web Driver and Java.
On this quest, I discovered that Selenium Web Driver might not be the best fit. It can't move the cursor directly. Or be able to in the fashion I need.
I don't need to physically move the mouse. Just as long as the website thinks the cursor is moving normally.
I have learned about AutoIt automation and have built some scripts. I built a script to automate the Key Strokes I require when uploading a photo. I had the idea to write the file path I need to upload to a .txt file. This is done in my Java App. Then when I call my AutoIt .exe file from Java. It then reads the .txt file. Gets the file path URL. It then does the operations necessary to paste the file path. Then click the "Open" button to upload the file to the website.
Following on from this, I could save coordinates on where I want the mouse to go. In a .txt file. Then when I fire the .exe AutoIt file. It reads this .txt file and does the "human-like" mouse behavior.
I just need to know how to simulate real mouse/cursor movement in AutoIt? A function I can give some coordinates to.
I saw an article on doing in this CSS and JS... This should give you a good idea.
Can anybody help? or offer any advice? Thank you.
Thanks to a comment made on my question. That linked to a script. It works amazingly!
It produces nonlinear mouse movements better than I ever imagined :)
; Smoother Mouse Move
; by the DtTvB
; Ease in function
func __calci1($i, $sm)
return $i ^ $sm;
endFunc
; Ease out function
func __calci2($i, $sm)
return 1 - ((1 - $i) ^ $sm);
endFunc
; Ease in out function
func __calci($i, $sm)
if ($i < 0.5) then
return __calci1($i * 2, $sm) / 2;
else
return (__calci2(($i - 0.5) * 2, $sm) / 2) + 0.5;
endIf
endFunc
; Ease backward function
func __calof($i, $sm)
if ($i < 0.5) then
return __calci($i * 2, $sm);
else
return __calci((1 - $i) * 2, $sm);
endIf
endfunc
; MAIN FUNCTION
func mouseMove2($x2, $y2)
$x1 = mouseGetPos(0);
$y1 = mouseGetPos(1);
$xv = random(-100, 100);
$yv = random(-100, 100);
$sm = random(1.5, 2.5);
$m = random(50, 160);
for $i = 0 to $m
$ci = __calci($i / $m, $sm);
$co = __calof($i / $m, $sm);
$cx = $x1 + (($x2 - $x1) * $ci) + ($xv * $co);
$cy = $y1 + (($y2 - $y1) * $ci) + ($yv * $co);
mouseMove ($cx, $cy, 1);
next
endFunc
; Test Script
mouseMove2 (512, 386);
Related
I working on Lua scripter in game that users are able to write custom Lua script and load it.
I already done with implementation and functions
L = luaL_newstate()
luaL_openlibs()
lua_register(L, cFunction, "luaFunction")
lua_register(L, cFunction2, "luaFunction2")
lua_register(L, cFunctionN, "luaFunctionN")
What I trying now?
Possibility to execute/kill script on button press, below picture for more clarity : https://i.stack.imgur.com/eJQzg.png
All scripts from scripter need to access to Lib.lua so i do:
luaL_loadfile(L, "Lib.lua")
lua_pcall(L, 0, 0, 0)
Then to load script i could use this same thing and is ok until user want to kill/unload script.
luaL_loadfile(L, "script.lua")
lua_pcall(L, 0, 0, 0)
I digging in many threads about Lua API and currently no good answer for this problem.
Ppls talking about lua_newthread that i already tried to implement but no success.
T = lua_newthread(L)
luaL_loadfile(L, "script.lua")
lua_pcall(L, 0, 0, 0)
Return >> Attempt to call a nill value. Look like new thread has no access to Lib.lua
Also there is other problem, when i register function i use:
lua_register(L, cFunction, "luaFunction")
Then even i able to create a thread functions from luaL_newstate*L required to pass handle L to working while handle of thread is T.
Example of C function passing to lua:
static int add (lua_State *L) {
double a = lua_tonumber(L, -1); /* get argument 1 */
double b = lua_tonumber(L, -2); /* get argument 2 */
lua_pushnumber(L, a+b); /* push result */
return 1; /* number of results */
}
Any king of is appreciated.
Regards,
Ascer
I am working on a Dragon Warrior - type rpg game in Game Maker studio and can't figure out how to get a show choice option that doesn't use the mouse. I have setup the game to run completely with a gamepad, but when I am confronted with the situation that requires feedback (choice selection) from the player I am unable to get the gamepad working. Heres the GML
if (distance_to_object(obj_judy)) <= 64 {
if keyboard_check(vk_space) || gamepad_button_check_pressed(0, gp_face3) {
show_question(mine_crystal);
if true {
global.energy -= 10;
global.power_crystal += 1;
instance_destroy();
}
}
}
The problem is " show_question(); " uses a windows-type popup and doesn't work with the gamepad.
How do I get feedback from the player using only inputs from the gamepad?
Thanks for your time reading and your help with this small issue.
So yeah, you'll need to write that logic yourself. Also, that code you wrote there looks kinda scary, i'd use this;
if (show_question(mine_crystal) == true) {
global.energy -= 10;
global.power_crystal += 1;
instance_destroy();
}
because
show_question(mine_crystal);
if true {
global.energy -= 10;
global.power_crystal += 1;
instance_destroy();
}
Will show a question, and then always do the mine crystal action (because your if (true) will always evaluate to true, it doesn't know about the line above
I'm a bit mixed up about how to achieve a division by a scalar on Neon in a specific case.
In a c++ context, I'm achieving a contrast effect with a very rudimentary algorithm:
if (currentEffect == "contrast_with_cpp")
{
r += ((r - 128) / 2);
g += ((g - 128) / 2);
b += ((b - 128) / 2);
}
I would like to port this algorithm to neon intrinsics.
I've tried, but I'm totally newbie to this approach, and I cannot debug this code in Visual Studio. It is compiled at startup and integrated to a Windows Phone application.
if (currentEffect == "contrast_with_neon") /* Experimental, not working *
{
// To test
copy_rgb = rgb;
// Substract 128 from the copy, prevent it should be a signed variable
?
// Get half value from copy and put it in another copy
uint8x8x4_t otherCopy = interleaved;
otherCopy.val[2] = vmul_n_f32(copy_rgb.val[2], 0.5);
otherCopy.val[1] = vmul_n_f32(copy_rgb.val[1], 0.5);
otherCopy.val[0] = vmul_n_f32(copy_rgb.val[0], 0.5);
// Add it to the first copy
copy_rgb.val[2] = vadd_u8(copy_rgb.val[2], otherCopy.val[2]);
copy_rgb.val[1] = vadd_u8(copy_rgb.val[2], otherCopy.val[1]);
copy_rgb.val[0] = vadd_u8(copy_rgb.val[2], otherCopy.val[0]);
rgb = copy_rgb;
}
Is this achievable using intrinsics?
[Edit] I guess the color data structure is similar to this
Stop wasting your time with intrinsics. It's a real pain, especially with gcc.
Try this in assembly :
vmov.i16 qMdeian, #128 // put this line outside of loop
// -----------------------------------------------
vmovl.u8 qRed, dRed
vmovl.u8 qGrn, dGrn
vmovl.u8 qBlu, dBlu
vsub.s16 qRedTemp, qRed, qMedian
vsub.s16 qGrnTemp, qGrn, qMedian
vsub.s16 qBluTemp, qBlu, qMedian
vshr.s16 qRedTemp, #2
vshr.s16 qGrnTemp, #2
vshr.s16 qBluTemp, #2
vadd.s16 qRed, qRedTemp
vadd.s16 qGrn, qGrnTemp
vadd.s16 qBlu, qBluTemp
vqmovun.s16 dRed, qRed
vqmovun.s16 dGrn, qGrn
vqmovun.s16 dBlu, qBlu
If the does saturate at 255, and any negative values will become zeros which I assume is intended.
PS : What are you doing with float?
so I am trying to dynamically create shapes based on a number pulled from a database. I've tried the most logical way of wrapping a for loop around creating a shape and subsequently adding the shape into a layer. But for some reason unknown to me, it keeps re-modifying the same shape even though the shapes stored in the layer should be at different positions (and different attributes).
My code is the following:
function graph(w) {
barLayer.removeChildren();
var bar = new Array();
for (var i = 1; i <= array.length; i++) {
var pos = i * Math.PI / 30;
var scaleUp = (i / array.length) * 2.5;
bar[i-1] = new Kinetic.Shape({
drawFunc: function(context) {
context.beginPath();
context.moveTo(radius2, radius2);
context.arc(radius2, radius2, scaleUp * radius2, (- Math.PI / 2) - w + pos, (- Math.PI / 2) - w + (Math.PI / 30) + pos, false);
context.closePath();
this.stroke(context);
this.fill(context);
},
fill: "#333",
stroke: "#000",
strokeWidth: 4,
x: centerX,
y: centerY,
offset: [200,200],
});
console.log("Starting: ", (- Math.PI / 2) - w + pos, "/ Ending: ", (- Math.PI / 2) - w + (Math.PI / 30) + pos);
}
for (var n = 0; n < bar.length; n++) {
barLayer.add(bar[n]);
}
barLayer.draw();
}
I've tried everything from putting the shapes in an Array to just creating a new shape and adding it in within the for loop. I'm definitely missing something.
I have done a bit of searching regarding this topic and I found one comment relevant to what I'm trying to do:
Basically, you need need to keep an array of shape objects and push new objects onto the array when you add a new shape. Within the setDrawStage() method of the kin object, just loop through the array and draw each object. I’ll let you know when I get the lab published.
I've looked all over for a setDrawStage() method and I can't find much data associated with it. He also stated to put the for loop inside the method which is a bit confusing as I do not only want to draw the shape but also store it in a layer (as I have done for every other shape).
Does anyone possibly have a solution? Much appreciated in advanced.
I think you're having a JavaScript closure problem. More on that:
How do JavaScript closures work?
Try moving all of the logic inside the for loop into a function to induce scope. Also, instead of using Kinetic.Shape, why not use Kinetic.Circle?
X and Y in your script do not change as far as I can tell so your shape will always start from the same position?
I have been developing a very simple text game using Objective C and Xcode. It is almost done but I am having a problem, the scanf method stops the loop and asks for user input while I need the computer to be running the rest of the loop, the solution I came up with was running two while loops at the same time, one being the logic loop and another being a loop for user input.
I have been doing my research and it looks like using threads are the way to go, I just have not found a tutorial that will break it down for a n00b in Objective C (I am decent in java, I just have never worked with threads). If anybody could explain them or link me to a very broken down tutorial that would be great. Or if anybody has another idea I am open to anything else.
Necessary Code (The scanf I am having a problem with has asterisks on the line):
while(running != 0)
{
if(gameState == 1)
{
if(timeToGenerateNum == true)
{
while(randNumber < 10000000)
{
randNumber = arc4random() % 100000000;
}
NSLog(#"%i", randNumber);
timeToGenerateNum = false;
}
else
{
while(time <= 2500)
{
NSLog(#"Testing");
time++;
******************scanf("%i", &userNum);************************
if(userNum == randNumber)
{
score += time;
time = 0;
timeToGenerateNum = true;
}
}
NSLog(#"Game Over! Your score was %i!", score);
running = 0;
}
}
else if(gameState == 2)
{
NSLog(#"To play, simply type in the number that appears on the screen.");
NSLog(#"But be careful, you only have a short amount of time before GAME OVER!");
NSLog(#"The quicker you type in the number the more score you get!");
NSLog(#"Are you ready to start, if so type '1' and press enter!");
scanf("%i", &gameState);
}
}
You're going to have to learn a bit about BSD (Unix, Linux) input/output to pull this off: replace your call to scanf with a non-blocking function you write to acquire input from the user's keyboard.
This function should immediately return whatever the user typed, or immediately return with a zero character count if she didn't type anything.
Read up on the select(2) system call, and keep in mind that keyboard input (standard input) is the first file descriptor, file descriptor zero.