Jump to content
Sign in to follow this  
crashdemons

Quine Example

Recommended Posts

crashdemons

A Quine is a program that can output it's own source without having direct access or user intervention.

(This Means no reading of the script file, prompting for source input, packaging the source, or using inbuilt source references)

A Quine is not necessarily malicious or self-duplicating, but rather an attempt at a theory.

Definition of Quine

Why torture ourselves making this this way? The reason is to [re]prove a concept of computing: that it is possible for a turing-complete language to output it's own source-code. (or optionally, output a program in another language that outputs the original source code; aka. a multiquine )

Here, are some AutoIt3 Quines:

My Quines:

One-line quines from my reply on Page 2:

ConsoleWrite(StringReplace("ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))
MsgBox(0,'',StringReplace("MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))

Old 2-Line Quine:

$x="$x=%srnMsgBox(0,'Quine Example',StringFormat($x,Chr(34)&$x&Chr(34)))"
MsgBox(0,'Quine Example',StringFormat($x,Chr(34)&$x&Chr(34)))

Skeleton/Customizable Quine (Page 2)

Global $gsQuine
eq("MsgBox(0,'program','first exec line')")
eq("MsgBox(0,'program','second exec line')")
Func eq($s)
Execute($s)
$gsQuine&=BinaryToString(0x22287165)&$s&BinaryToString(0x0A0D2922)
EndFunc
$x="Global $gsQuinern%sFunc eq($s)rnExecute($s)rn$gsQuine&=BinaryToString(0x22287165)&$s&BinaryToString(0x0A0D2922)rnEndFuncrn$x=%srnMsgBox(0,'Quine Example',StringFormat($x,$gsQuine,Chr(34)&$x&Chr(34)))"
MsgBox(0,'Quine Example',StringFormat($x,$gsQuine,Chr(34)&$x&Chr(34)))

Any Questions? :)

Quines by Michel Claveau:

$x="MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)"
MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)

$g=chr(34)
$x="MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)"
MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)

Images of past quines:

Posted Image

Posted Image

- - -

And for my next magic trick :) - an AutoIt3 / PHP Polyglot (non-quine and all too simple)

A Polyglot is a script that can perform the same actions in multiple languages without manipulation of the code.

;=- <?php
;/*
ConsoleWrite(";=- Hello World -=;");
;*/
; echo "Hello World";
; ?> -=;

In either language, this outputs ";=- Hello World -=;" to the console.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites
monoceres

Sorry for bumping, but I just had to.

Just read the wikpedia page on Quine and thought to myself: Hey! Wonder if it have been done in autoit? And indeed it had!

Very nice work (and in only 2 lines):)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
NELyon

Is this correct?

Posted Image

Share this post


Link to post
Share on other sites
Merovingian

Is this correct?

Posted Image

Ugh huh you bet its correct *Grinz*

if in doubt read Quine Definition

Edited by Gargy

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.

Share this post


Link to post
Share on other sites
NELyon

I thought the point was to output the whole source. There it only goes up to "MsgBox(0, 'Quine"

Share this post


Link to post
Share on other sites
Merovingian

I thought the point was to output the whole source. There it only goes up to "MsgBox(0, 'Quine"

You might have a vaild point there lets wait for Crash

lulz

*edit to conform

Edited by Gargy

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.

Share this post


Link to post
Share on other sites
weaponx

First:

Stop centering the text in the posts, are newspapers and books center justified? No.

Second:

Just include the entire source code using FileInstall()

- or -

Using a preprocessor directive:

#AutoIt3Wrapper_res_SaveSource

See other options:

http://www.autoitscript.com/forum/index.ph...install++source

Edited by weaponx

Share this post


Link to post
Share on other sites
Tomb

You might have a vaild point there lets wait for Crash

lulz

your signature is soo big it makes the page have a sidewards scroollbar.

Share this post


Link to post
Share on other sites
monoceres

That depends on how big screen you have :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
crashdemons

Wow! don't think I've ever gotten this many replies.

Um yeah I think the $ before MsgBox was a typo when I was removing lines from it - I'll go fix it now.

Also, I'd be pleased if someone can make a different example

- although StringFormat is certainly easier than anything else I could think of.

wrapping the string in a function to try one-line makes it complicated, ugh because you have to repeat it 2+ etc.... *shrugs*

Let me know...

Shorter version of the "PHP/AutoIt" Polyglot (Editbox is broken on the first post)

;=- <?php /*
ConsoleWrite(";=- Hello World -=;");*/ echo "Hello World"; ?> -=;

PS:

I don't know exactly why it was only partially outputting for some - but just in case, try the newest edit that removed the extra '$' before MsgBox

-- also I noticed the icon on the dialog box where the problem is, I suppose it's possible there might be a compatibility issue with WINE? I don't know.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

This release, without the StringFormat:

$x="MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)"
MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)

Variante:

$g=chr(34)
$x="MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)"
MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)

_

Edited by Michel Claveau

Share this post


Link to post
Share on other sites
crashdemons

Cool! that works good :)


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites
weaponx

I am failing to see how this would be useful, you have to replicate every line of commands for running and outputting to the user. If you used something like this below you only have to define the code once:

$var = 'MsgBox(0,"","TEST")'

;Escape double quotes
$var = StringReplace($var, '"', '""')

;Format run command
$runCMD = StringFormat('"%s" /AutoIt3ExecuteLine "%s"', @AutoItExe, $var)

RunWait($runCMD)

Share this post


Link to post
Share on other sites
NELyon

Wait you want run autoit on linux with wine ?? i tried for years and fail

I've been running Autoit under wine for around 8 Months now :)

@Weaponx:

I don't believe there is supposed to be a point. I think it's more of a "See if I can" type of thing.

Share this post


Link to post
Share on other sites
Skrip

Sorry for bump, but can this output source as the line is called?

Like, script is on line 1, it shows only line 1, then it moves to 2, ect...


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
crashdemons

Sorry for bump, but can this output source as the line is called?

Like, script is on line 1, it shows only line 1, then it moves to 2, ect...

do you want line 2 to output line 2 and line 3 to output line 3 ?

that sounds very difficult

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites
crashdemons

here are two One-Line-Quines for Console and MsgBox

ConsoleWrite(StringReplace("ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))

MsgBox(0,'',StringReplace("MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

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  

  • Similar Content

    • DynamicRookie
      By DynamicRookie
      Hey There!
       
      So, what i need to do is an app that can read text in a image (I.e. a png that has text saying "This is a png" and return the text to a variable)
      I'm pretty much a newbie on AutoIt, my purpose is doing that but i don't know any function that can

      Any help is much appreciated
    • santoshM
      By santoshM
      How can i exit from a procedure in auto
      Func test() if x=o then     return endif endFunc  
    • Valnurat
      By Valnurat
      Hi
      Small question.
      I trying to find all index in an array with value higher than 7.
      How can that be possible?
    • TrashBoat
      By TrashBoat
      Could someone help me create or give an idea of how to do a incrementing for loop that would do this: https://i.imgur.com/YFUt47H.gifv
      I'm having a hard time figuring it out :S
    • msd1994
      By msd1994
      I have a script that just adds some keyboard shortcuts for things like displaying the current song and artist, moving the window to the side so it won't pop up in my way, and play/pause, next song, previous song (these are the only 3 to still work since they don't need the window handle.)
      In some update recently, Spotify's window class swapped from "[CLASS:SpotifyMainWindow]" to "[CLASS:Chrome_WidgetWin_0]". Using the new class in my controls doesn't seem to work, I've tried getting the window handle from the process handle (_GetHwndFromPID($PID)) but that seems to fail as well.
      Does anybody have some idea of a way I could get this script working again?
       
      edit: seems like discord has the same window class name, so could be some issue with this? Still not sure of a way to solve the issue though, I added a function to get the handle of the active window and can just use that now, but it was able to find it on its own before on spotify startup or script startup which would be preferred.
       
      Thanks!
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.