Jump to content

Need some help with a project


Recommended Posts

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

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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...