Jump to content

Recommended Posts

Posted

Howdy!

I am trying to do something a little whacky but here's the function that's kicking back an error.

I am fairly sure I am overlooking a simple error but I am not seeing it.

Func mouseSpot ()
   Global $mouseSpot = MouseGetPos()
   ConsoleWrite ($mouseSpot[0] & ", " & $mouseSpot[1] & @CRLF)
   FileWriteLine ("mouseGrabs.txt" , "MouseClick ('"'primary'"' , $mouseSpot[0] , $mouseSpot[1], 1, 10)" )
EndFunc

The error displays as this 

Quote

FileWriteLine ("mouseGrabs.txt" , "MouseClick ('"'primary'"' , $mouseSpot[0] , $mouseSpot[1], 1, 10)" )
FileWriteLine ("mouseGrabs.txt" , ^ ERROR

Any thoughts?

Thanks!

-Reiz

Posted

Had a moment of "Ah-ha!' and got rid of the quotes around "Primary" , it now writes to the file appropriately but I am still not sure why I am erroring when I have the quotes.

  • Developers
Posted

The doublequote between the single quotes will end the literal string started with the double quote before mouseclick.

so this line

"MouseClick ('"'primary'"' , $mouseSpot[0] , $mouseSpot[1], 1, 10)"

is really 3 strings connected together giving the error  
String1: "MouseClick ('"  
String2: 'primary'
String3: "' , $mouseSpot[0] , $mouseSpot[1], 1, 10)"

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Howdy,

Ahh I see! 

So this is more for future reference than immediate need

If I want to use FileWriteLine and the string I want to write has quotes in it, how do I go about having said quotes be printed? Some languages call for a \ before characters and what-not to designate them to just be written rather than interpreted. 

Thanks!

-Reiz

  • Developers
Posted

That is quite easy. You have 2 options when you want to convert this command to a string: 

MouseClick ("primary" , $mouseSpot[0] , $mouseSpot[1], 1, 10)

 Opt1

"MouseClick (""primary"" , $mouseSpot[0] , $mouseSpot[1], 1, 10)"

Opt2

'MouseClick ("primary" , $mouseSpot[0] , $mouseSpot[1], 1, 10)'

The helpfile explains more on how this all works.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
×
×
  • Create New...