Buchstaben

  • Giebt es eine Möglichkeit von a-z zufällig einen Buchstaben auszuwählen, bzw ich bin mir sicher das es einen giebt aber eie heißt der?

    Einmal editiert, zuletzt von H43DSH0T (20. März 2010 um 17:45)

  • nimm doch Random(1, 26, 1) und dann auf ein Array wo du die Buchstaben aufgelistet hast.

  • Oder so:

    Spoiler anzeigen
    [autoit]

    MsgBox(0, "", _RandomAlNum(1,0,0)) ; nur kleinbuchstaben
    MsgBox(0, "", _RandomAlNum(1,1,0)) ; Klein- und Großbuchstaben
    MsgBox(0, "", _RandomAlNum(1,1,1)) ; Klein- und Großbuchstaben & Ziffern

    [/autoit] [autoit][/autoit] [autoit]

    Func _RandomAlNum($iLower = 1, $iUpper = 1, $iDigit = 1)
    Local $sPat = "[", $sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
    If $iLower Then $sPat &= "a-z"
    If $iUpper Then $sPat &= "A-Z"
    If $iDigit Then $sPat &= "0-9"
    $sPat &= "]"
    If $sPat = "[]" Then Return ""
    $aTmp = StringRegExp($sAlpha, $sPat, 3)
    Return $aTmp[Random(0, UBound($aTmp) - 1, 1)]
    EndFunc ;==>_RandomAlNum

    [/autoit]
  • ich schließ mich dem zweiteren an
    mach einfach
    if $zahl = 1 then
    $buchstabe = a
    ...
    bis z
    :)

    [autoit]


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D

  • 26 If-Abfragen??? Ein bisschen unprofessionel.
    Fürn Anfang gehts so:

    [autoit]

    $aChar[26] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
    MsgBox(0, "Test", $aChar[Random(0, 25, 1)])

    [/autoit]
  • [autoit]

    #include <Misc.au3>

    [/autoit][autoit][/autoit][autoit]

    $dll = DllOpen("user32.dll")

    [/autoit][autoit][/autoit][autoit]

    HotKeySet("#c", "_Close1")
    HotKeySet("#v", "TestFunc1")

    [/autoit][autoit][/autoit][autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Run ("notepad")

    [/autoit][autoit][/autoit][autoit]

    Sleep(300)

    [/autoit][autoit][/autoit][autoit]

    $n = 0
    For $i = Random(1, 26, 1) To Random(1, 26, 1)
    Next
    Exit

    If $i = 22 Then
    Send ("x")
    EndIf

    If $i = 21 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 23 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 24 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 25 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 20 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 26 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 19 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 18 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 17 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 16 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 15 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 14 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 13 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 12 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 11 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 10 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 9 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 8 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 7 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 6 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 5 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 4 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 3 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 2 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $i = 1 Then
    Send ("x")
    EndIf

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]


    ich hab´s mal so gemacht funktioniert aber irgendwie nicht

  • Hallo @retrokid,

    am einfachsten ist die Lösung über

    [autoit]

    MsgBox(0,"",chr(Random(65,90,1)))

    [/autoit]

    wie von xp_fan schon gepostet. Hier einmal ein Skript für zufällige Buchstabentafel 12x12:

    [autoit]

    #include <Array.au3>

    [/autoit][autoit][/autoit][autoit]

    Global $iSpalte, $iZeile
    Global $aSpalte[12], $aZeile[12]
    Global $aSuchArray[12][12] ;12 Zeilen und 12 Spalten
    For $iZeile = 0 To 11
    For $iSpalte = 0 To 11
    $aSuchArray[$iZeile][$iSpalte] = Chr(Random(65, 90, 1)) ;mit Zufallsbuchstaben belegen
    Next
    Next
    _ArrayDisplay($aSuchArray)

    [/autoit]

    und hier mit Gross-, Kleinbuchstaben und Zahlen:

    [autoit]

    #include <Array.au3>

    [/autoit][autoit][/autoit][autoit]

    Global $iSpalte, $iZeile, $iZahlOderBuchstabe
    Global $aSuchArray[12][12] ;13 Zeilen ([0] = Beschriftung)und 13 Spalten ([0] = Beschriftung
    For $iZeile = 0 To 11
    For $iSpalte = 0 To 11
    $iZahlOderBuchstabe = Random(0, 1, 1)
    If $iZahlOderBuchstabe Then
    $aSuchArray[$iZeile][$iSpalte] = Random(1, 99, 1) ;mit Zufallszahlen belegen
    Else
    $iGross = Random(0, 1, 1)
    If $iGross Then
    $aSuchArray[$iZeile][$iSpalte] = Chr(Random(65, 90, 1)) ;mit Zufallsbuchstaben belegen
    Else
    $aSuchArray[$iZeile][$iSpalte] = Chr(Random(97, 122, 1)) ;mit Zufallsbuchstaben belegen
    EndIf
    EndIf
    Next
    Next
    _ArrayDisplay($aSuchArray)

    [/autoit]

    mfg (Auto)Bert

    Einmal editiert, zuletzt von AutoBert (19. März 2010 um 14:00)

  • ich hab´s mal so gemacht funktioniert aber irgendwie nicht

    Diese 123 Zeilen Code kannst du auch ganz einfach so schreiben:

    [autoit]


    Run ("notepad")

    [/autoit][autoit][/autoit][autoit]

    WinWaitActive("Unbenannt - Editor")

    [/autoit][autoit][/autoit][autoit]

    Send(Chr(Random(65,90,1)))

    [/autoit]

    autoBert:
    Ich glaube nicht, dass ein 2D Array gepaart mit ein paar For-Next schleifen sonderlich dazu beiträgt, dass HeadShot es versteht - ich befürchte eher das Gegenteil.

  • Ich wollte nämlich eine art Geheimsprache machen.
    Man giebt z.B. Affe ein und raus kommt klaaq.
    Der andere hat dan das gegenprogramm und fertig...

  • sowas um den dreh?

    Spoiler anzeigen
    [autoit]

    MsgBox(0,"",_Translate("Test",0))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Translate($sText,$sMode)
    Switch $sMode
    Case 0
    $sText = __Trans($sText,"A","Z")
    $sText = __Trans($sText,"B","Y")
    $sText = __Trans($sText,"C","X")
    $sText = __Trans($sText,"D","W")
    $sText = __Trans($sText,"E","V")
    $sText = __Trans($sText,"F","U")
    $sText = __Trans($sText,"G","T")
    $sText = __Trans($sText,"H","S")
    $sText = __Trans($sText,"I","R")
    $sText = __Trans($sText,"J","Q")
    $sText = __Trans($sText,"K","P")
    $sText = __Trans($sText,"L","O")
    $sText = __Trans($sText,"M","N")
    $sText = __Trans($sText,"N","M")
    $sText = __Trans($sText,"O","L")
    $sText = __Trans($sText,"P","K")
    $sText = __Trans($sText,"Q","J")
    $sText = __Trans($sText,"R","I")
    $sText = __Trans($sText,"S","H")
    $sText = __Trans($sText,"T","G")
    $sText = __Trans($sText,"U","F")
    $sText = __Trans($sText,"V","E")
    $sText = __Trans($sText,"W","D")
    $sText = __Trans($sText,"X","C")
    $sText = __Trans($sText,"Y","B")
    $sText = __Trans($sText,"Z","A")
    Case 1
    ;..... war zu faul für das hier
    EndSwitch
    Return StringRegExpReplace($sText,"]|[","")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func __Trans($sText,$sChar,$sNewChar)
    Return StringRegExpReplace($sText,"(?i)(?<!\[)"&$sChar&"(?!\])",$sNewChar)
    EndFunc

    [/autoit]
  • Ne ich dachte das anders...
    du schreibst etwas z.B. in den txt-Editor und das wird dan diekt "verschlüsselt" also du drückst a und geschrieben wird aber b

  • In etwa so?

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ShellExecute('Notepad.exe')
    $dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    _aendern(41,'[CLASS:Notepad]','b')
    Sleep(100)
    WEnd
    DllClose($dll)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _aendern($buchstabein,$programm,$buchstabeout)
    If _IsPressed($buchstabein, $dll) Then
    WinActivate($programm)
    WinWaitActive($programm)
    SendKeepActive($programm)
    Send('{BACKSPACE}')
    Send($buchstabeout)
    EndIf
    EndFunc

    [/autoit]


    Ist nur von der Geschwindigkeit her nen Problem, außer du bist mit 2 Fingern unterwegs ^^


    So ist es ein klein wenig schneller :)

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ShellExecute('Notepad.exe')
    WinActivate('[CLASS:Notepad]')
    WinWaitActive('[CLASS:Notepad]')
    $dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    _aendern(41,'b')
    Sleep(100)
    WEnd
    DllClose($dll)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _aendern($buchstabein,$buchstabeout)
    If _IsPressed($buchstabein, $dll) Then
    Send('{BACKSPACE}')
    Send($buchstabeout)
    EndIf
    EndFunc

    [/autoit]

    21 is only half the truth.

    Einmal editiert, zuletzt von Mahagon (19. März 2010 um 20:37)

  • Du musst auch sagen was du willst -.-

    so?
    Verschlüsselt nur im Notepad, also erst notepad öffnen und dann schreiben.
    Der geschriebene Buchstabe wird um 7 stellen im Alphabet verschoben.

    (und auch nur kleinbuchstaben... die andere For-Next schleife für Hotkeyset kannste selber einbauen. Als kleine Aufgabe ;))

    Spoiler anzeigen
    [autoit]

    Opt("WinTitleMatchmode", 4)
    Opt("SendKeyDelay", 3)
    Opt("SendKeyDownDelay", 3)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 97 To 122
    HotKeySet(Chr($i), "_hks")
    Next

    [/autoit] [autoit][/autoit] [autoit]

    While 1 * Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _hks()
    $sHK = @HotKeyPressed
    If Not WinActive("[CLASS:Notepad]") Then
    Return HotKeySet($sHK) And Send($sHK) And HotKeySet($sHK, "_hks")
    Else
    Local $sType, $iAsc = Asc(StringRegExpReplace($sHK, "}|{", ""))
    If $iAsc >= 65 And $iAsc <= 90 Then $iA = 65
    If $iAsc >= 97 And $iAsc <= 122 Then $iA = 97
    $iNew = $iAsc + 7
    If $iNew > $iA + 26 Then $iNew -= 26
    $sSend = "{" & Chr($iNew) & "}"
    Return HotKeySet($sSend) And Send($sSend) And HotKeySet($sSend, "_hks")
    EndIf
    EndFunc ;==>_hks

    [/autoit]
  • das er nur im TXT-EDITOR funktioniert ist doof wie stell ich das ein dass es auch in PPP WORD OPEN OFFICE etc. funktioniert

  • ja lustig ich hab schon alles weggekürtzt "funktioniert" aber immer nur noch im txt-editor

    [autoit]

    For $i = 97 To 122
    HotKeySet(Chr($i), "_hks")
    Next

    [/autoit][autoit][/autoit][autoit]

    While 1 * Sleep(1000)
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Func _hks()

    Local $sType, $iAsc = Asc(StringRegExpReplace($sHK, "}|{", ""))
    If $iAsc >= 65 And $iAsc <= 90 Then $iA = 65
    If $iAsc >= 97 And $iAsc <= 122 Then $iA = 97
    $iNew = $iAsc + 8
    If $iNew > $iA + 26 Then $iNew -= 26
    $sSend = "{" & Chr($iNew) & "}"
    Return HotKeySet($sSend) And Send($sSend) And HotKeySet($sSend, "_hks")

    [/autoit]


    EndFunc

  • Hallo

    das er nur im TXT-EDITOR funktioniert ist doof wie stell ich das ein dass es auch in PPP WORD OPEN OFFICE etc. funktioniert

    hört sich so an, als wenn du einen Spass-Virus zum Erschrecken von Lehrer etc. basteln möchtest, also Forenregeln lesen und vorallem beachten,

    mfg (Auto)Bert