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?
Buchstaben
-
- [ gelöst ]
-
H43DSH0T -
19. März 2010 um 13:21 -
Geschlossen -
Erledigt
-
-
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
[/autoit] [autoit][/autoit] [autoit]
MsgBox(0, "", _RandomAlNum(1,1,0)) ; Klein- und Großbuchstaben
MsgBox(0, "", _RandomAlNum(1,1,1)) ; Klein- und Großbuchstaben & ZiffernFunc _RandomAlNum($iLower = 1, $iUpper = 1, $iDigit = 1)
[/autoit]
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]
Chr(Random(97, 122, 1))
[/autoit] -
edit: sry mein internet hat iwie so komisch gelagt
-
ich schließ mich dem zweiteren an
mach einfach
if $zahl = 1 then
$buchstabe = a
...
bis z -
also kurzgesagt du setzt für jede zahl durch eine if abfrage einen buchstaben
Womit wir dann bei Mindestens 26 Zeilen unnötigem Code wären
-
26 If-Abfragen??? Ein bisschen unprofessionel.
[autoit]
Fürn Anfang gehts so:$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"]
[/autoit]
MsgBox(0, "Test", $aChar[Random(0, 25, 1)]) -
[autoit]
#include <Misc.au3>
[/autoit][autoit][/autoit][autoit]$dll = DllOpen("user32.dll")
[/autoit][autoit][/autoit][autoit]HotKeySet("#c", "_Close1")
[/autoit][autoit][/autoit][autoit]
HotKeySet("#v", "TestFunc1")While 1
[/autoit][autoit][/autoit][autoit]
Sleep(100)
WEndRun ("notepad")
[/autoit][autoit][/autoit][autoit]Sleep(300)
[/autoit][autoit][/autoit][autoit]$n = 0
[/autoit][autoit][/autoit][autoit]
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")
EndIfIf $i = 23 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 24 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 25 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 20 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 26 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 19 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 18 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 17 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 16 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 15 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 14 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 13 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 12 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 11 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 10 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 9 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 8 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 7 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 6 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 5 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 4 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 3 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 2 Then
[/autoit][autoit][/autoit][autoit]
Send ("x")
EndIfIf $i = 1 Then
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]
Send ("x")
EndIfich 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
[/autoit]
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)und hier mit Gross-, Kleinbuchstaben und Zahlen:
[autoit]#include <Array.au3>
[/autoit][autoit][/autoit][autoit]Global $iSpalte, $iZeile, $iZahlOderBuchstabe
[/autoit]
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)mfg (Auto)Bert
-
ich hab´s mal so gemacht funktioniert aber irgendwie nicht
Diese 123 Zeilen Code kannst du auch ganz einfach so schreiben:
[autoit]
[/autoit][autoit][/autoit][autoit]
Run ("notepad")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)
[/autoit] [autoit][/autoit] [autoit]
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,"]|[","")
EndFuncFunc __Trans($sText,$sChar,$sNewChar)
[/autoit]
Return StringRegExpReplace($sText,"(?i)(?<!\[)"&$sChar&"(?!\])",$sNewChar)
EndFunc -
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')
[/autoit] [autoit][/autoit] [autoit]
$dll = DllOpen("user32.dll")While 1
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
_aendern(41,'[CLASS:Notepad]','b')
Sleep(100)
WEnd
DllClose($dll)Func _aendern($buchstabein,$programm,$buchstabeout)
[/autoit]
If _IsPressed($buchstabein, $dll) Then
WinActivate($programm)
WinWaitActive($programm)
SendKeepActive($programm)
Send('{BACKSPACE}')
Send($buchstabeout)
EndIf
EndFuncIst nur von der Geschwindigkeit her nen Problem, außer du bist mit 2 Fingern unterwegsSo ist es ein klein wenig schneller
Spoiler anzeigen
[autoit]#include <Misc.au3>
[/autoit] [autoit][/autoit] [autoit]ShellExecute('Notepad.exe')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
WinActivate('[CLASS:Notepad]')
WinWaitActive('[CLASS:Notepad]')
$dll = DllOpen("user32.dll")While 1
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
_aendern(41,'b')
Sleep(100)
WEnd
DllClose($dll)Func _aendern($buchstabein,$buchstabeout)
[/autoit]
If _IsPressed($buchstabein, $dll) Then
Send('{BACKSPACE}')
Send($buchstabeout)
EndIf
EndFunc -
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)
[/autoit] [autoit][/autoit] [autoit]
Opt("SendKeyDelay", 3)
Opt("SendKeyDownDelay", 3)For $i = 97 To 122
[/autoit] [autoit][/autoit] [autoit]
HotKeySet(Chr($i), "_hks")
NextWhile 1 * Sleep(1000)
[/autoit] [autoit][/autoit] [autoit]
WEndFunc _hks()
[/autoit]
$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 -
das er nur im TXT-EDITOR funktioniert ist doof wie stell ich das ein dass es auch in PPP WORD OPEN OFFICE etc. funktioniert
-
Schau dir mal die Hilfen zu
[autoit]Winactive winactivate
[/autoit]etc an
Generell funktioniert das überall -
ja lustig ich hab schon alles weggekürtzt "funktioniert" aber immer nur noch im txt-editor
[autoit]For $i = 97 To 122
[/autoit][autoit][/autoit][autoit]
HotKeySet(Chr($i), "_hks")
NextWhile 1 * Sleep(1000)
[/autoit][autoit][/autoit][autoit]
WEndFunc _hks()
[/autoit]
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")
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
-