Modify ↓
#56 closed Feature Request (Rejected)
Some features for discussion
| Reported by: | Xenobiologist | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | ||
| Keywords: | Cc: |
Description
Hi,
GaryFrost openend a thread how to submit udfs. I searched through my snippets and found some pieces of code which I'd like to discuss whether they can become a macro/udf ... before submitting them btw. somebody creates a nice piece of code for achieving the goal.
Before flaming me, YES I know they are not perfect. The code is just as examples!
- Macro for type of OS like (XP home or Professional)
- _getDNS()
- Macro for loggedInUser
- StringInsertLF
1.
Global $objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Global $colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For $objOperatingSystem in $colSettings
$Type = StringMid($objOperatingSystem.Caption, 19)
MsgBox(64, 'Ouput of Windows Type', "Type : "& $Type)
Next
MsgBox(0,"",_getDNS())
Func _getDNS()
Local $dns_A = StringRegExp(StdoutRead(Run(@ComSpec & " /c nslookup", "", @SW_HIDE, 2)), '(?s)(?i)server: .*?\.(.*?)(?m:$|\r)', 1)
If IsArray($dns_A) Then Return $dns_A[0]
Return SetError(1)
EndFunc
- (may fail on other machines than XP PRO SP2?)
Global $loggegInUser = RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AltDefaultUserName") Msgbox(64, "Value", $loggegInUser)
-
;~ Beispieltext von http://de.wikipedia.org/wiki/AutoIt $String = "Die Skripte ermöglichen z. B. das Ausführen von Programmen, das Simulieren von Tastaturanschlägen bzw. Mausklicks. Es können einfache Textfunktionen der Zwischenablage oder auch Windowsfunktionen (wie z. B. minimieren, verstecken, Warten auf/Aktivieren von Fenstern) aufgerufen werden. Seit Version 3 können zudem graphische Benutzeroberflächen mit zahlreichen Controls entworfen werden. Soll es um Registrymanipulationen oder komplexere Schleifen gehen, ist AutoIt 3 inzwischen mit seiner verbesserten Syntax deutlich einfacher zu handhaben als frühere Versionen. Es ist möglich, AutoIt mit anderen Scriptsprachen wie WSH oder Kixtart zu kombinieren (AutoItX)." MsgBox(0, "", $String) ; Original-Text MsgBox(0, "", _StringInsertLF($String, 50)) ; Softbreak after 50 MsgBox(0, "", _StringInsertLF($String, 50, 1)) ; Hardbreak after 50 Func _StringInsertLF($strString, $nCount, $cBreaking = 0) Local $strRetString = "", $nPos Do If StringLen($strString) > $nCount Then $nPos = StringInStr(StringLeft($strString, $nCount + 1), " ", 0, -1) If ($nPos And $cBreaking = 0) Then $strRetString &= StringLeft($strString, $nPos - 1) & @LF $strString = StringMid($strString, $nPos + 1) Else $strRetString &= StringLeft($strString, $nCount) & @LF $strString = StringMid($strString, $nCount + 1) EndIf EndIf Until StringLen($strString) < $nCount $strRetString &= $strString Return $strRetString EndFunc ;==>_StringInsertLF
Mega
Attachments (0)
Note:
See TracTickets
for help on using tickets.

Examples forum is where you should put these to get feedback from the user community.
Tickets should not be made up for discussing things.