Leaderboard
Popular Content
Showing content with the highest reputation on 03/27/2017 in all areas
-
Richedit : drag/drop .txt files and display content
Floooooo24 and one other reacted to mikell for a topic
Found it finally. Much much cleaner. I post the solution in case of someone could need it Too bad the $ES_NOOLEDRAGDROP constant was not documented #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;#Include <Array.au3> #include <GuiEdit.au3> #include <GuiRichEdit.au3> #include <WinAPISys.au3> Global Const $ES_NOOLEDRAGDROP = 0x08 Global Const $tagDROPFILES = $tagNMHDR & ";handle hDrop;long cp;bool fProtected" $gui = GUICreate("test", 600, 400, -1, 100, -1, $WS_EX_ACCEPTFILES) $edit = GUICtrlCreateEdit("", 10, 10, 580, 180, BitOr($ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL) ) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $hRichEdit = _GUICtrlRichEdit_Create($gui, "", 10, 200, 580, 180, BitOr($ES_NOOLEDRAGDROP, $ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetLimitOnText($hRichEdit, 100000) GUISetState() _WinAPI_DragAcceptFiles ($hRichEdit) _GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_DROPFILES) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $dropped = @GUI_DragFile If StringRight($dropped, 4) <> ".txt" Then ContinueLoop GuiCtrlSetData($edit, FileRead($dropped)) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR, $tDropFiles, $hDrop, $aFileList $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hRichEdit Select Case $iCode = $EN_DROPFILES $tDropFiles = DllStructCreate($tagDROPFILES, $lParam) $hDrop = DllStructGetData($tDropFiles, "hDrop") $aFileList = _WinAPI_DragQueryFileEx($hDrop, 1) ; files only If @error OR $aFileList[0] > 1 OR StringRight($aFileList[1], 4) <> ".txt" Then _ Return _GUICtrlRichEdit_SetText($hRichEdit, "") _NewFile($aFileList[1]) _WinAPI_DragFinish($hDrop) EndSelect EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _NewFile($newfile) $filetxt = FileRead($newfile) _GUICtrlRichEdit_SetText($hRichEdit, "") _GUICtrlRichEdit_AppendText($hRichEdit, $filetxt) _GUICtrlRichEdit_SetSel($hRichEdit, 0, 0) EndFunc2 points -
I also had need to do this to automate a 3D Laser Scanner. The example given was a good starting point, but did not work for me. I thought I should share what I finally did get to work, since there is very little information I could find on this topic with google. #include <MsgBoxConstants.au3> $comObject = ObjCreate("DeviareCOM.NktSpyMgr") ; Create an COM object to access the Deviare interface $comObject.Initialize $eventObject=ObjEvent($comObject,"Deviare2_","DNktSpyMgrEvents") ; events from comObject are now passed to eventObject While 1 Sleep(100) WEnd Volatile Func Deviare2_OnProcessStarted($process) ; for reference on the proc object: http://www.nektra.com/products/deviare-api-hook-windows/doc-v2/interface_i_nkt_process.html if ($process.Name == "notepad.exe") then $hook = $comObject.CreateHook("kernel32.dll!CreateFileW", 0) $hook.Attach($process, True) $hook.Hook() MsgBox($MB_SYSTEMMODAL, $process.name, "Target Process started and hooked", 10) EndIf EndFunc Volatile Func Deviare2_OnFunctionCalled($hook, $process, $callInfo) EndFunc Volatile Func Deviare2_OnCreateProcessCall($process, $pid, $mainThreadId, $is64BitProcess, $canHookNow) EndFunc Volatile Func Deviare2_OnCustomDllLoad( $process, $actionId, $actionResult) EndFunc Volatile Func Deviare2_OnCustomDllUnLoad( $process, $actionId, $actionResult) EndFunc Volatile Func Deviare2_OnCustomApiCall( $process, $actionId, $actionResult, $apiResult) EndFunc Volatile Func Deviare2_OnHookStateChanged( $Hook, $process, $actionId, $newState, $oldState) EndFunc Volatile Func Deviare2_OnLoadLibraryCall( $process, $dllName, $moduleHandle) EndFunc Volatile Func Deviare2_OnFreeLibraryCall( $process, $moduleHandle) EndFunc Volatile Func Deviare2_OnProcessTerminated( $process) EndFunc Volatile Func Deviare2_OnAgentLoad( $process, $errorCode) EndFunc Volatile Func Deviare2_OnAgentUnload( $process) EndFunc Volatile Func Deviare2_OnCustomMessage( $process, $msgCode, $msgParam, $retVal) EndFunc Volatile Func Deviare2_OnHookOverwritten( $Hook, $process) EndFunc I did put up some more information here: https://sites.google.com/site/janbeck/interception-of-win32-and-user-dll-api-calls-using-autoit-and-deviare One thing of note is that the version of Windows OS should not really matter here, but I found that the API hooking functioned fine on Win8 x64 and Win7 x64/x32 systems but would not function on two tested WinXP x32 systems. At least when running using F5. After compiling the script into an executable, it worked fine... Hope this helps somebody.2 points
-
How about you move that create label before the if check? Func VLC() $filepath = 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe' $VLC = GUICtrlCreateLabel("VLC", 176, 48, 41, 25) ;create the label before if If FileExists($filepath) Then GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman") GUICtrlSetState($VLC, $GUI_SHOW) Else GUICtrlSetState($VLC, $GUI_HIDE) EndIf EndFunc1 point
-
junkew, Your code in post 77. I think you have to do it this way: Replace these lines in CLR.au3 "GetAssemblies hresult();" & _ "get_FullName hresult();" & _ ; (Two lines) with these lines "GetAssemblies hresult(ptr*);" & _ "get_FullName hresult(bstr*);" & _ ; (Two lines) Run this code: #include <StructureConstants.au3> #include <WinAPI.au3> #include "CLR.au3" Example() Func Example() Local $oDomain=_CLR_GetDefaultDomain() ConsoleWrite("$oDomain: " & IsObj($oDomain) & @CRLF) Local $oXPTable = _CLR_LoadLibrary("XPTable.dll") Local $sFullName $oXPTable.get_FullName( $sFullName ) ConsoleWrite( "$sFullName = " & $sFullName & @CRLF ) Local $pAssemblyArray $oDomain.getAssemblies( $pAssemblyArray ) Local $iDim = SafeArrayGetDim( $pAssemblyArray ) ConsoleWrite( "$iDim = " & $iDim & @CRLF ) Local $iLBound, $iUBound SafeArrayGetLBound( $pAssemblyArray, 1, $iLBound ) SafeArrayGetUBound( $pAssemblyArray, 1, $iUBound ) ConsoleWrite( "$iLBound = " & $iLBound & @CRLF ) ConsoleWrite( "$iUBound = " & $iUBound & @CRLF ) Local $tAssemblyArray = DllStructCreate( $tagSAFEARRAY, $pAssemblyArray ) Local $fFeatures = DllStructGetData( $tAssemblyArray, "fFeatures" ) ConsoleWrite( "$fFeatures = 0x" & Hex( $fFeatures ) & @CRLF ) Local $vt SafeArrayGetVartype( $pAssemblyArray, $vt ) ConsoleWrite( "$vt = " & $vt & @CRLF ) Local $tGUID = $tagGUID Local $tGUID = DllStructCreate( $tagGUID, $pAssemblyArray - 16 ) Local $sGUID = _WinAPI_StringFromGUID( $tGUID ) ConsoleWrite( "$sGUID = " & $sGUID & @CRLF ) Local $pAssemblyArrayData SafeArrayAccessData( $pAssemblyArray, $pAssemblyArrayData ) Local $tAssembly = DllStructCreate( "ptr", $pAssemblyArrayData ) Local $pAssembly = DllStructGetData( $tAssembly, 1 ) ConsoleWrite( "$pAssembly = " & $pAssembly & @CRLF ) SafeArrayUnaccessData( $pAssemblyArray ) Local $oAssembly = ObjCreateInterface( $pAssembly, $sIID_IAssembly, $sTag_IAssembly ) ConsoleWrite( "IsObj( $oAssembly ) = " & IsObj( $oAssembly ) & @CRLF ) Local $sFullName $oAssembly.get_FullName( $sFullName ) ConsoleWrite( "$sFullName = " & $sFullName & @CRLF ) EndFunc Output: >oClrHost: 1 >pCLRRuntimeInfo: 0x00B20658 >oCLRRuntimeInfo: 1 >IsLoadable: True >pCLRRuntimeHost: 0x00B54538 >oCLRRuntimeHost: 1 IsObj( $oCorRuntimeHost ) = 1 $pAppDomain = 0x007A002C IsObj( $oAppDomain ) = 1 $oDomain: 1 >oClrHost: 1 >pCLRRuntimeInfo: 0x00B20A18 >oCLRRuntimeInfo: 1 >IsLoadable: True >pCLRRuntimeHost: 0x00B549B8 >oCLRRuntimeHost: 1 IsObj( $oCorRuntimeHost ) = 1 $pAppDomain = 0x007A002C IsObj( $oAppDomain ) = 1 $pType = 0x007A0018 IsObj( $oType ) = 1 $pAssembly = 0x007AFFD0 IsObj( $oAssembly ) = 1 $pAssemblyType = 0x007AFF98 IsObj( $oAssemblyType ) = 1 -$pObject = 0x007AFF50 -IsObj( $oObject ) = 1 $sFullName = XPTable, Version=1.2.0.22555, Culture=neutral, PublicKeyToken=24950705800d2198 $iDim = 1 $iLBound = 0 $iUBound = 1 $fFeatures = 0x00000240 $vt = 0x0000000D $sGUID = {00000000-0000-0000-C000-000000000046} $pAssembly = 0x007AFFD0 IsObj( $oAssembly ) = 1 $sFullName = mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ptrex, You are too hasty in your conclusions.1 point
-
1 point
-
its all little dots (sorry if that's like telling you santa isn't real). do you want larger dots and a lower quality image? like in 12 point font periods? what size grid were you thinking , normal doc margins single page? more rasterbated (https://rasterbator.net/)? maybe show an example of the ideal end result? or I keep asking questions.1 point
-
Hello. You also can use this way. Global Const $SPI_SETMENUDROPALIGNMENT=0x001C Global Const $RightAlignment=True Global Const $LeftAlignment=False _WinAPI_SystemParametersInfo($SPI_SETMENUDROPALIGNMENT,$LeftAlignment) Saludos1 point
-
There are a few reg files here that should be of help. Should be able to convert to AutoIt1 point
-
mLipok, This suggestion is all I could find with a quick search - perhaps worth a check to see what is set there? M231 point
-
This example restricts the number of @CRLF's at the EOF to one. If you wish the existing two or more @CRLF's at the EOF to remain, then this example is not for you. Local $sFileName = "Testo.txt" Local $sText = FileRead($sFileName) Local $hFile = FileOpen($sFileName, 2) FileWrite($hFile, StringStripWS($sText, 2) & @CRLF) ; $STR_STRIPTRAILING (2) = strip trailing white space FileClose($hFile)1 point
-
The structure is still wrong you're using unkown dllstructure data types. Make sure to check DllStructureCreate help File. I also think you need to add some OS Version Macro to make it compatible for multiples OS versions. I really dont have enough time to do it. But I hope my suggestions help you. Saludos1 point
-
[Solved] Snippet Manager for AutoIt?
dreivilo47 reacted to water for a topic
Did you search the forum? IIRC there are threads about snippet managers.1 point -
Hello Here is a small UDF wrapper(It's pretty funny to call it UDF. it's more a start to build one) It need to be clean add error checking remove comments create functions help etc.. etc......... But I really don't have enough time to do it maybe someone can do it. Evething is gathered from previous codes. I added some examples all in a zip. CLR.zip Updated-1: CLR.zip Updated-2: CLR.zip Updated-3 CLR.zip Examples: ;~ _Example1() ;C# & VB Messagebox ;~ _Example2() ;C# Create Executable ;~ _Example3() ;C#Return String from Class Method ;~ _Example4() ;XPTable Example ;~ _Example5() ;A MessageBox Using System.Windows.Forms.MessageBox ;~ _Example6() ;WebClient.DownloadString Using System.Net.WebClient ;~ _Example7() ;Form Using System.Windows.Forms.Form ;~ _Example8() ;Stack Using System.Collections.Generic.Stack ;~ _Example9() ;File.ReadAllText Using System.IO ;~ _Example10() ;ArrayList Using System.Collections.ArrayList Saludos1 point
-
[Solved] Stop GUI until message box closed
Colduction reacted to Melba23 for a topic
AnonymousX, A better solution is to set the correct style for the MsgBox like this: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) local $but = GUICtrlCreateButton("Hello", 150,150,85,25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox($MB_TOPMOST + $MB_TASKMODAL,"Message","Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit case $but MsgBox(0,"","Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example All is explained in the Modal MsgBox Styles tutorial in the Wiki. M231 point -
[Solved] Stop GUI until message box closed
AnonymousX reacted to 232showtime for a topic
#include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Local $but = GUICtrlCreateButton("Hello", 150, 150, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_DISABLE, $hGUI) ;added MsgBox(262144, "Message", "Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") GUISetState(@SW_ENABLE, $hGUI);added ;~ WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit Case $but MsgBox(0, "", "Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example EDIT: check the help file for additional info1 point -
The problem is "HKEY_LOCAL_MACHINE" == "HKLM" i.e. 32bit key, you need to use "HKLM64" to get 64bit keys.1 point