Jump to content

UpsiDown


BlackPhoenix
 Share

Recommended Posts

I was bored and i visited a site which made you able to type upside down. (http://www.typeupsidedown.com/) I looked at its sourcecode and made my own variant of it which is also able to revert text that is put upside down to normal text.

Here is the code:

;UpsidOwn 2009 made by BlackPhoenix
;Supports only lowercase for now
;================================
#include <String.au3>
#include <Array.au3>

If @Compiled = 1 Then
    Opt("TrayIconHide", 1)
Endif
;No trayicon
global $input, $output, $Reversed,$outputtext
$input='test'
;$type = 1 ;Code
;$type = 2 ;Decode

Func Main()
    Guicreate('UpsidOwn 2009',300,300,-1,-1)
    $inputtext=Guictrlcreateedit('Type text to put upside down',20,20,200,100)
    $outputtext=GUICtrlCreateEdit('Output',20,150,200,100)
    $convertbut=GUICtrlCreateButton('Convert',225,20,70,25)
    $convertbut2=GUICtrlCreateButton('Revert',225,50,70,25)
    GUISetState()

While 1
        $msg=guigetmsg()
        If $msg=$convertbut then Flipchar(guictrlread($inputtext),1)
        If $msg=$convertbut2 then Flipchar(guictrlread($inputtext),2)
        If $msg = -3 then Exit
    Wend

Endfunc


Main()

func FlipChar($input, $type)
Dim $table[50][2]
$table[0][0]='a'
$table[0][1]=Chrw(592)
$table[1][0]='b'
$table[1][1]='1'
$table[2][0]='c'
$table[2][1]=Chrw(596)
$table[3][0]='d'
$table[3][1]='3'
$table[4][0]='e'
$table[4][1]=Chrw(477)
$table[5][0]='f'
$table[5][1]=Chrw(607)
$table[6][0]='g'
$table[6][1]=Chrw(386)
$table[7][0]='h'
$table[7][1]=Chrw(613)
$table[8][0]='i'
$table[8][1]=Chrw(305)
$table[9][0]='j'
$table[9][1]=ChrW(638)
$table[10][0]='k'
$table[10][1]=Chrw(670)
$table[11][0]='l'
$table[11][1]='l'
$table[12][0]='m'
$table[12][1]=Chrw(623)
$table[13][0]='n'
$table[13][1]='5'
$table[14][0]='o'
$table[14][1]='o'
$table[15][0]='p'
$table[15][1]='2'
$table[16][0]='q'
$table[16][1]='4'
$table[17][0]='r'
$table[17][1]=Chrw(633)
$table[18][0]='s'
$table[18][1]='s'
$table[19][0]='t'
$table[19][1]=ChrW(647)
$table[20][0]='u'
$table[20][1]='6'
$table[21][0]='v'
$table[21][1]=Chrw(652)
$table[22][0]='w'
$table[22][1]=Chrw(653)
$table[23][0]='x'
$table[23][1]='x'
$table[24][0]='y'
$table[24][1]=Chrw(654)
$table[25][0]='z'
$table[25][1]='z'
;b -> 1 -> q
;q -> 2 -> b
;p -> 3 -> d
;d -> 4 -> p
;This can be changed if digits are used.
$table[26][0]='1'
$table[26][1]='q'
$table[27][0]='2'
$table[27][1]='d'
$table[28][0]='3'
$table[28][1]='p'
$table[29][0]='4'
$table[29][1]='b'
$table[30][0]='5'
$table[30][1]='u'
$table[31][0]='6'
$table[31][1]='n'


If $type=1 then
$Reversed=_Stringreverse($input)
;Msgbox(0,'Test',$Reversed)

    For $x=0 to 31

        $Newsplitted=Stringreplace($Reversed,$table[$x][0],$table[$x][1])
        $Reversed=$Newsplitted
    Next
    ClipPut($Reversed)
    Guictrlsetdata($outputtext,$Reversed)
Endif

If $type=2 then
$Reversed=_Stringreverse($input)
    For $x=26 to 31

        $Newsplitted=Stringreplace($Reversed,$table[$x][1],$table[$x][0])
        $Reversed=$Newsplitted
    Next
;Else stuff gets messed up if you put up the full range at once
    For $x=0 to 26

        $Newsplitted=Stringreplace($Reversed,$table[$x][1],$table[$x][0])
        $Reversed=$Newsplitted
    Next
    ClipPut($Reversed)
    Guictrlsetdata($outputtext,$Reversed)
Endif

;msgbox(0,'Test',$Reversed)

Return $output
EndFunc

Have fun with it ;)

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