Drew Posted April 27, 2008 Share Posted April 27, 2008 I've managed to do this before in one of my programs , but I haven't done auto-it in a while. This is pretty basic. This is what I want to do: It will send this first: Game-1 Next time the function is called , I need it to send: Game-2 I think it's something like Send( "Game-" &$1) $1 = $1 + 1 Or something simliar , but I keep getting errors. =/. Link to comment Share on other sites More sharing options...
martin Posted April 27, 2008 Share Posted April 27, 2008 I've managed to do this before in one of my programs , but I haven't done auto-it in a while. This is pretty basic.This is what I want to do:It will send this first:Game-1Next time the function is called , I need it to send: Game-2I think it's something likeSend( "Game-" &$1)$1 = $1 + 1Or something simliar , but I keep getting errors. =/.Nothing wrong that I can see providing you have set $i before the first send. What error do you get? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Drew Posted April 27, 2008 Author Share Posted April 27, 2008 The Error: C:\Documents and Settings\Dreu\Desktop\My Programs\AutoIt\Game_Creator.au3 (16) : ==> Variable used without being declared.: $1 = $1 + 1 $1 = ^ ERROR >Exit code: 1 Time: 2.235 The Script: ; Press Esc to terminate script, Pause/Break to "pause" HotKeySet("{ESC}", "Terminate") HotKeySet("`", "Box") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;;;; Body of program would go here;;;; While 1 WEnd ;;;;;;;; Func Box() Run( "Notepad.Exe") WinWaitActive( "Untitled - Notepad") $1 = $1 + 1 Send( "Game-" &$1) EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() $input = InputBox( "Game Name", "Please type in the desired game name.", "Game Name") MsgBox( 0, "None", "You entered: " &$input) EndFunc Link to comment Share on other sites More sharing options...
Drew Posted April 27, 2008 Author Share Posted April 27, 2008 I've tried multiple variations of this , all with the same end result. Link to comment Share on other sites More sharing options...
NELyon Posted April 27, 2008 Share Posted April 27, 2008 Declare it at the top of your script. Global $1 (If I remember correctly, isn't using numbers as variable names somewhat problematic?) Link to comment Share on other sites More sharing options...
martin Posted April 27, 2008 Share Posted April 27, 2008 The Error: C:\Documents and Settings\Dreu\Desktop\My Programs\AutoIt\Game_Creator.au3 (16) : ==> Variable used without being declared.: $1 = $1 + 1 $1 = ^ ERROR >Exit code: 1 Time: 2.235 The Script: ; Press Esc to terminate script, Pause/Break to "pause" HotKeySet("{ESC}", "Terminate") HotKeySet("`", "Box") HotKeySet("+!d", "ShowMessage");Shift-Alt-d ;;;; Body of program would go here;;;; While 1 WEnd ;;;;;;;; Func Box() Run( "Notepad.Exe") WinWaitActive( "Untitled - Notepad") $1 = $1 + 1 Send( "Game-" &$1) EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() $input = InputBox( "Game Name", "Please type in the desired game name.", "Game Name") MsgBox( 0, "None", "You entered: " &$input) EndFunc In the line $i = $I + 1 the compiler has to give a value to $I of $I + 1. But nothing has been said about $I before so it can't possibly work out $I + 1. You have to at least give $I a starting value somewhere before you use it. So have a line near the start of your script $I = 1 Or Global $I = 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Drew Posted April 27, 2008 Author Share Posted April 27, 2008 Alright So I Declared It At The Top Of My Script, And I Changed All The Variables To "x" Instead Of 1. Still the same problem. When I don't get Error , It just sends Game-1 over and over... Never moves on to Game-2 ; Press Esc to terminate script, Pause/Break to "pause" HotKeySet("{ESC}", "Terminate") HotKeySet("`", "Box") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d Global $x ;;;; Body of program would go here;;;; While 1 WEnd ;;;;;;;; Func Box() $x = 1 WinWaitActive( "Untitled - Notepad") Send( "Game-" &$x) $x = $x + 1 Send( "{ENTER}") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() $input = InputBox( "Game Name", "Please type in the desired game name.", "Game Name") MsgBox( 0, "None", "You entered: " &$input) EndFunc Link to comment Share on other sites More sharing options...
Muchuchu Posted April 27, 2008 Share Posted April 27, 2008 Didn't test it but it should work ; Press Esc to terminate script, Pause/Break to "pause" HotKeySet("{ESC}", "Terminate") HotKeySet("`", "Box") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d Global $x = 0 ;;;; Body of program would go here;;;; While 1 WEnd ;;;;;;;; Func Box() do WinWaitActive( "Untitled - Notepad") Send( "Game-" &$x) $x = $x + 1 Send( "{ENTER}") until $x = 1 EndFunc Func Terminate() Exit EndFunc Func ShowMessage() do $input = InputBox( "Game Name", "Please type in the desired game name.", "Game Name") MsgBox( 0, "None", "You entered: " & $input) $x = $x + 1 until $x = 1 EndFunc Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 27, 2008 Share Posted April 27, 2008 Alright So I Declared It At The Top Of My Script, And I Changed All The Variables To "x" Instead Of 1. Still the same problem.When I don't get Error , It just sends Game-1 over and over... Never moves on to Game-2You are re-setting $x = 1 every time you call Box(). That keeps the Global variable $x from being updated to a new value each time. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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