benzrf Posted July 11, 2012 Share Posted July 11, 2012 I'm trying to write a simple program that lets you specify a series of clicks (and other actions) in a text file. It works pretty well so far, except that the window I'm using it on keeps closing when I try to send a click! Here's my code: expandcollapse popup$instructions = StringSplit(FileRead("instructions.txt"), @CRLF) For $instruction In $instructions If StringMid($instruction, 0, 1) = "#" Then ContinueLoop EndIf $params = StringSplit($instruction, "$") If UBound($params) >= 3 Then $params[3] = "[CLASSNN:" & $params[3] & "]" EndIf Switch StringLower($params[1]) Case "click" Click($params) Case "type" Type($params) Case "tab" Tab($params) Case "select" Select_($params) Case "togglecheck" ToggleCheck($params) EndSwitch Next Func Click($params) ControlClick($params[2], "", $params[3]) EndFunc Func Type($params) ControlSend($params[2], "", $params[3], $params[4]) EndFunc Func Tab($params) If $params[4] = "right" Then ControlCommand($params[2], "", $params[3], "TabRight") Else ControlCommand($params[2], "", $params[3], "TabLeft") EndIf EndFunc Func Select_($params) ControlCommand($params[2], "", $params[3], "SelectString", $params[4]) EndFunc Func ToggleCheck($params) If ControlCommand($params[2], "", $params[3], "IsChecked") Then ControlCommand($params[2], "", $params[3], "UnCheck") Else ControlCommand($params[2], "", $params[3], "Check") EndIf EndFunc Here's instructions.txt: tab$Local Area Connection Properties$SysTabControl321$right click$Local Area Connection Properties$Button2 As you can probably tell, I'm testing it out on the Local Area Connection properties window in Control Panel. If I just put the first line in, it tabs just fine. But if I have both, the window closes instead of the button being clicked. I've double-checked the control names with Window Info, and they're definitely right. Please help! Link to comment Share on other sites More sharing options...
Mechaflash Posted July 11, 2012 Share Posted July 11, 2012 How have you attempted to debug your script to find the issue? Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now