Leaderboard
Popular Content
Showing content with the highest reputation on 01/15/2018 in all areas
-
An example on how to inject jQuery into a web page It can be useful to manage the page from AutoIt using jQuery. Idea from here: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet Suggestions and improvements are welcome #include <ie.au3> Example() Func Example() Local $oIE = _IECreate("www.google.com") Local $jQuery = _jQuerify($oIE) MsgBox(0, "Version", "jQuery version: " & $jQuery.fn.jquery) MsgBox(0, "Example", "click ok to exit." & @CRLF & "Google logo will fade out by jQuery...") $jQuery('#hplogo').fadeOut(3000) ; jQuery will fade out the google logo EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _jQuerify ; Description ...: ; Syntax ........: _jQuerify(Byref $oIE) ; Parameters ....: $oIE - Object variable of an InternetExplorer.Application. ; Return values .: an object variable pointing to the jQuery library ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _jQuerify(ByRef $oIE) Local $jsEval, $jQuery, $otherlib = False ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) ; if jQuery is not already loaded then load it If $jsEval("typeof jQuery=='undefined'") Then ; check if the '$' (dollar) name is already in use by other library If $jsEval("typeof $=='function'") Then $otherlib = True Local $oScript = $oIE.document.createElement('script'); $oScript.type = 'text/javascript' ; If you want to load jQuery from a disk file use the following statement ; where i.e. jquery-1.9.1.js is the file containing the jQuery source ; (or also use a string variable containing the whole jQuery listing) ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file ; If you want to download jQuery from the web use this statement $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript) Do Sleep(250) Until $jsEval("typeof jQuery == 'function'") EndIf Do Sleep(250) $jQuery = $jsEval("jQuery") Until IsObj($jQuery) If $otherlib Then $jsEval('jQuery.noConflict();') Return $jQuery EndFunc ;==>_jQuerify2 points
-
how to press a button that "AutoIt v3 Window Info" don't spot
junkew and one other reacted to JLogan3o13 for a topic
Take a look at the IUIAutomation thread in the Examples forum. I am pretty sure that junkew has covered this exact scenario more than once.2 points -
StringSplit returns empty aray
rootx and one other reacted to JLogan3o13 for a topic
@rootx So, you create an array with StringSplit, then cycle through that array to create a second array, then display the second array (which is exactly the same as the $Members array originally returned). Rube Goldberg much?2 points -
I've always preferred using access keys on controls that support it natively. This is done by adding an ampersand (&) in front of a letter in the control text, then using the alt key to "activate' the control. As an example (below), hit the Alt key on the keyboard to display the underline beneath the letter 'M' in Menu, then hit the 'M' key to open it. Subsequently you can hit 'x' to toggle the Exit menu item. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> Example() Func Example() GUICreate("My GUI menu", 300, 200) $menu1 = GUICtrlCreateMenu("&Menu") $menuitem1 = GUICtrlCreateMenuItem("&Settings", $menu1) $menuitem2 = GUICtrlCreateMenuItem("E&xit", $menu1) GUISetState(@SW_SHOW) Local $sFile ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $menuitem2 ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example2 points
-
Hi, I would like to share this simple project which aims to be a first approach in order to use AutoIt as scripting language for mobile automation (Android). This project is an ImperiusGeorge client for mobile test automation that support native Android apps. You can find more information at https://ohtejera.github.io/ImperiusAutoIt and here's the link to the project on Github: https://github.com/ohtejera/ImperiusAutoIt Best regards. Henry1 point
-
StringSplit returns empty aray
JLogan3o13 reacted to iamtheky for a topic
you can always put some debug in your debug #include <Array.au3> $String0 = ("CN=Firstname0\, Lastname0 (UserID0),OU=_Marked for deletion,DC=Fabrikam,DC=COM" _ & "^CN=Firstname1\,Lastname0 (UserID0),OU=Users,OU=EUR,DC=Fabrikam,DC=COM" _ & "^CN=Firstname2\, Lastname2 (UserID3),OU=Users,OU=EUR,DC=Fabrikam,DC=COM") $members = StringSplit ( $String0, "^",2) _ArrayDisplay($members , "Array+Console" , "" , 0 , 0 , 0 , 0 , 0 , consolewrite(_ArrayToString($members , @CR)))1 point -
You have to init GDI+ first of course. Did you? Sorry, I had forgotten one additional line. Check out the code above again.1 point
-
Something like this here? $hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\Users\s\Desktop\1.jpg') $hClipboard_BitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClipboard_Bitmap) $hHBmp_Clipboard = _WinAPI_CopyImage($hClipboard_BitmapGDI, 0, 0, 0, BitOR($LR_COPYDELETEORG, $LR_COPYRETURNORG)) _WinAPI_Bitmap2Clipboard($hHBmp_Clipboard) Func _WinAPI_Bitmap2Clipboard($hHBitmap) If Not _ClipBoard_Open(0) Then Return 1 If Not _ClipBoard_Empty() Then Return 2 Local Const $hCP = _ClipBoard_SetDataEx($hHBitmap, $CF_BITMAP) If Not $hCP Or @error Then Return 3 _ClipBoard_Close() Return 0 EndFunc1 point
-
1 point
-
You can increase default cache size for a given session by using a pragma (see "PRAGMA schema.cache_size = pages;") and DB page size is defined at DB creation or changeable after that (see PRAGMA schema.page_size = bytes;"). Select a DB page size which works well for your use case and a cache size reasonnably wide enough. Don't waste too much time trying to fine-tune this until much later). You may also benefit from the json support built in SQLite, in case your API yields json. The reference site for documentation and more is of course http://www.sqlite.org/1 point
-
your suggestion is a right example of how to fix it, just in the wrong spot (and control) :).1 point
-
I have a hack this time, not a function: Generate custom/fake/pseudo events in OnEvent mode in AutoIt ; This snippet will show you a "hack" that you can use in GUI OnEvent mode in AutoIt ; With this hack you can create fake/pseudo events for a control in a OnEvent "handler" ; function which is registered with multiple controls. ; Usually you can get around this by using a unique function for every control ; but I like to use a single function that I use as a handler for a group of related ; controls. Looks neat and organized :) ; Let's get started! ; Include the important stuff #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; This function will create the GUI and make it visible Func CreateGUI() GUICreate("Example", 60, 60) ; Functions with parameters will not be called, unless all of their parameters are optional (undocumented) GUISetOnEvent($GUI_EVENT_CLOSE, HandleGUI) Global $idToggleButton = GUICtrlCreateButton("", 5, 05, 50, 50) GUICtrlSetOnEvent($idToggleButton, HandleGUI) EndFunc ; This is our most important piece of code, the Handler function which handles ; any events generated by the GUI! Func HandleGUI($iCtrlID = Default) ; As mentioned previously, when a function is called by AutoIt's OnEvent handler, ; the optional parameters are NOT defined at all! So their default values are meaningless ; Therefore we can use IsDeclared to see if a parameter is declared, effective way to know ; if it was called by AutoIt's OnEvent handler. ; ; The switch expression is a ternary operation, it first checkes if $iCtrlID is defined, ; then if it is declared locally, the expression is evaluated to $iCtrlID's value. This ; would be the case when a psedo/fake event has been generated by the script manually ; ; If it was called by AutoIt, then the expression would evaluate to @GUI_CtrlID ; ; This allows for seamless integration with the code, you won't have to use ControlClick to ; create a mouse press or something similar! Switch (IsDeclared("iCtrlID") = $DECLARED_LOCAL ? $iCtrlID : @GUI_CtrlId) Case $GUI_EVENT_CLOSE Exit Case $idToggleButton Local Static $bOn = True If $bOn Then GUICtrlSetData($idToggleButton, "Off") $bOn = False Else GUICtrlSetData($idToggleButton, "On") $bOn = True EndIf EndSwitch EndFunc ; A practical use case: ; Often when there is a button which toggles/switches between values, the default value will have ; to be repeated when creating the control, this is fine for small things but is a good way to do ; if you have something more that needs to be done. This is just a simple example of a button which ; toggles between On and Off. The speciality is that those values will not be repeated in the code :) ; ; This is not very easy to read or as simple as setting the value of the button to the default state ; during the creation of the GUI, but it is a good practise that helps you avoid replicating text CreateGUI() HandleGUI($idToggleButton) ; This will generate a fake event which will trigger the same action as clicking on the button GUISetState() ; Show the GUI While True Sleep(10) WEnd ; Link to this code snippet on Gist: https://git.io/vbRQ51 point
-
Calculate IP Subnet
natedog102 reacted to sticks221 for a topic
I apologies for posting to an old topic but this was the only post I found with a problem similar to the one I was trying to solve. Anyhows, this is the solution I found which seems to work well; ;Set our IP and Subnet $IPAddr="10.0.14.97" $Subnet="255.255.255.248" ;Split them into arrays $arrIP=StringSplit($IPAddr,".") $arrSN=StringSplit($Subnet,".") ;use a BitwiseAND to calculate the network ConsoleWrite(BitAND($arrIP[1],$arrSN[1]) & "." & BitAND($arrIP[2],$arrSN[2]) & "." & BitAND($arrIP[3],$arrSN[3]) & "." & BitAND($arrIP[4],$arrSN[4])& @CRLF) Hope this helps someone.1 point