rawName returns null, probably because you dont set it in your gui untill you click a button. You could just instantiate the variable by just doing String rawName = "". Albeit thats a bad practice IMO. So you should look into how to make your script wait untill the gui is closed.
http://osbot.org/forum/topic/91963-using-synchronized-to-your-advantage/
Also you can watch my tutorial series if you want to do tasks or better states, I upload new tutorials weekly.
http://osbot.org/forum/topic/114013-tutorial-seriesvideo-scripting-made-easy-with-in-depth-explanations/