Sign in to follow this  
Followers 0
Notepad

filewrite being stupid!

4 posts in this topic

so im wanting t make a macro creator script but not like mouse record one a little different i can't really explain the problem better than this..

(19) : ==> Missing separator character after keyword.:

FileWriteLine($file, "MouseClick("left"," & $3 & ", $1, 1, 0)")

FileWriteLine($file, "MouseClick("left^ ERROR

heres the script

#Include <Timers.au3>

HotKeySet("{lctrl}", "_lclick")

HotKeySet("{lshift}", "_mousemove")

HotKeySet("{lalt}", "_rclick")

$thing = 1

While

If $thing = 1 Then

_Timer_Init()

Else

WEnd

Func _lclick()

_Timer_Diff($iTimeStamp)

$file = FileOpen("bot.au3", 1)

$thing = 0

$1 = MouseGetPos()

FileWriteLine($file, "Sleep(" & $iTimeStamp & ")"

FileWriteLine($file, "MouseClick("left"," & $3 & ", $1, 1, 0)")

$thing = 1

FileClose($file)

EndFunc

Func _rclick()

_Timer_Diff($iTimeStamp)

$file = FileOpen("bot.au3", 1)

$thing = 0

$2 = MouseGetPos()

FileWriteLine($file, "Sleep(" & $iTimeStamp & ")"

FileWriteLine($file, "MouseClick("right"," & $3 & ", $2, 1, 0)")

$thing = 1

FileClose($file)

EndFunc

Func _mousemove()

_Timer_Diff($iTimeStamp)

$file = FileOpen("bot.au3", 1)

$thing = 0

$3 = MouseGetPos()

FileWriteLine($file, "Sleep(" & $iTimeStamp & ")"

FileWriteLine($file, "MouseMove(" & $3 & ", 0)")

$thing = 1

FileClose($file)

EndFunc

please help me! all i need is an au3 wizard :scorcerer:


Hi.

Share this post


Link to post
Share on other sites



Notepad,

I think you need to read the Help file a bit more carefully! ;)

1. You cannot use the Alt, Ctrl, Shift, Win keys as HotKeys - as the Help file says: These are the modifier keys themselves! I have set the HotKeys to q, a, z at the moment - over to you to set them to any other valid keys you want.

2. MouseGetPos returns an array, so you need to use the different elements to get your coordinates into the FileWrite lines.

A couple of other points:

The built-in timer functions are good enough here - there is no need to use the Timers UDF.

It is also a good idea to open the file just once rather than every time you want to write - but then you need an exit function to close it.

I have modified the script quite a bit, as you can see: :evil:

;#include <Timers.au3>
HotKeySet("q", "_lclick")
HotKeySet("a", "_mousemove")
HotKeySet("z", "_rclick")
HotKeySet("{ESC}", "On_Exit")
;$thing = 1

Global $file = FileOpen("bot.au3", 1)
Global $iBegin = TimerInit()

While 1

    Sleep(10)

    ;If $thing = 1 Then
    ;   _Timer_Init()
    ;EndIf ; Else
WEnd

Func _lclick()
    $iTimeStamp = Int(TimerDiff($iBegin))
    ;_Timer_Diff($iTimeStamp)
    ;$file = FileOpen("bot.au3", 1)
    ;$thing = 0
    $1 = MouseGetPos()
    FileWriteLine($file, "Sleep(" & $iTimeStamp & ")")
    FileWriteLine($file, 'MouseClick(" left",' & $1[0] & ", " & $1[1] & ", 1, 0)")
    $iBegin = TimerInit()
    ;$thing = 1
    ;FileClose($file)
EndFunc   ;==>_lclick

Func _rclick()
    $iTimeStamp = Int(TimerDiff($iBegin))
    ;_Timer_Diff($iTimeStamp)
    ;$file = FileOpen("bot.au3", 1)
    ;$thing = 0
    $2 = MouseGetPos()
    FileWriteLine($file, "Sleep(" & $iTimeStamp & ")")
    FileWriteLine($file, 'MouseClick(" right",' & $2[0] & ", " & $2[1] & ", 1, 0)")
    $iBegin = TimerInit()
    ;$thing = 1
    ;FileClose($file)
EndFunc   ;==>_rclick

Func _mousemove()
    $iTimeStamp = Int(TimerDiff($iBegin))
    ;_Timer_Diff($iTimeStamp)
    ;$file = FileOpen("bot.au3", 1)
    ;$thing = 0
    $3 = MouseGetPos()
    FileWriteLine($file, "Sleep(" & $iTimeStamp & ")")
    FileWriteLine($file, "MouseMove(" & $3[0] & ", " & $3[1] & ")")
    $iBegin = TimerInit()
    ;$thing = 1

EndFunc   ;==>_mousemove

Func On_Exit()
    FileClose($file)
    Exit
EndFunc   ;==>On_Exit

But I hope this now works as you intended - please ask if anything is unclear. :evil:

M23

P.S. By the way, when you post code it is much easier to read if you use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here).


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

Sorry to say it's not FileWriteLine() being stupid...

Your missing an end bracket on the FileWriteLine($file, "Sleep(" & $iTimeStamp & ")"

There are many things your script is just plain written wrongly.

Can list them if you like..

I'd suggest you start at the very beginning of your script and use the help file on each line of your script and step through the problems.

Start with HotKeySet("{lctrl}", "_lclick")...

Reading the help file tells me

The following hotkeys cannot be set:

Alt, Ctrl, Shift, Win These are the modifier keys themselves!

Moving on to your While loop, While what?

While <expression>

expression If the expression is true the following statements up to the WEnd statement are executed. This loop continues until the expression is false.

Moving on into your While loop..

If $thing = 1 Then

_Timer_Init()

Else

..........

I could step through your code and correct every problem, but I feel that if you read the help file and took the time to try an debug your code issues then you'd feel better about it yourself.

Not to mention you'd probably pick up a thing or two along the way.

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

Thanks for the help! I haven't been using autoit for about a year i just got started up again so thanks again! ;)


Hi.

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  
Followers 0