Jump to content

Arilvv

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Arilvv's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. This is very useful, thank you for sharing.
  2. Sorry, my mistake. You can try it again now :">
  3. There are four functions: Asc2Unicode($AscString) Unicode2Asc($UnicodeString) Unicode2Utf8($UnicodeString) Utf82Unicode($Utf8String) Note: $AscString and $Utf8String are normal strings, and $UnicodeString should be a binarystring Tested under Chinese Tradition (Taiwan) environment and worked fine. Hope it support all language system. Func Asc2Unicode($AscString) Local $BufferSize = StringLen($AscString) * 2 Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]") Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _ "int", 0, _ "int", 0, _ "str", $AscString, _ "int", StringLen($AscString), _ "ptr", DllStructGetPtr($Buffer), _ "int", $BufferSize) Local $UnicodeString = StringLeft(DllStructGetData($Buffer, 1), $Return[0] * 2) $Buffer = 0 Return $UnicodeString EndFunc Func Unicode2Asc($UniString) If Not IsBinaryString($UniString) Then SetError(1) Return $UniString EndIf Local $BufferLen = StringLen($UniString) Local $Input = DllStructCreate("byte[" & $BufferLen & "]") Local $Output = DllStructCreate("char[" & $BufferLen & "]") DllStructSetData($Input, 1, $UniString) Local $Return = DllCall("kernel32.dll", "int", "WideCharToMultiByte", _ "int", 0, _ "int", 0, _ "ptr", DllStructGetPtr($Input), _ "int", $BufferLen / 2, _ "ptr", DllStructGetPtr($Output), _ "int", $BufferLen, _ "int", 0, _ "int", 0) Local $AscString = DllStructGetData($Output, 1) $Output = 0 $Input = 0 Return $AscString EndFunc Func Unicode2Utf8($UniString) If Not IsBinaryString($UniString) Then SetError(1) Return $UniString EndIf Local $UniStringLen = StringLen($UniString) Local $BufferLen = $UniStringLen * 2 Local $Input = DllStructCreate("byte[" & $BufferLen & "]") Local $Output = DllStructCreate("char[" & $BufferLen & "]") DllStructSetData($Input, 1, $UniString) Local $Return = DllCall("kernel32.dll", "int", "WideCharToMultiByte", _ "int", 65001, _ "int", 0, _ "ptr", DllStructGetPtr($Input), _ "int", $UniStringLen / 2, _ "ptr", DllStructGetPtr($Output), _ "int", $BufferLen, _ "int", 0, _ "int", 0) Local $Utf8String = DllStructGetData($Output, 1) $Output = 0 $Input = 0 Return $Utf8String EndFunc Func Utf82Unicode($Utf8String) Local $BufferSize = StringLen($Utf8String) * 2 Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]") Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _ "int", 65001, _ "int", 0, _ "str", $Utf8String, _ "int", StringLen($Utf8String), _ "ptr", DllStructGetPtr($Buffer), _ "int", $BufferSize) Local $UnicodeString = StringLeft(DllStructGetData($Buffer, 1), $Return[0] * 2) $Buffer = 0 Return $UnicodeString EndFunc
  4. If a line in script is too long, autoit3 can't handle with it. So this function will cut it by using a variable $Value . ;=============================================================================== ; Description: Export registry key to an autoit script file ; Usage _RegToScript($File, $KeyName [,$ValueName]) ; Parameter(s): $File - The file to write to ; $KeyName - The registry key to export ; $ValueName - The value to export ; Requirement(s): None ; Return Value(s): None ; Author(s): Arilvv ;=============================================================================== Func _RegToScript($File, $KeyName, $ValueName = "") Dim $RegTypes[11] = ["REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY", "REG_DWORD", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ", "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR", "REG_RESOURCE_REQUIREMENTS_LIST"] Local $i, $Vaule, $SubKeyName, $KeyNameString, $TempStr, $EntireKey = False If @NumParams = 2 Then $EntireKey = True $KeyNameString = StringReplace($KeyName, '"', '""') $i = 1 While True If $EntireKey Then $ValueName = RegEnumVal($KeyName, $i) If @Error Then ExitLoop $Value = RegRead($KeyName, $ValueName) If @Error Then ExitLoop Else $Value = RegRead($KeyName, $ValueName) If @Error Then Return EndIf $TypeName = $RegTypes[@Extended] $ValueName = StringReplace($ValueName, '"', '""') If StringLen($Value) <= 1024 Then $Value = StringReplace($Value, '"', '""') If $TypeName = "REG_MULTI_SZ" Then $Value = StringReplace($Value, @LF, '" & @LF & "') FileWriteLine($File, 'RegWrite("$KeyNameString$", "$ValueName$", "$TypeName$", "$Value$")') Else FileWriteLine($File, '$$Value = ""; Long String For $KeyNameString$\$ValueName$') While $Value <> "" $TempStr = StringReplace(StringLeft($Value, 1024), '"', '""') If $TypeName = "REG_MULTI_SZ" Then $TempStr = StringReplace($TempStr, @LF, '" & @LF & "') FileWriteLine($File, '$Value &= "' & $TempStr & '"') $Value = StringTrimLeft($Value, 1024) WEnd FileWriteLine($File, 'RegWrite("$KeyNameString$", "$ValueName$", "$TypeName$", $$Value)') EndIf If Not $EntireKey Then Return $i += 1 Wend $i = 1 While True $SubKeyName = RegEnumKey($KeyName, $i) If @Error Then ExitLoop _RegToScript($File, $KeyName & "\" & $SubKeyName) $i += 1 WEnd EndFunc Example: $File = FileOpen("Test.au3", 2) _RegToScript($File, "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer") FileClose($File)
  5. What if I want to use some reg functions or run/runwat functions in the eventhandle? So I can't use Execute(). However, Call("SetVal") can't transfer the value.
  6. Recently, I use kixforms as a GUI framwork :"> . In most cases, autoit work perfectly with kixforms. But think of the example: (kix source, and kixforms.dll is here) #NoTrayIcon Global $System = ObjCreate("Kixtart.System") Global $Form = $System.Form With $Form .FontName = "Tahoma" .FontSize = 10 EndWith Global $SmallIcon = $Form.ToolButton With $SmallIcon .Location = $System.Point(10, 10) .Width = 23 .Icon = 40 .onclick = "$ListView.View = 1" .FlatStyle = 1 EndWith Global $LargeIcon = $Form.ToolButton With $LargeIcon .Location = $System.Point($SmallIcon.Right + 5, 10) .Width = 23 .Icon = 38 .onclick = "$ListView.View = 0" .FlatStyle = 1 EndWith Global $ListIcon = $Form.ToolButton With $ListIcon .Location = $System.Point($LargeIcon.Right + 5, 10) .Width = 23 .Icon = 39 .onclick = "$ListView.View = 2" .FlatStyle = 1 EndWith Global $DetailsIcon = $Form.ToolButton With $DetailsIcon .Location = $System.Point($ListIcon.Right + 5, 10) .Width = 23 .Icon = 41 .onclick = "$ListView.View = 3" .FlatStyle = 1 EndWith Global $ListView = $Form.ListView With $ListView .Location = $System.Point(10, $SmallIcon.Bottom + 10) .Right = $Form.ClientWidth - 10 .Bottom = $Form.ClientHeight - 50 .Columns.Count = 1 .SmallImageList = $Form.SmallImageList .onclick = "ListView_Click()" .View = 0 EndWith $LargeImageList = $Form.ImageList With $LargeImageList .ImageSize = $System.Size(32, 32) For $i = 0 To $Form.SmallImageList.Images.Count .Images.Add($Form.SmallImageList.Images($i)) Next EndWith $ListView.largeImageList = $LargeImageList Func ListView_Click() $Exit.Icon = $ListView.SmallImageList.Images($ListView.FocusedItem.Text) EndFunc For $i = 0 To $ListView.SmallImageList.Images.Count $Item = $ListView.Items.Add($i,$i) Next Global $Exit = $Form.ToolButton With $Exit .Center() .Top = $ListView.Bottom + 10 .Text = "Exit" .Icon = 37 .onclick = "Quit()" EndWith $Form.Center() $Form.Show() While $Form.Visible Execute($Form.DoEvents) Wend Exit 1 In this case, toolbutton can't work because Execute("$ListView.View = 3") is restricted. Maybe the only solution is to write additional functions just like: .onclick = "ListView_View_0" ... Func ListView_View_0() $ListView.View = 0 EndFunc ... While $Form.Visible Call($Form.DoEvents) Wend But I don't think this is a good idea
  7. It's a very good idea!I think the restrictions is not really necessary. Add an option to remove the restrictions or just add a new commnad, please...
×
×
  • Create New...