antanee52 Posted May 22, 2007 Share Posted May 22, 2007 Hey, I'm new to AutoIt and have only written a few scripts. I'm generally someone who can search until I find what I need, but I would like to get this going tonight. What I need to know is how I would use conditionals... for example... I want this... IF Window Is Open [World of Warcraft] And key is pressed [F5] Then send [Whatever I put]... Anyone know how to write thing's like that? The "WOW WINDOW OPEN" part is not as important as getting it to do something upon keypress. Thanks in advance... Link to comment Share on other sites More sharing options...
McGod Posted May 22, 2007 Share Posted May 22, 2007 $HotKey = "{F5}" $Name = "Notepad" $Send = "Test message" HotKeySet($HotKey, "Function") While 1 Sleep(100) WEnd Func Function () If WinActive($Name) = 1 Then Send($Send) EndIf EndFunc Should do what you want. [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
antanee52 Posted May 22, 2007 Author Share Posted May 22, 2007 $HotKey = "{F5}" $Name = "Notepad" $Send = "Test message" HotKeySet($HotKey, "Function") While 1 Sleep(100) WEnd Func Function () If WinActive($Name) = 1 Then Send($Send) EndIf EndFunc Would that work? Link to comment Share on other sites More sharing options...
Sardith Posted May 22, 2007 Share Posted May 22, 2007 Search for the win. Made this for another members post. expandcollapse popup;Login info; $Path = "C:\Program Files\World of Warcraft\WoW.exe";Default path $Accountname = "Account Name"; Put your WoW password there.. $Pass = "Account Password";Put your WoW password there... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func Logon() If WinExists("World of Warcraft") Then $hWnd = WinGetHandle("World Of Warcraft");Handle of WoW, for controlsend Sleep(100) ControlSend($hWnd, "", "", $Accountname);Sends it to the game, wether your in game or not. Account name. Sleep(100) ControlSend($hWnd, "", "", "{TAB}");Moves down to the password field. Sleep(100) ControlSend($hWnd, "", "", $Pass);Sends it to the game, wether your in game or not. Sleep(100) ControlSend($hWnd, "", "", "{ENTER}");Moves down to the password field. Sleep(100) Else Run($Path, "") Sleep(8000);25 seconds is a bit much... $hWnd = WinGetHandle("World Of Warcraft");Handle of WoW, for controlsend Sleep(100) ControlSend($hWnd, "", "", "Accountname");Sends it to the game, wether your in game or not. Account name. Sleep(100) ControlSend($hWnd, "", "", "{TAB}");Moves down to the password field. Sleep(100) ControlSend($hWnd, "", "", "AccountPassword");Sends it to the game, wether your in game or not. Sleep(100) ControlSend($hWnd, "", "", "{ENTER}");Moves down to the password field. Sleep(100) EndIf EndFunc [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
antanee52 Posted May 22, 2007 Author Share Posted May 22, 2007 Alright I got the first part working. I have a few general autoit questions about it. First of all.... If WinActive($Name) = 1 Then oÝ÷ Ø:²ØZ¶«¨·Z®¢Ùj{ajÚ'#j+ÚYªÜ§íÂ)Ý£·¨¥éÞtz0Â¥tè²ajÛaz··öÉè)¢µ'¢wZºÚ"µÍÌÍÔÙ[H ][ÝÕÝYÜØYÙI][Ý Link to comment Share on other sites More sharing options...
antanee52 Posted May 22, 2007 Author Share Posted May 22, 2007 Okay I got everything except now I have a duplicate function error... probably because I have "Function ()" in there a bunch of times. How do I give them each their own name? Link to comment Share on other sites More sharing options...
antanee52 Posted May 22, 2007 Author Share Posted May 22, 2007 Okay, scratch everything else. For some reason my F6, F7, and F8 keys dont work in the script. I have looked it over and everything is alright.... so what the hell lol. Link to comment Share on other sites More sharing options...
Gif Posted May 22, 2007 Share Posted May 22, 2007 (edited) Okay, scratch everything else. For some reason my F6, F7, and F8 keys dont work in the script. I have looked it over and everything is alright.... so what the hell lol. ok heres the problem 1)you have declared func ("FUNCTION") 4 times and only the first one F5 works 2) you have a lot of While 1 Wend so it should be something like : expandcollapse popup$HotKey = "{F5}" $HotKey2 = "{F6}" $HotKey3 = "{F7}" $HotKey4 = "{F8}" $Name = "World of Warcraft" $Send = "Acct1" $Send2 = "Pass1" $Send3 = "Acct2" $Send4 = "Pass2" $Send5 = "Acct3" $Send6 = "Pass3" $Send7 = "Acct4" $Send8 = "Pass4" HotKeySet($HotKey, "Function") HotKeySet($HotKey2, "Functiontwo") HotKeySet($HotKey3, "Functionthree") HotKeySet($HotKey4, "Functionfour") While 1 WEnd Func Function () If WinActive($Name) = 1 Then Send("$Send") Send("{TAB}") Send("$Send2") Send("{Enter}") EndIf EndFunc Func Functiontwo () If WinActive($Name) = 1 Then Send("$Send3") Send("{TAB}") Send("$Send4") Send("{Enter}") EndIf EndFunc Func Functionthree () If WinActive($Name) = 1 Then Send("$Send5") Send("{TAB}") Send("$Send6") Send("{Enter}") EndIf EndFunc Func Functionfour () If WinActive($Name) = 1 Then Send("$Send7") Send("{TAB}") Send("$Send8") Send("{Enter}") EndIf EndFunc Edited May 22, 2007 by c4nm7 Link to comment Share on other sites More sharing options...
antanee52 Posted May 22, 2007 Author Share Posted May 22, 2007 (edited) Okay, thanks but I already solved it before your post :-P I would put the scripts in here but all my account info is in there lol. Edited May 22, 2007 by antanee52 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