Leaderboard
Popular Content
Showing content with the highest reputation on 08/13/2013 in all areas
-
A UDF for manipulating Windows Image Files (.wim) without ImageX.exe This UDF allows you to use the Windows Imaging API directly (wimgapi.dll) so you don't have to use a command line program such as ImageX. Benefits are wimgapi.dll is shipped with windows 7 so users don't have to download the 1gb+ AIK to manage wim files. The UDF also allows you to utilize callback functions so you can show detailed progress info to your users. wimfltr.sys/wimmount.sys required for mount/unmount only. working with both 32 and 64 bit builds. its pretty well documented but you should still read the MS Imaging API documentation and be familiar how wimgapi.dll works to get the most out of this UDF. functions marked with an (*) are only available with newer versions of wimgapi.dll Functions Included: _WIM_ApplyImage _WIM_CaptureImage _WIM_CloseHandle _WIM_CreateFile _WIM_DeleteImage _WIM_DeleteImageMounts * _WIM_ExportImage _WIM_ExtractImagePath * _WIM_GetImageAttributes _WIM_GetImageCount _WIM_GetImageInformation _WIM_LoadImage _WIM_MountImage _WIM_RegisterLogFile * _WIM_RegisterMessageCallback _WIM_RemountImage * _WIM_SetBootImage _WIM_SetImageInformation _WIM_SetReferenceFile _WIM_SetTemporaryPath _WIM_Shutdown _WIM_Startup _WIM_UnMountImage _WIM_UnRegisterLogFile * _WIM_UnregisterMessageCallback have fun! Homes32 Sample Usage #include <Wimgapi.au3> ; functions for WIM Global $swimfile, $hWim, $hImage, $filepath, $Percent, $rTime, $pCallBack Global $gsWimDLL = @SystemDir & "wimgapi.dll" ; path to wimgapi.dll $ProgramName = "WIM Demo" ; Fire up wimgapi.dll $aResult = _WIM_Startup() If @error = 2 Then MsgBox(16, $ProgramName, "Error loading library: " & "(" & $aResult & "," & @error & ", " & $gsWimDLL & ")" & @CRLF & @CRLF & "The file could not be found.") Exit (2) ElseIf @error = 1 Then MsgBox(16, $ProgramName, "Error loading library: " & "(" & $aResult & "," & @error & ", " & $gsWimDLL & ")" & @CRLF & @CRLF & "Wrong DLL. Make sure you are using the right arch (x86/x64)") Exit (254) EndIf ; your code here ; ex. ; Capture("C:toolz", "c:test.wim", "My Test IMG", "Test Desc", 1) ; Cleanup() ; Apply ;----------------------------- Func Apply($sWimFile, $iImageIndex, $sTarget) ProgressOn('Apply', '', '', -1, -1, 19) ; Register callbacks so we get progress information for the capture process. ; WARNING: This does not work very well with Apply do to the way autoit handles callbacks. ; See the following post for more info: ; http://www.autoitscript.com/forum/topic/127075-wimgapi-udf/page__view__findpost__p__917049 $pCallBack = DllCallbackRegister('CallBack', 'int', 'dword;WPARAM;LPARAM;dword') _WIM_RegisterMessageCallback(0, DllCallbackGetPtr($pCallBack), 0) ; load .wim file with read access $hWim = _WIM_CreateFile($sWimFile, $WIM_GENERIC_READ, $WIM_OPEN_EXISTING, 0, 0, 0) If $hWim = 0 Then MsgBox(48, $ProgramName, "Error: Failed to load image. (" & $hWim & "," & @error & "," & @extended & ")") Cleanup() Exit (252) EndIf ; set our temp path $aResult = _WIM_SetTemporaryPath($hWim, $sTarget) ; load the image index $hImage = _WIM_LoadImage($hWim, $iImageIndex) ; Apply the image $aResult = _WIM_ApplyImage($hImage, $sTarget) If $aResult = 0 Then MsgBox(48, $ProgramName, "Error: Failed to apply image. Make sure your path exists! (" & $aResult & "," & @error & "," & @extended & ")") Cleanup() ProgressOff() EndFunc ; Mount ;----------------------------- Func Mount($sMountPath, $sWimFile, $iImageIndex, $RW) $aResult = _WIM_MountImage($sMountPath, $sWimFile, $iImageIndex, $RW) If $aResult = 0 Then MsgBox(48, $ProgramName, "Mount Error: (" & $aResult & "," & @error & "," & @extended & ")") Cleanup() Exit (253) ; mount error EndIf Cleanup() EndFunc ; UnMount ;----------------------------- Func UnMount($sMountPath, $iCommit) $aResult = _WIM_UnMountImage($sMountPath, 0, 0, $iCommit) If $aResult = 0 Then MsgBox(48, $ProgramName, "UnMount Error: (" & $aResult & "," & @error & "," & @extended & ")") Cleanup() Exit (254) ; Unmount error EndIf Cleanup() EndFunc ; GetInfo ;----------------------------- Func GetInfo($sWimFile) ; load .wim file with read access $hWim = _WIM_CreateFile($sWimFile, $WIM_GENERIC_READ, $WIM_OPEN_EXISTING, 0, 0, 0) If $hWim = 0 Then MsgBox(48, $ProgramName, "Error: Failed to load image. (" & $hWim & "," & @error & "," & @extended & ")") Cleanup() Exit (252) EndIf ; set our temp path $aResult = _WIM_SetTemporaryPath($hWim, @TempDir) ; read wim attributes $aWimAttribs = _WIM_GetImageAttributes($hWim) ; read info from the image $aXML = _WIM_GetImageInformation($hWim) ; Cleanup any open handles Cleanup() ; make our output pretty Switch $aWimAttribs[4] Case $WIM_COMPRESS_NONE $aWimAttribs[4] = "NONE" Case $WIM_COMPRESS_XPRESS $aWimAttribs[4] = "XPRESS" Case $WIM_COMPRESS_LZX $aWimAttribs[4] = "LZX" EndSwitch Local $outFile = @ScriptDir & "wiminfo.txt" If FileExists($outFile) Then FileDelete($outFile) FileWrite($outFile, @CRLF & $ProgramName & @CRLF & @CRLF & @CRLF & @CRLF & _ "WIM Information:" & @CRLF & _ "----------------" & @CRLF & _ "Wim Path: : " & $aWimAttribs[1] & @CRLF & _ "GUID : " & $aWimAttribs[2] & @CRLF & _ "Image Count: " & $aWimAttribs[3] & @CRLF & _ "Compression: " & $aWimAttribs[4] & @CRLF & _ "Part Number: " & $aWimAttribs[5] & "/" & $aWimAttribs[6] & @CRLF & _ "Boot Index : " & $aWimAttribs[7] & @CRLF & _ "Attributes : " & $aWimAttribs[8] & @CRLF & @CRLF & @CRLF & _ "Available Image Choices:" & @CRLF & _ "------------------------" & @CRLF & _ $aXML[1]) EndFunc ;==>GetInfo ; Extract ;----------------------------- Func Extract($sWimFile, $iImageIndex, $sFilePath, $sExtractTo) ; load .wim file with read access $hWim = _WIM_CreateFile($sWimFile, $WIM_GENERIC_READ, $WIM_OPEN_EXISTING, 0, 0, 0) If $hWim = 0 Then MsgBox(48, $ProgramName, "Error: Failed to load image. (" & $hWim & "," & @error & "," & @extended & ")") Cleanup() Exit (252) EndIf ; set our temp path $aResult = _WIM_SetTemporaryPath($hWim, @TempDir) ; load the image index $hImage = _WIM_LoadImage($hWim, $iImageIndex) ; extract the file $aResult = _WIM_ExtractImagePath($hImage, $sFilePath, $sExtractTo) If $aResult = 0 Then MsgBox(48, $ProgramName, "Error: Failed to extract from image. Make sure your path exists! (" & $aResult & "," & @error & "," & @extended & ")") Cleanup() EndFunc ; Capture ;----------------------------- Func Capture($Path, $sWimFile, $sImageName, $sImageDesc, $Compress) ProgressOn('Capture', '', '', -1, -1, 19) ; Register callbacks so we get progress information for the capture process. $pCallBack = DllCallbackRegister('CallBack', 'int', 'dword;WPARAM;LPARAM;dword') _WIM_RegisterMessageCallback(0, DllCallbackGetPtr($pCallBack), 0) ; first we need to create a blank .wim file with write access and our compression options $hWim = _WIM_CreateFile($sWimFile, $WIM_GENERIC_WRITE, $WIM_CREATE_ALWAYS, 0, $Compress, 0) If $hWim = 0 Then MsgBox(48, $ProgramName, "Error: Failed to create image. (" & $hWim & "," & @error & "," & @extended & ")") Cleanup() Exit (252) ; image create failed EndIf ; set our temp path $aResult = _WIM_SetTemporaryPath($hWim, @TempDir) ; start the image capture!!! $hImage = _WIM_CaptureImage($hWim, $Path, 0) If $hImage = 0 Then MsgBox(48, $ProgramName, "Error: Failed to capture image. (" & $hImage & "," & @error & "," & @extended & ")") Cleanup() Exit (251) ; image capture failed EndIf ; add our name and description to the XML data - ChrW(65279) is the BOM $sXML = ChrW(65279) & "<IMAGE><NAME>" & $sImageName & "</NAME><DESCRIPTION>" & $sImageDesc & "</DESCRIPTION></IMAGE>" _WIM_SetImageInformation($hImage, $sXML) _WIM_SetBootImage($hWim, 1) Cleanup() ; free resources ProgressOff() EndFunc ;==>Capture ; ================================================================================================================== ; Function: CallBack ; Description: Very Basic Sample Callback function for capture progress ; Usage: CallBack($msgId, $param1, $param2, $b) ; Author: Homes32 ; ================================================================================================================== Func CallBack($msgId, $param1, $param2, $unused) Switch $msgId Case $WIM_MSG_PROGRESS ; get progress % and time remaining $Percent = $param1 If $param2 = 0 Then $rTime = "" Else $rTime = StringFormat('Remaining: %i sec.', $param2 / 1000) EndIf Case $WIM_MSG_PROCESS ; get the file name being processed $Struct = DllStructCreate("ushort[1024]", $param1) $sFilePath = "" $i = 1 While 1 $Tmp = DllStructGetData($Struct, 1, $i) If $Tmp = 0 Then ExitLoop $sFilePath &= ChrW($Tmp) $i += 1 WEnd EndSwitch ProgressSet($Percent, StringFormat('%3i%% completed. %snn %s', $Percent, $rTime, $filePath), 'Capture ' & $sWimFile) Return $WIM_MSG_SUCCESS EndFunc ;==>CallBack Func Cleanup() ; Cleanup any open handles If $hImage Then _WIM_CloseHandle($hImage) If $hWim Then _WIM_CloseHandle($hWim) If $pCallBack Then ; Cleanup our callbacks $aResult = _WIM_UnregisterMessageCallback(0, DllCallbackGetPtr($pCallBack)) DllCallbackFree($pCallBack) EndIf _WIM_Shutdown() ; shutdown wimgapi.dll EndFunc ;==>Cleanup History v1 3-30-2011 * 1st release v2 4-4-2011 * cleaned up the documention * added the following functions _WIM_DeleteImage _WIM_DeleteImageMounts _WIM_ExportImage _WIM_RemountImage _WIM_SetReferenceFile v3 9-19-2011 * Fixed Access Violation crash in _WIM_GetImageInformation Previous Downloads: 312 WimgapiUDF.zip1 point
-
The error should be "Can not initialize a variable with itself." and it should be on last $hDC on that line. This is bug.1 point
-
Try this : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("GUIOnEventMode", 1) Global Const $SM_CXSIZEFRAME = 32 Global $iSM_CXDLGFRAME = _WinAPI_GetSystemMetrics($SM_CXSIZEFRAME) Global $iSM_CYCAPTION = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Global $hGUI = GUICreate("MyGUI", Default, Default, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlCreateButton("button", 10, 10) GUICtrlCreateInput("input", 10, 40) GUICtrlCreateCheckbox("checkbox", 10, 70, 80) GUISetState(@SW_SHOW, $hGUI) Global $hMouseHook = DllCallbackRegister("_MouseProc", "long", "int;ptr;ptr") Global $hMouseProc = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseHook), _WinAPI_GetModuleHandle(0), 0) OnAutoItExitRegister("OnAutoItExit") While 1 Sleep(1000) WEnd Func _MouseProc($iCode, $wParam, $lParam) If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hMouseHook, $iCode, $wParam, $lParam) Switch BitAND($wParam, 0xFFFF) Case $WM_LBUTTONDOWN If WinActive($hGUI) > 0 Then Local $aWgp = WinGetPos($hGUI) Local $aMgp = MouseGetPos() If ($aMgp[0] > ($aWgp[0] + $iSM_CXDLGFRAME)) And ($aMgp[0] < ($aWgp[0] + $aWgp[2] - $iSM_CXDLGFRAME)) _ And ($aMgp[1] > $aWgp[1] + $iSM_CYCAPTION) And ($aMgp[1] < ($aWgp[1] + $aWgp[3] - $iSM_CXDLGFRAME)) Then _LeftClick() EndIf EndIf EndSwitch Return _WinAPI_CallNextHookEx($hMouseHook, $iCode, $wParam, $lParam) EndFunc Func _LeftClick() ConsoleWrite("left button clicked" & @CrLf) EndFunc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hMouseHook) DllCallbackFree($hMouseProc) EndFunc Func _Exit() GUIDelete($hGUI) Exit EndFuncEdit: Added indents. Br, FireFox.1 point
-
Hi, Something like this I guess : #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GUIMenu.au3> Local $hGUI = GUICreate("Control Panel", 1024, 720, -1, -1, -1, $WS_EX_TOOLWINDOW) Local $hSysMenu = _GUICtrlMenu_GetSystemMenu($hGUI) _GUICtrlMenu_DeleteMenu($hSysMenu, $SC_MINIMIZE, False) _GUICtrlMenu_DeleteMenu($hSysMenu, $SC_MAXIMIZE, False) GUISetState(@SW_SHOW, $hGUI) While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEndBr, FireFox.1 point
-
Buttons disabled after adding background image
JomarSevillejo reacted to Edano for a topic
you should prefer to disable it like firefox said....1 point -
Need help with virtual Joystick emulator
JLogan3o13 reacted to Bert for a topic
IMHO -This is really discussing game automation. It isn't naming a game specifically but none the less the purpose is to work with a game. This is only my humble opinion and it is really up to the moderator to decide.1 point -
Buttons disabled after adding background image
JomarSevillejo reacted to Edano for a topic
. as soon as you click the pic, it will overlap again1 point -
Buttons disabled after adding background image
JomarSevillejo reacted to FireFox for a topic
Hi, If you read carefully the helpfile it's stated : But there are many people like you who asked the same question so a quick forum search would have led you to the anwser Br, FireFox.1 point -
Why not just use a speedtesting site instead of complicating yourself?1 point
-
Hi, I think the Oozlum bird has had its exercise for the day and vanished up its own fundament as usual. M231 point
-
1 point
-
If you really want a result of 0/45, compile it with the latest beta.1 point
-
InKnown, Similar to BrewmanNH's (beat me to it again!!!) except that I consolidated your events to eliminate redundant code. M23 has an excellent tutorial here for managing multiple Gui's. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <EditConstants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) global $form2, $button2, $input, $timer GUIFUNC() Func GUIFUNC() Global $Form1 = GUICreate("Countdown", 460, 238, 288, 136) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") Global $Button1 = GUICtrlCreateButton("Countdown", 144, 80, 177, 57) GUICtrlSetFont($Button1, 12, 800, 0, "MS Serif") GUICtrlSetOnEvent(-1, "Button") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd EndFunc ;==>GUIFUNC Func GUIFUNC2() $form2 = GUICreate("", 350, 330) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $Input = GUICtrlCreateInput("", 125, 150, 90, 40, BitOR($SS_CENTER, $ES_READONLY, $WS_CLIPCHILDREN)) GUICtrlSetFont(-1, 18, 400) $Button2 = GUICtrlCreateButton("Close", 125, 250, 90, 40) GUICtrlSetOnEvent(-1, "Button") GUISetState(@SW_SHOW) EndFunc ;==>GUIFUNC2 Func Button() switch @gui_ctrlid case $button2 $Var = MsgBox(4, "Close", "Close?") If $Var = 6 Then Exit case $Button1 guifunc2() $timer = timerinit() Update_timer() adlibregister('Update_timer',1000) endswitch EndFunc ;==>PressClose Func SpecialEvents() Switch @GUI_winhandle Case $form1 Exit case $form2 guidelete($form2) EndSwitch EndFunc ;==>SpecialEvents func Update_timer() $ms = 10000 $seconds = TimerDiff($timer) / 1000 $diff = $seconds - ($ms / 1000); $minutes = Int($diff / 60) $secondsRem = $diff - ($minutes * 60) $minutes = $minutes * -1 $secondsRem = $secondsRem * -1 $time = StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem) GUICtrlSetData($Input, $time) endfunc kylomas edit: moved timerinit function from adlib to button routine so it could be retstarted from the beginning1 point
-
Or you could use @Tab.1 point
-
You think you can write regex?
jaberwacky reacted to monoceres for a topic
If you had any idea what you're talking about you would realize how ridiculus this statemment is. The bloom filter is used to speed up processing for lightweight clients (like smartphones). Do you really think a basic property of a common data structure would compromise one of the worlds most well crafted, intricate cryptographic system?!1 point -
How to build a check box like this?
codewar509 reacted to Edano for a topic
0x50010006 = BitOr(0x50000000, 0x10000, 0x06) 6 is $BS_AUTO3STATE 0x50000000 is not known as global const in the includes there are 48 global const in the includes with the value of 0x10000, among them $__BUTTONCONSTANT_WS_TABSTOP1 point -
ok, if you are forced to using this dialog popped by your app, then follow this route: step 1: use the AutoIt Window Info tool (Start > Programs > AutoIt3) to determine the Control ID of: the element presenting the list of folders & files - or - the InputBox where you can type the file name step 2: use ControlSend() to pass to this Control ID the folder/file name you want to use. (if it's in the list, then the focus will go to the folder as you type. you can try it manually). step 3: Send("{ENTER}") you know, if you give us a little background on what you are doing and why, we may better understand your issue, and suggest more suitable solutions. but hey, feel free to stop us from helping you anytime :-)1 point
-
AutoIt v3.3.7.3 (Beta) Released: Report issues here. Download here.1 point