Leaderboard
Popular Content
Showing content with the highest reputation on 03/29/2017 in all areas
-
Event_handling.au3: ;#AutoIt3Wrapper_UseX64=y #include "CLR.au3" Example() Func Example() ; Compile the helper class. This could be pre-compiled. Local $oHelper, $oHelperAsm = _CLR_CompileCSharp( FileRead( "EventHelper.cs" ) ) $oHelperAsm.CreateInstance( "EventHelper", $oHelper ) ConsoleWrite( "IsObj( $oHelper ) = " & IsObj( $oHelper ) & @CRLF ) ; Create our test object, which simply exposes a single event. Local $oTest, $oTestAsm = _CLR_CompileCSharp( FileRead( "TestObject.cs" ) ) $oTestAsm.CreateInstance( "ObjectWithEvent", $oTest ) ConsoleWrite( "IsObj( $oTest ) = " & IsObj( $oTest ) & @CRLF ) Local $hEventHandler = DllCallbackRegister( "EventHandler", "int", "ptr" ) Local $pEventHandler = DllCallbackGetPtr( $hEventHandler ) ; Add an event handler for the "OnEvent" event. Use "" to pass the ; address as a string, since IDispatch doesn't support 64-bit integers. $oHelper.AddHandler( $oTest, "OnEvent", $pEventHandler ) ; Make an event handler (event must be of the EventHandler type). Local $oHandler = $oHelper.MakeHandler( $pEventHandler ) $oTest.add_OnEvent( $oHandler ) ; Test the event handlers. $oTest.RaiseEvent() EndFunc ; Our event handler is called with a SAFEARRAY of parameters. This ; makes it much easier to get the type and value of each parameter. Func EventHandler( $pprm ) ConsoleWrite( "$pprm = " & $pprm & @CRLF ) Local $iDim = SafeArrayGetDim( $pprm ) ConsoleWrite( "$iDim = " & $iDim & @CRLF ) Local $iLBound, $iUBound SafeArrayGetLBound( $pprm, 1, $iLBound ) SafeArrayGetUBound( $pprm, 1, $iUBound ) ConsoleWrite( "$iLBound = " & $iLBound & @CRLF ) ConsoleWrite( "$iUBound = " & $iUBound & @CRLF ) Local $tprm = DllStructCreate( $tagSAFEARRAY, $pprm ) Local $fFeatures = DllStructGetData( $tprm, "fFeatures" ) ConsoleWrite( "$fFeatures = 0x" & Hex( $fFeatures ) & @CRLF ) Local $cbElements = DllStructGetData( $tprm, "cbElements" ) ConsoleWrite( "$cbElements = " & $cbElements & @CRLF ) Local $vt SafeArrayGetVartype( $pprm, $vt ) ConsoleWrite( "$vt = " & $vt & @CRLF ) Local $prmData, $tvt, $data, $obj SafeArrayAccessData( $pprm, $prmData ) $tvt = DllStructCreate( "word", $prmData ) $vt = DllStructGetData( $tvt, 1 ) ConsoleWrite( "$vt = " & $vt & @CRLF ) ; EventArgs Class $data = DllStructGetData( DllStructCreate( "ptr", $prmData + 8 ), 1 ) $obj = ConvertPtrToIDispatch($data) ConsoleWrite( $obj.ToString() & @CRLF ) $tvt = DllStructCreate( "word", $prmData + ( @AutoItX64 ? 24 : 16 ) ) $vt = DllStructGetData( $tvt, 1 ) ConsoleWrite( "$vt = " & $vt & @CRLF ) ; EventArgs Class $data = DllStructGetData( DllStructCreate( "ptr", $prmData + ( @AutoItX64 ? 24 : 16 ) + 8 ), 1 ) $obj = ConvertPtrToIDispatch($data) ConsoleWrite( $obj.ToString() & @CRLF ) SafeArrayUnaccessData( $pprm ) EndFunc ; In the end we still want the autoit object. This function converts a raw pointer to an autoit object Func ConvertPtrToIDispatch($IDispatch_Ptr) ; This would have been 10000x easier if autoit had supported the idispatch* type in dllstructs... ; Fortunetely memcpy can copy the pointer into a idispatch*, lucky us. $ptr_struct=DllStructCreate("ptr") DllStructSetData($ptr_struct,1,$IDispatch_Ptr) $aCall = DllCall("ntdll.dll","ptr:cdecl","memcpy","idispatch*","","ptr",DllStructGetPtr($ptr_struct),"long",4) return $aCall[1] EndFunc EventHelper.cs using System; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; public class EventHelper { // Delegate type for the AutoHotkey callback. public delegate void CallbackType([MarshalAs(UnmanagedType.SafeArray)] object[] argv); // AddHandler: Adds a callback as a handler for the given event of the given object. public void AddHandler(object target, string eventName, string pcb) { var cb = ParseCB(pcb); // Reference: http://msdn.microsoft.com/en-us/library/ms228976 EventInfo evt = target.GetType().GetEvent(eventName); Type handlerType = evt.EventHandlerType; MethodInfo handlerSig = handlerType.GetMethod("Invoke"); ParameterInfo[] parameters = handlerSig.GetParameters(); Type[] parameterTypes = new Type[parameters.Length+1]; parameterTypes[0] = typeof(CallbackType); for (int i = 0; i < parameters.Length; i++) parameterTypes[i+1] = parameters[i].ParameterType; var handler = new DynamicMethod("", handlerSig.ReturnType, parameterTypes, true); var il = handler.GetILGenerator(); var loc = il.DeclareLocal(typeof(object[])); il.Emit(OpCodes.Ldc_I4_2); il.Emit(OpCodes.Newarr, typeof(object)); il.Emit(OpCodes.Stloc_0); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldc_I4_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Stelem_Ref); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Ldc_I4_1); il.Emit(OpCodes.Ldarg_2); il.Emit(OpCodes.Stelem_Ref); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Call, typeof(CallbackType).GetMethod("Invoke")); il.Emit(OpCodes.Ret); var delg = handler.CreateDelegate(handlerType, cb); var adder = evt.GetAddMethod(); adder.Invoke(target, new object[] { delg }); } // Much simpler method, restricted to a specific delegate type. public EventHandler MakeHandler(string pcb) { var cb = ParseCB(pcb); return (sender, e) => cb(new object[]{ sender, e }); } public CallbackType ParseCB(string cb) { // For 32-bit, simply marking the parameter of AddHandler/MakeHandler with: // [MarshalAs(UnmanagedType.FunctionPtr)] CallbackType cb // is adequate, but since IDispatch doesn't support 64-bit integers, // we have to pass the callback address as a string for x64 builds. return (CallbackType) Marshal.GetDelegateForFunctionPointer( (IntPtr)Int64.Parse(cb), typeof(CallbackType)); } } TestObject.cs public class ObjectWithEvent { public void RaiseEvent() { if (OnEvent != null) OnEvent(this, System.EventArgs.Empty); } public event System.EventHandler OnEvent; } tst00.au3 ;#AutoIt3Wrapper_UseX64=y #include "CLR.au3" Example() ; Form Using System.Windows.Forms.Form Func Example() ; Compile the helper class. This could be pre-compiled. Local $oHelper, $oHelperAsm = _CLR_CompileCSharp( FileRead( "EventHelper.cs" ) ) $oHelperAsm.CreateInstance( "EventHelper", $oHelper ) ConsoleWrite( "IsObj( $oHelper ) = " & IsObj( $oHelper ) & @CRLF ) ConsoleWrite( "_CLR_LoadLibrary System.Windows.Forms" & @CRLF ) Local $oAssembly = _CLR_LoadLibrary( "System.Windows.Forms" ) ConsoleWrite( "IsObj( $oAssembly ) = " & IsObj( $oAssembly ) & @CRLF ) ConsoleWrite( @CRLF & "_CRL_CreateObject: System.Windows.Forms.Form" & @CRLF ) Local $oForm = _CRL_CreateObject( $oAssembly, "System.Windows.Forms.Form" ) ConsoleWrite( "IsObj( $oForm ) = " & IsObj( $oForm ) & @CRLF ) $oForm.Text = "Form From Net - AutoIt Rocks" $oForm.Width = 800 $oForm.Height = 400 ConsoleWrite( @CRLF & "_CRL_CreateObject System.Windows.Forms.Button" & @CRLF ) Local $oButton1 = _CRL_CreateObject($oAssembly, "System.Windows.Forms.Button") $oButton1.Text = "button" $oButton1.Width = 60 $oButton1.Height = 30 Local $hEventHandler = DllCallbackRegister( "EventHandler", "int", "ptr" ) Local $pEventHandler = DllCallbackGetPtr( $hEventHandler ) ; Add an event handler for the "OnEvent" event. Use "" to pass the ; address as a string, since IDispatch doesn't support 64-bit integers. $oHelper.AddHandler( $oButton1, "Click", $pEventHandler ) ;$oForm.Controls.Add( $oButton1 ) ; ERR $oButton1.Parent = $oForm ; OK $oForm.ShowDialog() $oForm.Dispose() EndFunc ; Our event handler is called with a SAFEARRAY of parameters. This ; makes it much easier to get the type and value of each parameter. Func EventHandler( $pprm ) ConsoleWrite( "$pprm = " & $pprm & @CRLF ) Local $iDim = SafeArrayGetDim( $pprm ) ConsoleWrite( "$iDim = " & $iDim & @CRLF ) Local $iLBound, $iUBound SafeArrayGetLBound( $pprm, 1, $iLBound ) SafeArrayGetUBound( $pprm, 1, $iUBound ) ConsoleWrite( "$iLBound = " & $iLBound & @CRLF ) ConsoleWrite( "$iUBound = " & $iUBound & @CRLF ) Local $tprm = DllStructCreate( $tagSAFEARRAY, $pprm ) Local $fFeatures = DllStructGetData( $tprm, "fFeatures" ) ConsoleWrite( "$fFeatures = 0x" & Hex( $fFeatures ) & @CRLF ) Local $cbElements = DllStructGetData( $tprm, "cbElements" ) ConsoleWrite( "$cbElements = " & $cbElements & @CRLF ) Local $vt SafeArrayGetVartype( $pprm, $vt ) ConsoleWrite( "$vt = " & $vt & @CRLF ) Local $prmData, $tvt, $data, $obj SafeArrayAccessData( $pprm, $prmData ) $tvt = DllStructCreate( "word", $prmData ) $vt = DllStructGetData( $tvt, 1 ) ConsoleWrite( "$vt = " & $vt & @CRLF ) ; EventArgs Class $data = DllStructGetData( DllStructCreate( "ptr", $prmData + 8 ), 1 ) $obj = ConvertPtrToIDispatch($data) ConsoleWrite( $obj.ToString() & @CRLF ) $tvt = DllStructCreate( "word", $prmData + ( @AutoItX64 ? 24 : 16 ) ) $vt = DllStructGetData( $tvt, 1 ) ConsoleWrite( "$vt = " & $vt & @CRLF ) ; EventArgs Class $data = DllStructGetData( DllStructCreate( "ptr", $prmData + ( @AutoItX64 ? 24 : 16 ) + 8 ), 1 ) $obj = ConvertPtrToIDispatch($data) ConsoleWrite( $obj.ToString() & @CRLF ) SafeArrayUnaccessData( $pprm ) EndFunc ; In the end we still want the autoit object. This function converts a raw pointer to an autoit object Func ConvertPtrToIDispatch($IDispatch_Ptr) ; This would have been 10000x easier if autoit had supported the idispatch* type in dllstructs... ; Fortunetely memcpy can copy the pointer into a idispatch*, lucky us. $ptr_struct=DllStructCreate("ptr") DllStructSetData($ptr_struct,1,$IDispatch_Ptr) $aCall = DllCall("ntdll.dll","ptr:cdecl","memcpy","idispatch*","","ptr",DllStructGetPtr($ptr_struct),"long",4) return $aCall[1] EndFunc3 points
-
Hello Community, here's the latest update on... SMF - Search my Files Current Version: v17 (2024-Oct-20) SMF - Search my Files features A good looking GUI, Search files by location, Search files and / or folders, Poll [-]File names and Locations in Long and Short (8.3) format, [-]File Extensions, [-]File Times (modified, created, accessed), [-]File size, [-]File Attributes, [-]File Extended Attributes, Filter by [-]Extension, [-]Attribute, [-]File size, [-]File time, Free Name filtering by usage of RegEx, GUI designed to fit to 800x600 desktops with Tab-Design Nice looking Icon Minimize to Tray (also while searching) Export Result to CSV-file Export Result to XML-file Save & Load search runs Build Tree for local Computer on StartUp, add NetworkDrives optional A separate Report-GUI [-]Pre-Select output columns [-]SQLite driven [-]Dynamically generated statements, fully user adjustable [-]Dynamically sub filtering of results on the fly [-]Results can be executed directly, starting with the default associated program (ShellExcecute) [-]Select Results by drag, copy selected URIs to clipboard [-]Copy, move, delete or Erase results or subset of results md5 driven Duplicate file finder [-]High-Performance [-]added trimmed md5 short calculation (false md5, but sufficient for dup-search and a great speed improvement!) [-]Search 30.000 pics for dups in 1min 30secs Added many other ideas (some not activated / implemented yet) Limitations / Bugs / ToDos Lots and lots of unnecessary Global Variables Ugly code PLUS violations of any coding principal known to man... But hey, thats why I release the source, so that YOU help me to further improve SMF... SMF works fine at least on the 32bit XP SP3 and 64bit Win7/Win8/Win10 machines and I've tested it on. If you find bugs please let me know. Thanks to my sweet girlfriend for reviewing, giving new ideas and having so much patience with me :-*. Thanks to Jon, Larry, Jos, Valik, Jpm, Melba23 and Trancexx and for creating AutoIt and maintaining the forum. And finally thanks to all these great guys from the forum, providing excellent UDFs, snippets of code I use in SMF or help and feedback: Achilles, Ascend4nt, Ed_Maximized, Elgabionline, Erik Pilsits (Wraithdu), Eukalyptus, Gafrost, Holger Kotsch, Jarvis J. Stubblefield (JSThePatriot), Jos, Lahire Biette, Lazycat, Lod3n, Prog@ndy, Ptrex, Rasim, RazorM, RobSaunders, Sean Hart, Siao, Simucal, Smashly, SmOke_N, Teh_hahn, Valik, Ward, WideBoyDixon, Yann Perrin, Yashied & Zedna. Please let me know if you found some piece of code in the source for which I forgot to mention a credit. The executable and the source can be downloaded from my site: https://funk.eu Enjoy, let me know what you think of SMF and with Best Regards1 point
-
Version 1.6.3.0
17,292 downloads
Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort1 point -
[New Version] - 16 Apr 2022 Added: A new function _GUIExtender_Hidden_Control which allows you to specify which controls should not be automatically reshown when it redraws the GUI. You no longer need to hide/show the control within the script - this function does that as well as telling the UDF whether or not to show it on redraw. New UDF and an additional example in the zip below. Previous changes: Changelog.txt ........................................................................... The GUIExtender UDF allows you to have multiple sections within your GUIs which can be either static or extendable. The extendable sections can be extended and retracted either by UDF created buttons or programmatically by other controls or HotKeys. The controls on the sections are fully functional and there is no overlap problem when retracted (see the details section if you want to know how). The UDF can be used in both MessageLoop and OnEvent modes and with both native and UDF created controls, as well as embedded objects and child GUIs. -------------------------------------------------------------- Note: This is a new recoded and (I hope) simplified version of my earlier UDF of the same name. If you move to this new version there are several script-breaking changes, so please look carefully at the included example scripts to see where things have changed. Here is a quick guide to how the UDF function list has been altered: Old function New function Comment _Init _Init Unchanged _Clear _Clear Unchanged _Section_Start _Section_Create New default parameters for position and size _Section_End Deprecated _Section_Create used to end all section creation _Section_Action _Section_Activate Simple rename _Action _EventMonitor Simple rename _Section_Extend _Section_Action Simple rename, but now uses integer parameter for required state _Section_State _Section_State Unchanged _Restore Deprecated Now automatic _ActionCheck Deprecated Now automatic _HandleCheck Deprecated Now automatic _Obj_Data _Obj_Data Unchanged - _Handle_Data Single call on creation replaces multiple _HandleCheck calls Note: The _EventMonitor function must be added to the idle loop for the automatic actions above to occur -------------------------------------------------------------- Details of how the UDF works for those who are interested: The UDF and plenty of commented examples are in the attached zip: GUIExtender.zip M231 point
-
So I think it's time to publish this little tutorial I have made on using DllCall() and DllStructs. It's not near completion but I think it's a good start at least This tutorial is mostly aimed for people who have never used DllCall() before or have very limited knowledge about it. In the future I will update it with more advanced topics so more advanced users can make use of it too. Well here goes. Dealing_with_Dll.pdf Previous downloads: 31 Suggestions, language corrections and errors in the tutorial is of course welcome.1 point
-
Hello Yes you can. #RequireAdmin ; for this example to have sense #include <MsgBoxConstants.au3> #include <ProcessConstants.au3> #include <Security.au3> #include <SecurityConstants.au3> #include <StructureConstants.au3> #include <WinAPI.au3> Local $sCommand = _ 'Local ' & _ '$Dummy1 = MsgBox(0,"Am I Admin?", "IsAdmin: " & IsAdmin())' $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' ConsoleWrite($sCommand & @CRLF) ;~ Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand) _RunNonElevatedAndWait(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand) Func _RunNonElevatedAndWait($sCommandLine = "") If Not IsAdmin() Then Return Run($sCommandLine) ; if current process is run non-elevated then just Run new one. ; Structures needed for creating process Local $tSTARTUPINFO = DllStructCreate($tagSTARTUPINFO) Local $tPROCESS_INFORMATION = DllStructCreate($tagPROCESS_INFORMATION) ; Process handle of some process that's run non-elevated. For example "Explorer" Local $hProcess = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, 0, ProcessExists("explorer.exe")) ; If successful If $hProcess Then ; Token... Local $hTokOriginal = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS) ; Process handle is no longer needed. Close it _WinAPI_CloseHandle($hProcess) ; If successful If $hTokOriginal Then ; Duplicate the original token Local $hTokDuplicate = _Security__DuplicateTokenEx($hTokOriginal, $TOKEN_ALL_ACCESS, $SECURITYIMPERSONATION, $TOKENPRIMARY) ; Close the original token _WinAPI_CloseHandle($hTokOriginal) ; If successful If $hTokDuplicate Then ; Create process with this new token _Security__CreateProcessWithToken($hTokDuplicate, 0, $sCommandLine, 0, @ScriptDir, $tSTARTUPINFO, $tPROCESS_INFORMATION) ; Close that token _WinAPI_CloseHandle($hTokDuplicate) ; Close get handles _WinAPI_CloseHandle(DllStructGetData($tPROCESS_INFORMATION, "hProcess")) _WinAPI_CloseHandle(DllStructGetData($tPROCESS_INFORMATION, "hThread")) ; Return PID of newly created process Return ProcessWaitClose(DllStructGetData($tPROCESS_INFORMATION, "ProcessID")) EndIf EndIf EndIf EndFunc ;==>_RunNonElevated Saludos1 point
-
Right-click context menu items - where are they stored?
Jos reacted to JLogan3o13 for a topic
And the award for missing the point by a mile goes to...1 point -
how to immediately update tray items when clicking on tray icon?
krasnoshtan reacted to Melba23 for a topic
jpujut, Interesting problem - here is my best effort so far: #include <TrayConstants.au3> Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown. ; Flag to show if update has occurred Global $fUpdate = False $cTray_Change_Item = TrayCreateItem("Item set at " & @SEC) TrayCreateItem("") $cTray_Exit_Item = TrayCreateItem("Exit") TrayItemSetOnEvent($cTray_Exit_Item, "_Exit") ; Update tray when mouse first goes over TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_Update_Tray") While 1 Sleep(10) WEnd Func _Update_Tray() ; If not already updated If Not $fUpdate Then ; Run update code ConsoleWrite("Updating at: " & @SEC & @CRLF) TrayItemSetText($cTray_Change_Item, "Item set at " & @SEC) ; Set flag to show update completed $fUpdate = True ; Register Adlib to clear flag after 1 sec AdlibRegister("_Reset_UpDate", 1000) ConsoleWrite("Adlib set" & @CRLF) EndIf EndFunc Func _Reset_UpDate() AdlibUnRegister("_Reset_Update") $fUpdate = False ConsoleWrite("Reset" & @CRLF) EndFunc Func _Exit() Exit EndFunc It updates the tray when the mouse first goes over the icon, sets a flag to prevent multiple updates, and sets a timer to clear the flag after 1 sec - this timer does not run until after the menu is closed, so the delay could be even shorter. Please ask if you have any questions. M231 point -
Auto Install Fonts from folder
Silverback83 reacted to JLogan3o13 for a topic
@Silverback83 no one is saying you're being a pain, just trying to gather more information. Something as simple as what you wrote above is helpful as forum members try to assist you. Sometimes we get into a rut of posting "it's broke!" without realizing that it doesn't fully explain what we are (or are not!) seeing.1 point -
[Solved] Convert a 2D array to a 1D array
AnonymousX reacted to Subz for a topic
To convert the 2D Array to a 1D Array you could just use: #include <Array.au3> Local $twoDarray[3][2] Local $oneDarray[1] $twoDarray [0][1] = "A" $twoDarray [1][1] = "B" $twoDarray [2][1] = "C" For $i = 0 To UBound($twoDarray) - 1 _ArrayAdd($oneDarray, $twoDarray[$i][1]) Next $oneDarray[0] = UBound($oneDarray) - 1 _ArrayDisplay($twoDarray) _ArrayDisplay($oneDarray)1 point -
Subscript used on non-accesible variable
JohnOne reacted to InunoTaishou for a topic
The error is in ImageSearch.au3. This topic has been created so many times, the question has been asked so many times, and it has been answered so many times. The ImageSearch.au3 UDF should have proper error checking throw into it and re-released or something. Throw in If (@Error) in the ImageSearch function after it does the DLLCall to the ImageSearchDLL.dll or check that $result is an array (IsArray($result))1 point -
[Solved] Convert a 2D array to a 1D array
AnonymousX reacted to InunoTaishou for a topic
Not sure how you're able to create a 2d array using IniWrite, I think you left out a step. Perhaps you meant you get a 2d array using IniReadSection? If you're trying to store settings in an Ini file this is one of the favorite ways I use to load/save ini files #include <String.au3> #include <FileConstants.au3> #include <GUIConstants.au3> ; Array holding the Ini Key and the corresponding AutoIt variable name Global Const $INI_SETTINGS[][2] = [["String Val", "sStringVal"], ["Integer Val", "iIntVal"], ["Double Val", "dDoubleVal"], ["Boolean Val", "bBoolVal"]] Global $sStringVal = "" Global $iIntVal = 0 Global $dDoubleVal = 0.0 Global $bBoolVal = False LoadIniFile(@ScriptDir & "\Test.ini") Global $hMain = GUICreate("Example", 230, 130) Global $lblString = GUICtrlCreateLabel("String Val = ", 10, 10, 75, 20) Global $inpString = GUICtrlCreateInput($sStringVal, 85, 10, 125, 20) Global $lblInteger = GUICtrlCreateLabel("Integer Val = ", 10, 40, 75, 20) Global $inpInteger = GUICtrlCreateInput($iIntVal, 85, 40, 125, 20) Global $lblDouble = GUICtrlCreateLabel("Double Val = ", 10, 70, 75, 20) Global $inpDouble = GUICtrlCreateInput($dDoubleVal, 85, 70, 125, 20) Global $lblBool = GUICtrlCreateLabel("Boolean Val = ", 10, 100, 75, 20) Global $inpBool = GUICtrlCreateInput($bBoolVal, 85, 100, 125, 20) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE $sStringVal = GUICtrlRead($inpString) $iIntVal = GUICtrlRead($inpInteger) $dDoubleVal = GUICtrlRead($inpDouble) $bBoolVal = GUICtrlRead($inpBool) SaveToIniFile(@ScriptDir & "\Test.ini") Exit 0 EndSwitch WEnd Func LoadIniFile(Const $sIniFile) If (Not FileExists($sIniFile)) Then Return For $i = 0 To UBound($INI_SETTINGS) - 1 Local $vIniValue = IniRead($sIniFile, "Settings", $INI_SETTINGS[$i][0], "Default") If ($vIniValue == "Default" Or StringLen($vIniValue) = 0) Then ContinueLoop ; If the string value of the ini setting is the string "True" make it Boolean true If ($vIniValue = "True") Then $vIniValue = True ; If the string value of the ini setting is the string "False" make it Boolean false If ($vIniValue = "False") Then $vIniValue = False ; Assign to the variable the value read Assign($INI_SETTINGS[$i][1], $vIniValue) Next EndFunc ;==>LoadIniFile Func SaveToIniFile(Const $sIniFile) ; Open Ini File for overwrite ; That's correct, we are not going to use IniWrite because everything can be written to the Ini file using the $INI_SETTINGS array Local $hIniFile = FileOpen($sIniFile, $FO_OVERWRITE) ; Beginning of the Ini file Local $sSettings = "[Settings]" & @CRLF ; Length of the longest Key value, used purely to make the ini file look pretty.... Local $iMaxLength = 0 ; Get the longest length of a string For $i = 0 To UBound($INI_SETTINGS) - 1 $iMaxLength = Max(StringLen($INI_SETTINGS[$i][0]) + 1, $iMaxLength) Next ; Create the ini file string For $i = 0 To UBound($INI_SETTINGS) - 1 Local $sPadding = StringReplace(_StringRepeat(" ", $iMaxLength - StringLen($INI_SETTINGS[$i][0])), " ", " ") $sSettings &= $INI_SETTINGS[$i][0] & StringReplace($sPadding, " ", " ") & " = " & Eval($INI_SETTINGS[$i][1]) & @CRLF Next ; Write the file (removing the last @CRLF) and close FileWrite($hIniFile, StringTrimRight($sSettings, 2)) Return FileClose($hIniFile) EndFunc ;==>SaveToIniFile Func Max(Const $lhs, Const $rhs) Return ($lhs > $rhs ? $lhs : $rhs) EndFunc ;==>Max I store all of the Key values from the Ini file in the [n][0] element and the autoit variable in the [n][1] element of a 2d array.1 point -
Info, Let me google that for you. M231 point
-
[Solved] IE drop down list elements
davidacrozier reacted to Subz for a topic
Wasn't 100% sure what you were after maybe something like this? #include <IE.au3> Local $oIE = _IE_Example("form") Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm") Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample") _IEFormElementOptionSelect($oSelect, "Freepage", 1, "byText") ConsoleWrite("Selected: " & _IEFormElementGetValue($oSelect) & @CRLF) Local $oOptions = _IETagNameGetCollection($oSelect, "Option") For $oOption In $oOptions ConsoleWrite($oOption.InnerText & @CRLF) Next1 point -
I have converted and extended the adfunctions.au3 written by Jonathan Clelland to a full AutoIt UDF including help file, examples, ScITE integration etc. The example scripts should run fine without changes. 2016-08-18: Version: 1.4.6.0 As always: Please test before using in production! KNOWN BUGS: (Last changed: ) None AD 1.4.6.0.zip For AutoIt >= 3.3.12.0 AD 1.4.0.0.zip other versions of AutoIt1 point
-
Here the input section: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test GUI", 581, 43) $iLable = GUICtrlCreateLabel("Project #", 6, 8, 72, 25) GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman") $iInput = GUICtrlCreateInput("", 96, 8, 385, 21) $iButton = GUICtrlCreateButton("Button", 496, 8, 75, 25) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_COMMAND, "") GUIDelete() Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0x0000FFFF) = $iInput Then Local $s = StringRegExpReplace(GUICtrlRead($iInput), "[^0-9]", "") GUICtrlSetData($iInput, $s) Switch StringLen($s) Case 3 to 6 GUICtrlSetData($iInput, StringLeft($s, 2) & "-" & StringMid($s, 3)) Case 7 To 10 GUICtrlSetData($iInput, StringLeft($s, 2) & "-" & StringMid($s, 3, 4) & "-" & StringMid($s, 7, 2)) EndSwitch EndIf Return "GUI_RUNDEFMSG" EndFunc The 2nd part is very easy by following what AutoBert has said.1 point
-
That one seems even simpler. #include "WinHttp.au3" $sTo = "5555555554" ; some phone number? $sMessage = "Test Message Text. Works?" $sRet = SMS_Send($sTo, $sMessage) ConsoleWrite("Error = " & @error & ", Response code = " & @extended & @CRLF) ConsoleWrite("> Returned = " & $sRet & @CRLF) Func SMS_Send($sTo, $sMessage) Local Const $sAddress = "https://bulksms.vsms.net/eapi/submission/send_sms/2/2.0" ; your's here Local Const $sUserName = "you" ; your user name Local Const $sPassword = "password" ; your password ; Construct the form (API's post method) Local Const $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="application/x-www-form-urlencoded">' & _ ' <input name="username"/>' & _ ; ' <input name="password"/>' & _ ' <input name="msisdn"/>' & _ ' <input name="message"/>' & _ '</form>' ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = $sForm ; Fill the form Local $sRead = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ ; location of the form "name:username", $sUserName, _ "name:password", $sPassword, _ "name:msisdn", $sTo, _ "name:message", $sMessage) ; Collect error number and HTTP status code Local $iErr = @error, $iStatus = @extended ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return SetError($iErr, $iStatus, $sRead) EndFunc1 point
-
while loop is a circle that keep the script looping the code all the time loops can b best choice for infinite loop run code 10 times run code untill something changes If sityations where you dont have loop, your script will run your code only once and then exit1 point