Jump to content
Sign in to follow this  
para

Looking for the second, then third, ect text

Recommended Posts

If anyone can help me with this it would be greatly appriciated!

What I want to be able to do is send a command to a computer running this script, and it execute it via text.

I want to use aim as the source of sending the commands.

Heres what I got.

Opt("WinTitleMatchMode", 3)
Global $var1, $var2, $var3, $var4

While 1
  Activate ()
   Commands ()
WEnd

Func Activate ()
  WinWait("Untitled - Notepad", "!activate")
EndFunc


Func Commands ()
 While 1
   $var1 = WinExists("Untitled - Notepad", "!run notepad")
   $var2 = WinExists("Untitled - Notepad", "!run paint")
   $var3 = WinExists("Untitled - Notepad", "!run calc")
   $var4 = WinExists("Untitled - Notepad", "!run cmd")

If $var1 = 1 Then
  Run("notepad.exe")
 ExitLoop
EndIf

If $var2 = 1 Then
  Run("mspaint.exe") 
 ExitLoop
EndIf

If $var3 = 1 Then
  Run("calc.exe") 
 ExitLoop
EndIf

If $var4 = 1 Then
  Run("cmd.exe")
 ExitLoop
EndIf
WEnd
EndFunc

What it will do is, if autoit sees the window open NOTEPAD(will be replaced with aim) then it will wait for !activate.

After it see !activate on the screen then it will start to loop, looking for one of the commands I have listed(there will be a ton more).

When it sees one of those commands, it will execute it, and reloop to the first option, and wait to see !activate again.

The only problem is it will already be on the screen. I thought of the possibility of just having it close the window after seeing !activate, but I want this to be right, and I think it would be useful for other cercomstances(SP).

What I am asking is....

How would I make it so that after it finds the first !activate, it goes to the loop, and then when it gets back to the waiting for !activate, it loops for the SECOND one from the top down. Then when it goes again, it looks for the 3rd, and 4th, and so on and so forth.

I figured there would be somthing about strings or arrays that would allow me to just tell it took look for the next one then +1 each time it gets to it, which I have done on counters or timers before, but I couldn't come acrossed what I was looking for.

Any help would be greatly appriciated! Thanks alot!

If you need any further information to assist me with this problem, please feel free to ask!

-Para :idiot:


Share this post


Link to post
Share on other sites

Warning: I would test it with AIM before you go all the way as to write the program then find out it doesn't work...

Okay, not sure if i got you but you want all the commands in a better way then just manually checking them?

To work it type !Name@, the @ is telling the script that it's time to use the command. I discovered that it will cause errors with just !Name or !Activate because of different things.

Here is a quick script (note, it might need a good debug):

;
;
;~~~~~~~~~~~~~~~~~~~~~~~~~ This is window name
;
Global Const $Window = "Untitled - Notepad"
;
;~~~~~~~~~~~~~~~~~~~~~~~~~ This is window name
;
;
Read()
While 1
    Activate()
    Send('{BACKSPACE}')
    For $Number = 1 To $Array[0][0]
        If _WinExists($Array[$Number][1], $Array[$Number][4]) Then    Run ('"' & $Array[$Number][2] & '" ' & $Array[$Number][3]
    Next
    If _WinExists('Exit', 1) Then Exit
    If _WinExists('New', 1) Then New()
WEnd
Func Activate()
    WinWait($Window, "@")
EndFunc  ;==>Activate
Func New()
    IniWrite('file.ini', '_GLOBAL_', 'Number', IniRead('file.ini', '_GLOBAL_', 'Number', 0) + 1)
    $Number = IniRead('file.ini', '_GLOBAL_', 'Number', 1)
    $Nick = InputBox('Nickname', 'Enter a nickname for this command (NOT the !cmd)')
    IniWrite('file.ini', '_GLOBAL_', 'Number_' & $Number, $Nick)
    IniWrite('file.ini', 'Command_' & $Nick, 'Command', InputBox('Name', 'Enter a name for this command to be run using ! (name)'))
    IniWrite('file.ini', 'Command_' & $Nick, 'File', FileOpenDialog('File', @ScriptDir, 'Executable files (*.exe)', 3))
    IniWrite('file.ini', 'Command_' & $Nick, 'Param', InputBox('Param', 'Enter any parameters that are needed'))
    Read()
EndFunc  ;==>New
Func _WinExists($text, $status)
    If Not $status Then
        Return 0
    ElseIf WinActive($Window, '!' & $text) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc  ;==>_WinExists
Func Read()
    $Number = IniRead('file.ini', '_GLOBAL_', 'Number', 0)
    If $Number = 0 Then New()
    Global $Array[$Number + 1][5]
    $Array[0][0] = $Number
    For $Number = 1 To $Array[0][0]
        $Array[$Number][0] = IniRead('file.ini', '_GLOBAL_', 'Number_' & $Number, '')
        If $Array[$Number][0] = '' Then
            $Array[$Number][4] = 0
            ContinueLoop
        EndIf
        $Array[$Number][1] = IniRead('file.ini', 'Command_' & $Array[$Number][0], 'Command', '')
        If $Array[$Number][1] = '' Then
            $Array[$Number][4] = 0
            ContinueLoop
        EndIf
        $Array[$Number][2] = IniRead('file.ini', 'Command_' & $Array[$Number][0], 'File', '')
        If $Array[$Number][2] = '' Then
            $Array[$Number][4] = 0
            ContinueLoop
        EndIf
        $Array[$Number][3] = IniRead('file.ini', 'Command_' & $Array[$Number][0], 'Param', '')
        $Array[$Number][4] = 1
    Next
EndFunc  ;==>Read
Edited by Wolvereness

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

You kind of confused me as I did you.

Thank you for taking the time to do that, but Im not sure if thats what I am looking for.

I want to enter the commands manually.

What I need to know is how to make it so that if the screen looks like this

!activate

!run notepad

!activate

!run cmd

Then to stop and wait for the third !activate, and not use the first or second, since it has already used them.

That way I could do this.

1. !activate (then it would prepare for a command by looping through the possibilities)

2. !run notepad (then it would run notepad and go back up to Activate () and wait for a command)

See the problem is, when it loops after number 2, it will not look at the screen and run notepad again just because its on the screen. I want it to wait for a second !activate to appear, and a second command to appear. So I will probably make it so that the command to activate is, $activate, and the command to run somthing is !run NAMEHERE.

That way you can make it look for the second $ and then the second ! if it has already done each one, one time.

Does that make sence?

-Para

EDIT : Also, I woujld like the remote computer running the autoit file to ONLY have to have the autoit file on it and ONLY need the autoit, not any inis or txts. Simply the autoit file running in the background, and the command on the screen coming from my seperate computer.

Thanks!

Edited by para

Share this post


Link to post
Share on other sites

Well, for that to confuse you then the real thing your trying to do will blow your mind and i doupt anyone will take their time to write it. I'll just say you need to have a script that write scripts that are extremely smart.


Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

I thought you could just have it search the screen for strings, then pcik the second one, with +1 then it would continue...

3rd

4th...

and after running ur script i understood everything in it, and thats not what i was looking for but thanks very much for the help.


Share this post


Link to post
Share on other sites

ALOT harder then it seems dude :idiot:

Mine should work fine if it picks up the text correctly.


Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

I don't know if I see it as hard....

Use a WinExists($win-name, $text)

Or a filereadline($file) function, that could work. Say...I've seen the command !run notepad, so I activate it, and write "NOTEPAD IS ACTIVE" to a file.... check the file to see if this line exists, if it does, don't re-run notepad. The file is stored in a TEMP directory and delted when the program is exited.

BTW, good luck with your diablo bot.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

How would I make it so that after it finds the first !activate, it goes to the loop, and then when it gets back to the waiting for !activate, it loops for the SECOND one from the top down. Then when it goes again, it looks for the 3rd, and 4th, and so on and so forth.

I am not running AIM, so I cannot test this in it, but it works in Notepad. If it is acceptable to clear the command from the window after the command has been executed, and the controlID of the window is known, the following should/may do what you have been looking for. It is derived from my post on your previous topic and your post today at the top of this thread.

If this method works, and you would like to optimize the code a bit, $var1 thru 4 can be eliminated, and the "If" statements converted to a "Select" statement. If you wish, I can send that version.

Opt ("WinTitleMatchMode", 3)
Global $var1, $var2, $var3, $var4

While 1
   Activate()
   Commands()
WEnd


Func Activate()
   SplashTextOn("Waiting on Notepad", "Waiting for the Notepad window to appear" & @LF & "and the text '!activate' to be entered into Notepad.", 400, 45)
   WinWait("Untitled - Notepad", "!activate")
   SplashOff()
EndFunc  ;==>Activate


Func Commands()
   While 1
      $var1 = WinExists("Untitled - Notepad", "!run notepad")
      $var2 = WinExists("Untitled - Notepad", "!run paint")
      $var3 = WinExists("Untitled - Notepad", "!run calc")
      $var4 = WinExists("Untitled - Notepad", "!run cmd")
      
      If $var1 = 1 Then
         Run("notepad.exe")
         ControlSetText("Untitled - Notepad", "", "Edit1", "");<<<<<<<< add this
         ExitLoop
      EndIf
      
      If $var2 = 1 Then
         Run("mspaint.exe")
         ControlSetText("Untitled - Notepad", "", "Edit1", "");<<<<<<<< add this
         ExitLoop
      EndIf
      
      If $var3 = 1 Then
         Run("calc.exe")
         ControlSetText("Untitled - Notepad", "", "Edit1", "");<<<<<<<< add this
         ExitLoop
      EndIf
      
      If $var4 = 1 Then
         Run("cmd.exe")
         ControlSetText("Untitled - Notepad", "", "Edit1", "");<<<<<<<< add this
         ExitLoop
      EndIf
      
      Sleep(10)
   WEnd
EndFunc  ;==>Commands

Phillip

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...