Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Algorithm Help  RSS feed

 
Dion A
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone. I am writing a program that uses the Java Robot class to basically do all of the keystrokes that a human would do in order to complete a certain process. The Robot performs these keystrokes on another windows program. My goal is to basically find a certain folder from a very large list. I search for this folder by hitting F2 when I land on one and copying the highlighted name into the clipboard, then comparing it against the folder I am looking for(F2 is rename). I know this isn't the best way to do things, but it works, lol, and I don't see another way. The part I need help with is actually finding the folder. The algorithm I developed basically goes down the list by 100 until the current folder number is within a 100 range of the folder number we are looking for. Then I begin moving by one. A problem I have encountered however, is that some people named the folders with zeroes in front, i.e. S05-05555. Since this program orders the folders by String value, these numbers come before any number that does'nt begin with a zero. Therefore if I am looking for 4444 and I run into 05555, then my code will change the direction of the movement upwards, because the current number si higher then the one were looking for, even though it comes before the one I am looking for(making any sense?). Could someone offer a solution for this. I also implement checks to see that I don't end up in an infinite loop because the numbers are all consecutive, so someitmes you can end up moving between the same two folders.

- Thank You!!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "Computer Whiz"-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

Enjoy your time here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!