Jump to content
Sign in to follow this  
antanee52

Need some help with a project

Recommended Posts

antanee52

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...

Share this post


Link to post
Share on other sites
McGod

$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.

Share this post


Link to post
Share on other sites
Sardith

Search for the win. Made this for another members post.

;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]

Share this post


Link to post
Share on other sites
antanee52

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][ÝÂ

Share this post


Link to post
Share on other sites
antanee52

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?

Share this post


Link to post
Share on other sites
antanee52

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.

Share this post


Link to post
Share on other sites
Gif

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 :

$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 by c4nm7

Share this post


Link to post
Share on other sites
antanee52

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 by antanee52

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×