w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
   » Home » Chat robot
Adding private chat functionality to simple twisted chat server
Actually I figured it out by changing the for loop in handle_CHAT. As I want the program to send the message to the specific user, a "talkwith" string can be added to the class and this string can hold that specific user's name. Then this change turns the program from public to private chatting. msg = "<%s> %s" % (self.name,msg) for name,protocol in self.users.iteritems(): if name == self.talkwith: protocol.sendLine(msg)

Categories : Python

Swing chat window creates extra chat windows
Just remove the static keyword from private static UDPCS1 chat = new UDPCS1(); and no more chat windows will be there... Hoping it helped... Helped in my case i was doing something too,...

Categories : Java

PHP AJAX chat - Chat commands logic?
You need to define a syntax for your commands yourself. For example /ban <username> for a ban. First you check whether the message begins with a slash. If so it is a command. Now search for the first space, everything after the slash and in front of the space is the command name. Pass everything after the first space to the command. In this case the username. The command handles the parameters on it's own. It could look like this: $message = '/ban TimWolla'; if (substr($message, 0, 1) === '/') { // $message is a command $firstSpace = strpos($message, ' '); $command = substr($message, 1, $firstSpace); $parameters = substr($message, $firstSpace + 1); if (!hasPermission($command)) error('Permission denied'); switch ($command) { case 'ban':

Categories : PHP

which is faster, saving chat history in a text file and display it or using mysql db to save chat history
For a real-world implementation, I wouldn't consider either one of these a good option, but it definitely could be fun to play with. Using files isn't going to scale as well as the db,well... as easily. But really, I'd look into just setting up a jabber server and play with that. Or maybe look into node.js.

Categories : PHP

Pop up chat box on new chat message
Web sockets tends to be the way to go for chat applications, in your case it sounds like server sent events could be perfect (as from what it sounds you're only receiving events, for two way communication you'll be good using web sockets), both lack support in older browser. So if you need to support older browsers you can go with long polling which out of your choices has the least load on the server as it's one request for every response. See this post: What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet? for more info on the specific technologies

Categories : PHP

Robot and keyPress
Codes are defined as constants in javafx.scene.input.KeyCode. With the glass robot, you can use the deprecated method impl_getCode: Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot(); robot.keyPress(KeyCode.A.impl_getCode()); You can also use the FXRobot, which takes KeyCodes as parameters: FXRobot robot = FXRobotFactory.createRobot(scene); robot.keyPress(javafx.scene.input.KeyCode.A);

Categories : Java

How can I get a RobotState of my robot?
The enum RobotState is only used in the core of RoboCode. There is no getState() method for your robot. (i digged through the source code) However: you can get all theses state in other ways: If your robot is hitting a wall, a HitWall event is fired. you can handle those events by overriding a method in your robot class: @Override public void onHitWall(HitWallEvent e) { //your code } same with hitting a robot: @Override public void onHitRobot(HitRobotEvent e) { //your code } if your robot dies: @Override public void onRobotDeath(RobotDeathEvent event) { //salute your warrior //your code } and if it's alive it should still loop in your runs method: @Override public void run() { do { //here you do the normal stuff a robot does } while(true); }

Categories : Java

RMI with Robot class
of course your system will hang, if not it's a surprise, first set the mouse location by mouseMove(0,0), then you need to add mouse hook listener, to remove again the mouse cursor to 0,0 (NOT IN WHILE LOOP!), and just after the task(if any), remove the listener

Categories : Java

tracking the robot from the overhead cam
Not sure if this will help you, but I did some work related to your post. Though I'd share. http://letsmakerobots.com/node/38208

Categories : Opencv

Nao Robot and "FaceDetected" variable
After a lot of tests I have finally discovered the meaning of the FaceDetected variable. I've written a explanation here I hope it could be useful to others

Categories : C++

Using Java's Robot to hold a key down
Why not use a for loop? for (int i = 0; i < 10; i++) rob.keyPress(whatever); Or, to emulate the hold down effect you want: rob.keyPress(whatever); Thread.sleep(500); for (int i = 0; i < 10; i++) { rob.keyPress(whatever); Thread.sleep(10); } If you want more "organic" behaviour, just randomize the number of iterations.

Categories : Java

How to change orientation of robot in c#
The TurnLeft and TurnRight methods rotate your robot by modifying the mOrientation field and since your have provided a setter property you can change the direction directly by: robot.Orientation = Compass.West;

Categories : C#

Robot moving in a grid
You can write a recursive program that calculates all possible paths, and whenever it arrives at the down right corner it increments the number of paths. I wrote something, but I didn't test it. (Think of it as pseudocode to give you a start). Basically what this does, is call the moveRobot function on the current position (0, 0) with an empty field (the robot hasn't moved yet). Then it tries to move up, down, left and right. This movement is described in the respective functions. If one of these movements succeds(or more than one), the new position is marked in the field with a 1 instead of a 0. 1 means the robot has passed through that position. Then you call moveRobot again. This because in the new position you want to try all four movements once more. Main Function: int field[4][4];

Categories : Algorithm

Use iphone bluetooth to control a robot
iOS now supports Bluetooth 4.0. You would probably be well served to checkout the Core Bluetooth Programming Guide.

Categories : IOS

Robot class - If a Button Is Pressed?
Unfortunately, there isn't a way to directly control hardware (well, in fact there is, but you would have to use JNI/JNA), this means that you can't simply check if a key is pressed. You can use KeyBindings to bind the space key to an action, when the spacebar is pressed you set a flag to true, when it's released you set that flag to false. In order to use this solution, your application has to be a GUI application, this won't work with console applications. Action pressedAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { spaceBarPressed = true; } }; Action releasedAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { spaceBarPressed = false; } }; oneOfYourComponents.getInputMap().put(KeyStroke.getKeyStro

Categories : Java

Robot Framework selecting from UL ID and li class
Figured this out. I create my own element id and click that new id. Example: Assign Id To Element xpath=//li[@onclick="update_blurb('one');"] one Click Element one Thanks for checking it out, Slanec.

Categories : Selenium

Robot Framework - Case sensitive
Luckily Robot Framework allows for keywords to be written in python. MyLibrary.py def Compare_Ignore_Case(s1, s2): if s1.lower() != s2.lower(): return False else: return True def Convert_to_Lowercase(s1): return s1.lower() MySuite.txt | *Setting* | *Value* | | Library | ./MyLibrary.py | | *Test Case* | *Action* | *Argument* # | T100 | [Documentation] | Compare two strings ignoring case. | | Compare Ignore Case | foo | FOO # | T101 | [Documentation] | Compare two strings where one is a variable. # Should be Get Location in your case. | | ${temp}= | MyKeyword that Returns a String | | Compare Ignore Case | foo | ${temp} I have not used the Selenium library, but the example in T101 should work for you.

Categories : Testing

Issue Using Java AWT Robot class
I wouldn't be completely surprised if this were forbidden by the OS or environment; however, have you tried adding robot.keyRelease events? At the moment it's as though you're holding the keys down forever. This may be insufficient to fire the appropriate key up/down/press events that the OS uses to recognise this key combination.

Categories : Java

How do I run the OpenGrasp Robot Editor with Blender on Mac OS X?
From the error you it can't find the python module Blender which represents the python hook to Blender. So there could be a few This could be any number of reasons to do with your setup. The first is that the Blender module is runtime generated whileBlender is running. The specific 'Blender' module used is part of the Blender 2.4x series. According to the link you provided there, they mention porting to newer versions but checking their snv the code is definitely written for 2.49. Blender 2.49b was the last stable release - http://download.blender.org/release/ Ensure you are using that. The next thing is whether it can be run via the the Run Script command TL:DR Start up blender Switch to the text workspace Open the script and see if it can be run directly. If not you will need

Categories : Python

basic recursive backtracking (robot 2D pathfinding)
When recursively building solutions, it's common to pass a partially built solution as an argument to the recursive call. public void travel(int x, int y, String path) { if (x == 0 && y == 0) { System.out.println(path); } else if (x > 0 && y > 0) { travel(x-1, y, path + ' E'); travel(x, y-1, path + ' N'); travel(x-1, y-1, path + ' NE'); } else if (x > 0 && y == 0) { travel(x-1, y, path + ' E'); } else if (y > 0 && x == 0) { travel(x, y-1, path + ' N'); } } See how we build the path as we go along - and let the function calls handle the complexity of remembering where we are in the search? This also has the nice property of simplifying our code, since we get exactly one call to

Categories : Java

Java Robot class working in laptop but not pc
Surely the simple answer to this is not to cheat at games? Try adding e.printStackTrace() to your catch block and look to see if there are errors on the pc version and not on the laptop.

Categories : Java

Creating a 'robot' to fill form with some pages in
Forms work by posting data, so instead of making a robot that would type something into every field and click submit, you can just POST the data to the server. First grab the form fields names, and the action of the form. Then CURL: //set POST variables $url = 'http://domain.com/get-post.php'; $fields = array( 'lname' => urlencode($last_name), 'fname' => urlencode($first_name), 'title' => urlencode($title), 'company' => urlencode($institution), 'age' => urlencode($age), 'email' => urlencode($email), 'phone' => urlencode($phone) ); //url-ify the data for the POST foreach($fields as $ke

Categories : PHP

Using robot class to take screenshot - would like to reduce filesize
Why not simply scale the image you receive: BufferedImage img = robot.createScreenCapture(allScreenBounds); // scaledWidth and scaledHeight are the new smaller image size Image scaledImg = img.getScaledInstance(scaledWidth, scaledHeight, BufferedImage.SCALE_AREA_AVERAGING); If you need the new image to be a BufferedImage, then: BufferedImage scaledBufferedImg = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB); Graphics g = scaledBufferedImg.getGraphics(); g.drawImage(scaledImg, 0, 0, null); g.dispose();

Categories : Java

Robot Framework verify a new browser tab was opened
Selenium does not support tabs (as of June 2013, Selenium 2.33.0) and always opens new windows instead. If your test opens a new tab, good luck to you. That said, if it correctly opens a new window, use Select Window. Select Window | url=https://twitter.com/expectedPage My working WebDriver (2.33.0) code in Java, hopefully it will help a little. The problems you are describing are where my Robot knowledge begins to fall off. @Test public void targetBlankLinkTest() { // load the website and make sure only one window is opened driver.get(file("TargetBlankLinkTest.html")); assertEquals(1, driver.getWindowHandles().size()); // click the link and assert that a new window has been opened driver.findElement(By.linkText("Follow us on Twitter!")).click(); Set&l

Categories : Selenium

Java auto typer with robot class?
With a little help from the code here: Thread.sleep(2000); // Give me time to open up notepad Robot r = new Robot(); for (char c : "I like playing with fire, and Java.".toCharArray()) { int code = KeyEvent.getExtendedKeyCodeForChar(c); if (Character.isUpperCase(c)) r.keyPress(KeyEvent.VK_SHIFT); r.keyPress(code); r.keyRelease(code); if (Character.isUpperCase(c)) r.keyRelease(KeyEvent.VK_SHIFT); } You'll have to do a little more work to get characters like !@#$%&*()_+ to work.

Categories : Java

How to execute jQuery using Selenium2Library under Robot Framework
When you use jquery selector,you need to make sure web is loaded jquery package. if without,you can Execute JavaScript var headID = document.getElementsByTagName("head")[0];var newScript = document.createElement('script');newScript.type='text/javascript';newScript.src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';headID.appendChild(newScript);

Categories : Jquery

java sending keystrokes using robot class
The Robot will send the keystrokes to whichever application window is on top. To send keystrokes to a specific target, you will want to set the target as the platform's foreground window first. Doing this may require native code such as that provided by JNI or (what I use) JNA. If you desire to send keystrokes to a background window, I believe that you cannot use Robot, that you will have to write native code. Of course all native code solutions will be platform dependent. You ask: Would you please give me some more details on how to do it with JNA sorry , I'm writing for windows For Windows, you would interface with the user32.dll library. Something like this has worked for me: User32.java import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win3

Categories : Java

Robot Framework doesn't see Groovy Keywords
EDIT: this answer was only appropriate for the original posting which used the class name 'test'. The problem is that there is already a module named test containing unit tests for Jython itself that being loaded by Robot Framework instead of your test library. Try a more descriptive class name like TestGroovyLibrary. >>> import test >>> help(test) Help on package test: NAME test - # Dummy file to make this directory a package. FILE c:appsjython2.5.3lib est\__init__.py PACKAGE CONTENTS Graph access_protected_class access_protected_field anygui autotest bad_coding ... To see what was loaded you can do this: ${library}= Get Library Instance test Log ${library.__file__} Output

Categories : Groovy

How to compare two strings equal or not in Robot Framework
Yes, that is the correct way of storing variables. Though you can also do it without the equal sign: ${xyz} Get Text xpath=/html/body/div/div[2]/div[3]/div/div/div/div/h3 ${abc} Get Text xpath=/html/body/div/div[2]/div[4]/div/div/div/div/h3 Now that you have the two different strings assigned to variables, you can simply do: Should Be Equal As Strings ${xyz} ${abc} You can see the documentation for Should Be Equal As Strings here.

Categories : Python

Simulating a hardware key press in Java without Robot
Java Native Access (JNA) enables to access the Native levels of Operating systems using Pure Java. You can access the JNA Project here. Furthermore I found a sample which uses JNA to Hook on to Hardware Keyboard to listen to key presses. I think this is what you looking for. If it is not what you are looking for, then you can definitely look through the reference and implement your own.

Categories : Java

Faster alternative to java.awt.Robot.createScreenCapture?
The only way to do this will be through JNI or possibly JNA. I did some benchmarking and native screen capture API and it was able to sustain about 45 FPS vs the Robots 8 FPS. I might be starting on a JNI project to solve this issue in the near future. I will update this post with the project URL if that goes forward.

Categories : Java

Robot detect change in selected area
As shown here, createScreenCapture() can capture a BufferedImage of the pixels in the upright rectangle defined by your two points. You can loop through the pixels using getRGB() to implement any desired heuristic. Your chosen approach to detect a scene change depends on the goal. As a simple concrete example, you could use getHSBColor() to find changes in brightness. More examples may be found in ImageJ.

Categories : Java

Android speech to text for robot control
It can be done. Look at this link. It has also some example code :) You can make it listen and when it speeches you get the word see if it is a keyword and then make the robot do as you want. http://viralpatel.net/blogs/android-speech-to-text-api/

Categories : Android

How to make java robot class type apostrophe '
Java doesn't have KeyEvent.VK_APOSTROPHE Try: robot.keyPress(KeyEvent.VK_QUOTE); or robot.keyPress(KeyEvent.VK_BACKQUOTE); if you want the key above <Tab>

Categories : Java

Robot().createScreenCapture captures image with print dialog in it
Dump it into an array then parse the entire array then you can guarantee that everything is there what I mean is this BufferedImage TestShot = iris.createScreenCapture(new Rectangle(0,0,width,height)); int[] ImgData = null; TestShot.getRGB(0, 0, width, height, ImgData, 0, 0); for(int i:ImgData){ // count or something } // all of it is there in TestShot That should work. I don't know why you are having problems with this, I use the robot all the time and the screenshot function for me works instantly. Maybe its your printJob that takes more time.

Categories : Java

Displaying Library before a User Keyword in Robot Framework
yes, it is possible. This is explained in the documentation: http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.1#specifying-a-keyword-explicitly

Categories : Java

Robot screen capture - heap OutOfMemory while resizing
OutOfMemory errors are not uncommon while working with BufferedImage that's because BufferedImage works with the uncompressed image in memory, so a image that's JPEG encoded and takes maybe 300kb on disc could take up 10mb of memory, and depending on how you tackle the image resizing procedure this can take up much more (by creating lot's of BufferedImages). My suggestion to you is using a image scaling library such as imgscalr, I've used imgscalr sucessfuly in the past to improve memory usage in a legacy Java application that used BufferedImages like crazy to resize images Using imgscalr can be as simple as: BufferedImage thumbnail = Scalr.resize(image, 150);

Categories : Java

how to animate the motion of the mouse from point a to b with robot class?
The problem may be that your conx never truly equals your x2 because you're doing all your math as doubles. That would mean that conx would go from being slightly less than x2 to being slightly greater than x2 and would either bounce back and forth between the two or would continue moving along its current trajectory. You will want to add some logic to make sure you don't step over your target, which you could do by setting a threshold for once it's close enough or by stopping as soon as you over step it.

Categories : Java

How to correctly compute direct kinematics for a delta robot?
I would do it as follows (algebraic representation of graphic solution): compute F1,F2,F3; solve system // spheres from Ji to Ei ... parallelograms (use lower Z half sphere) (x1-J1.x)^2 + (y1-J1.y)^2 +(z1-J1.z)^2 = re^2 (x2-J2.x)^2 + (y2-J2.y)^2 +(z2-J2.z)^2 = re^2 (x3-J3.x)^2 + (y3-J3.y)^2 +(z3-J3.z)^2 = re^2 // Ei lies on the sphere E1=(x1,y1,z1) E2=(x2,y2,z2) E3=(x3,y3,z3) // Ei is parallel to Fi ... coordinate system must be adjusted // so base triangles are parallel with XY-plane z1=z2 z1=z3 z2=z3 // distance between any Ei Ej must be always q // else it is invalid position (kinematics get stuck or even damage) |E1-E2|=q |E1-E3|=q |E2-E3|=q // midpoint is just average of Ei E=(E1+E2+E3)/3 where q is the joint distance |Ei-E| which is constant [Notes] Do not solve it manu

Categories : Java

Robot moving in a grid algorithm possible paths and time complexity ?
Ok, I give you a solution to that problem so that you have better time catching it. First of all, let us decide a solution algorithm. We will count all possible paths for every cell to reach end from it. The algorithm will check cells and write there sum of right and bottom cells. We do it because robot can move down and follow any of bottom paths or move right and follow any of rightside paths, thus, adding the total number of different paths. It is quite obvious for me to prove the divercity of these paths. If you want I can do it in comments. Initial values for cells will be 1 for rightmost bottom cell (finish) because there only 1 way to get there from this cell (not to move at all). And if cell doesn't exist (e.g. taking bottom cell for bottommost cell) it will have value of 0. Buildi

Categories : Algorithm



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.