Jump to content

2 Days Of Exprience Project


Recommended Posts

simple little thing with a buggy get title thingy.

BTW!!!! important!!! the mouse must be over the window to add a wait to...

BTW MORE IMPORTANT!!! I dont know what will happen to existing notepap windows so just to be safe, close ande save those.

I have only had two days of experience so it is rather simple for now. remember to type help for help.

WinMinimizeAll()

run("notepad","",@SW_MAXIMIZE)

winwait("Untitled - Notepad")

WinSetTitle ("","","Program" )

run("notepad","",@SW_MAXIMIZE)

winwait("Untitled - Notepad")

WinSetTitle ("","","Info Dump" )

$comloop = 1

;lets make a variable called comloop and set it equal to 1

While $comloop = 1

$self=AutoItWinGetTitle()

Winactivate($self,"")

$Cmd = InputBox("Click Easy", "Command","","",500,60,0,0)

If @error = 1 Then

WinKill("Info Dump","")

exit

else

WinActivate ("Click Easy", "")

$cmds = StringSplit($cmd, " ")

If $cmds[1]= "sleep" Then

WinActivate ("Program")

send("sleep(")

send($cmds[2])

send(")")

send("{enter}")

$cmds[1] = 0

elseIf $cmds[1] = "titlewait" then

mouseclick("left")

$title = WinGetTitle("")

$text = WinGetText("")

WinActivate ("Program")

send ("WinWait({SHIFTDOWN}'{SHIFTUP}")

send($title)

send("{SHIFTDOWN}'{SHIFTUP},{SHIFTDOWN}'{SHIFTUP}")

send($text)

send("{SHIFTDOWN}'{SHIFTUP})")

send("{enter}")

$cmds[1] = 0

$title = 0

$text = 0

ElseIf $cmds[1] = "click" Then

$pos = MouseGetPos()

WinActivate ("Program")

send("MouseClick(")

Send("{SHIFTDOWN}'{SHIFTUP}")

send("left")

Send("{SHIFTDOWN}'{SHIFTUP}")

send(", ")

send($pos[0])

send(", ")

send($pos[1])

send(")")

send("{enter}")

$cmds[1] = 0

Elseif $cmds[1] = "help" Then

WinActivate ("Info Dump")

send("Available commands are:")

send("{enter}{enter}")

send("click{tab}{tab}(adds a click to the code at the current mouse coordinates, relative to the topleft part of the screen)")

send("{enter}")

send("sleep{tab}{tab}(puts a pause in the program for a secondary parameter number of milliseconds)")

send("{enter}")

send("titlewait{tab}(adds a wait command to the window currently under the mouse)")

send("{enter}")

send("--------------------------------------------------------------------")

send("{enter}")

WinActivate ("Program")

msgbox(0,"Information","Check your Info Dump")

EndIf

EndIf

WEnd

$comloop=0

Link to comment
Share on other sites

It's a nice idea. With this you can create AutoIt3 scripts interactively.

If you add some more commands I bet it will be useful for new users.

BTW, to make it work for me I changed your code a bit.

The first 8 lines I changed to this:

WinMinimizeAll()
run("notepad","",@SW_MAXIMIZE)
Sleep(2000)
Winactivate("Notepad")
WinSetTitle ("","","Program" )
run("notepad","",@SW_MAXIMIZE)
Sleep(2000)
Winactivate("Notepad")
Link to comment
Share on other sites

Version update!!! to all my tens of fans!

AutoItSetOption("WinTitleMatchMode", 4)
WinMinimizeAll()
run("notepad","",@SW_MAXIMIZE)
winwait("Untitled - Notepad")
WinSetTitle ("","","Program" )
winwait("Program")
send("AutoItSetOption({SHIFTDOWN}'{SHIFTUP}WinTitleMatchMode{SHIFTDOWN}'{SHIFTUP},4)")
send("{enter}")
send("AutoItSetOption({SHIFTDOWN}'{SHIFTUP}MouseCoordMode{SHIFTDOWN}'{SHIFTUP}, 1)")
run("notepad","",@SW_MAXIMIZE)
winwait("Untitled - Notepad")
WinSetTitle ("","","Info Dump" )
$comloop = 1
While $comloop = 1
     $Cmd = InputBox("Click Easy", "Command","","",500,60,0,0)
     If @error = 1 Then
          WinKill("Info Dump","")
          exit
     else
          WinActivate ("Click Easy", "")
          $cmds = StringSplit($cmd, " ")
          
          If $cmds[1] = "sleep" Then
               WinActivate ("Program")
               send("sleep(")
               send($cmds[2])
               send(")")
               send("{enter}")
               $cmds[1] = 0
               
          elseIf $cmds[1] = "titlewait" then
               mouseclick("left")
               $title = WinGetTitle ("")
               $handle = WinGetHandle ("")
               WinActivate ("Program")
               send ("WinWait({SHIFTDOWN}'{SHIFTUP}")
               send($title)
               send("{SHIFTDOWN}'{SHIFTUP},{SHIFTDOWN}'{SHIFTUP}")
               send($handle)
               send("{SHIFTDOWN}'{SHIFTUP})")
               send("{enter}")
               $cmds[1] = 0
               $title = 0
               $handle = 0

          ElseIf $cmds[1] = "click" Then
               $pos = MouseGetPos()
               WinActivate ("Program")
               send("MouseClick(")
               Send("{SHIFTDOWN}'{SHIFTUP}")
               send("left")
               Send("{SHIFTDOWN}'{SHIFTUP}")
               send(", ")
               send($pos[0])
               send(", ")
               send($pos[1])
               send(")")
               send("{enter}")
               $cmds[1] = 0
               
          Elseif $cmds[1] = "help" Then
               WinActivate ("Info Dump")
               send("Available commands are:")
               send("{enter}{enter}")
               send("click{tab}{tab}(adds a click to the code at the current" & _
                    " mouse coordinates, relative to the topleft part of the screen)")
               send("{enter}")
               send("sleep{tab}{tab}(puts a pause in the program for a secondary" & _
                    " parameter number of milliseconds)")
               send("{enter}")
               send("titlewait{tab}(adds a wait command to the window currently" & _
                    " under the mouse)")
               send("{enter}")
               send("--------------------------------------------------------------------")
               send("{enter}")
               WinActivate ("Program")
               msgbox(0,"Information","Check your Info Dump")

          EndIf
     EndIf
WEnd
$comloop=0
Edited by Larry
Link to comment
Share on other sites

oooooh!

that is nice hold on i have the newer version here i go...

AutoItSetOption("WinTitleMatchMode", 4)

WinMinimizeAll()

run("notepad","",@SW_MAXIMIZE)

winwait("Untitled - Notepad")

WinSetTitle ("","","Program" )

winwait("Program")

send("AutoItSetOption({SHIFTDOWN}'{SHIFTUP}WinTitleMatchMode{SHIFTDOWN}'{SHIFTUP},4)")

send("{enter}")

send("AutoItSetOption({SHIFTDOWN}'{SHIFTUP}MouseCoordMode{SHIFTDOWN}'{SHIFTUP}, 1)")

send("{enter}")

run("notepad","",@SW_MAXIMIZE)

winwait("Untitled - Notepad")

WinSetTitle ("","","Info Dump" )

$comloop = 1

While $comloop = 1

$Cmd = InputBox("Click Easy", "Command","","",500,60,0,0)

If @error = 1 Then

WinKill("Info Dump","")

exit

else

WinActivate ("Click Easy", "")

$cmds = StringSplit($cmd, " ")

If $cmds[1]= "sleep" Then

WinActivate ("Program")

send("sleep(")

$sleeptime = InputBox("Amount of time to sleep", "please enter the amout of time to sleep (in milliseconds)","","",215,120,0,0)

WinActivate ("Program")

winwait("Program")

send($sleeptime)

send(")")

send("{enter}")

$cmds[1] = 0

elseIf $cmds[1] = "titlewait" then

msgbox(0,"Mouse Placement","Place the mouse over the window that will recieve the wait command, and then press enter")

mouseclick("left")

$title = WinGetTitle ("")

$handle = WinGetHandle ("")

WinActivate ("Program")

send ("WinWait({SHIFTDOWN}'{SHIFTUP}")

send($title)

send("{SHIFTDOWN}'{SHIFTUP},{SHIFTDOWN}'{SHIFTUP}")

send($handle)

send("{SHIFTDOWN}'{SHIFTUP})")

send("{enter}")

$cmds[1] = 0

$title = 0

$handle = 0

ElseIf $cmds[1] = "click" Then

msgbox(0,"Mouse Placement","Place the mouse where you want the click to be sent")

$pos = MouseGetPos()

WinActivate ("Program")

send("MouseClick(")

Send("{SHIFTDOWN}'{SHIFTUP}")

send("left")

Send("{SHIFTDOWN}'{SHIFTUP}")

send(", ")

send($pos[0])

send(", ")

send($pos[1])

send(")")

send("{enter}")

$cmds[1] = 0

Elseif $cmds[1] = "help" Then

WinActivate ("Info Dump")

send("Available commands are:")

send("{enter}{enter}")

send("click{tab}{tab}(adds a click to the code at the current mouse coordinates, relative to the topleft part of the screen)")

send("{enter}")

send("sleep{tab}{tab}(puts a pause in the program for a secondary parameter number of milliseconds)")

send("{enter}")

send("titlewait{tab}(adds a wait command to the window currently under the mouse)")

send("{enter}")

send("--------------------------------------------------------------------")

send("{enter}")

WinActivate ("Program")

msgbox(0,"Information","Check your Info Dump")

EndIf

EndIf

WEnd

$comloop=0

Link to comment
Share on other sites

If you are looking for suggestions:

-Copy and paste is usually more efficient than Send

ClipPut("stuff goes here" & @CRLF) ;text plus carriage return/new line

WinMenuSelectItem("InfoDump", "&Edit", "&Paste")

; If the notepad window has focus, then Send("^c") is another way to paste

-ControlSend--when it works--is even better (because WinMenuSelectItem must be different for different language versions of Microsoft Windows)

ControlSend ( "InfoDump", "", "Edit1", "stuff goes here", 1)

ControlSend ( "InfoDump", "", "Edit1", "{Enter}", 0)

Happy Scripting

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

thanks cyberslug! I will definitely do that right after i solve this...

could you guys help me with this?

try running the waitfor command

AutoItSetOption("MouseCoordMode", 1)

AutoItSetOption("WinTitleMatchMode", 4)

WinMinimizeAll()

run("notepad","",@SW_MAXIMIZE)

winwait("Untitled - Notepad")

WinSetTitle ("","","Program" )

winwait("Program")

send("AutoItSetOption({SHIFTDOWN}'{SHIFTUP}WinTitleMatchMode{SHIFTDOWN}'{SHIFTUP},4)")

send("{enter}")

send("AutoItSetOption({SHIFTDOWN}'{SHIFTUP}MouseCoordMode{SHIFTDOWN}'{SHIFTUP}, 1)")

send("{enter}")

run("notepad","",@SW_MAXIMIZE)

winwait("Untitled - Notepad")

WinSetTitle ("","","Info Dump" )

$comloop = 1

While $comloop = 1

$Cmd = InputBox("Click Easy", "Command","","",500,60,0,0)

If @error = 1 Then

WinKill("Info Dump","")

exit

else

WinActivate ("Click Easy", "")

$cmds = StringSplit($cmd, " ")

If $cmds[1]= "sleep" Then

WinActivate ("Program")

send("sleep(")

$sleeptime = InputBox("Amount of time to sleep", "please enter the amout of time to sleep (in milliseconds)","","",215,120,0,0)

WinActivate ("Program")

winwait("Program")

send($sleeptime)

send(")")

send("{enter}")

$cmds[1] = 0

endif

elseIf $cmds[1] = "waitfor" then

msgbox(0,"Mouse Placement","Place the mouse over the window that will recieve the wait command, and then press enter")

if @error = 1 Then

mouseclick("left")

$title = WinGetTitle ("")

$handle = WinGetHandle ("")

WinActivate ("Program")

send ("WinWait({SHIFTDOWN}'{SHIFTUP}")

send($title)

send("{SHIFTDOWN}'{SHIFTUP},{SHIFTDOWN}'{SHIFTUP}")

send($handle)

send("{SHIFTDOWN}'{SHIFTUP})")

send("{enter}")

else

;$cmds[1] = 0

;$title = 0

;$handle = 0

ElseIf $cmds[1] = "click" Then

msgbox(0,"Mouse Placement","Place the mouse where you want the click to be sent")

$pos = MouseGetPos()

WinActivate ("Program")

send("MouseClick(")

Send("{SHIFTDOWN}'{SHIFTUP}")

send("left")

Send("{SHIFTDOWN}'{SHIFTUP}")

send(", ")

send($pos[0])

send(", ")

send($pos[1])

send(")")

send("{enter}")

$cmds[1] = 0

Elseif $cmds[1] = "help" Then

WinActivate ("Info Dump")

send("Available commands are:")

send("{enter}{enter}")

send("click{tab}{tab}(adds a click to the code at the current mouse coordinates, relative to the topleft part of the screen)")

send("{enter}")

send("sleep{tab}{tab}(puts a pause in the program for a secondary parameter number of milliseconds)")

send("{enter}")

send("waitfor{tab}(adds a wait command to the window currently under the mouse)")

send("{enter}")

send("--------------------------------------------------------------------")

send("{enter}")

WinActivate ("Program")

msgbox(0,"Information","Check your Info Dump")

EndIf

EndIf

WEnd

$comloop=0

Link to comment
Share on other sites

It's a good idea to tell us the problem we should look for :D

I'm guessing you get an AutoIt run-time error, right?

Try deleting the following

else
;$cmds[1] = 0
;$title = 0
;$handle = 0

You have an Else statement before an ElseIf statement, and this will not work. Or Maybe you have an EndIf block not terminated?

Misc Recommendations: Make sure to use a text editor with syntax highlighting. Break up the script into functions.

;....
Select
Case $cmds[1] = "waitfor"
    _waitfor()
Case $cmds[1] = "click'
    _click()
;....
EndSelect
Exit

Func _waitfor()
;block of code goes here
EndFunc

Func _click()
;block of code goes here
EndFunc

P.S. Because this forum strips tabs from code, replace any tabs with spaces to keep the code intended when posting.

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • 4 weeks later...
Guest SigiS

thanks cyberslug!  I will definitely do that right after i solve this...

could you guys help me with this?

try running the waitfor command

:D found the bug ...

there is an wrong 'endif'-statement ...

remove it before this line:

elseIf $cmds[1] = "waitfor" then

and add it before this line:

ElseIf $cmds[1] = "click" Then

thats it :huh2:

have fun!

Sigi

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