Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/17/2014 in all areas

  1. #include <IE.au3> Const $ie_new_in_tab=0x0800 $oIE = _IECreate("http://www.autoitscript.com") $oIE.Navigate("http://www.autoitscript.com/forum/", $ie_new_in_tab) $oIE2 = _IEAttach("http://www.autoitscript.com/forum/", "url") _IEQuit($oIE2)
    2 points
  2. FredAI

    System restore UDF

    Hi. I needed this for one of my apps, and all I could find here was a WMI object function to create a restore point, so I decided to create this UDF and post it here. It has functions to enumerate, delete (one or all) and create restore points. Also enable or disable the system restore, and restore the system to one of the restore points. There are only two functions available through DllCall on msdn, the others are WMI. The UDF is not commented yet, I'll do it tomorrow and update. It's getting late, now. Better call it a night. Sorry for the delay. Here's the commented updated version: (28 downloads before) Note: Some functions were slightly modified. Updated 15/11/2011 (66 total downloads). The $DriveL optional parameter in the _SR_Enable and _SR_Disable functions must be in the format $SystemDrive & '\', or the functions won't work. SystemRestore.au3
    1 point
  3. Just so everyone (who does't know) knows, before we ship the UDFs with the latest AutoIt, jpm runs a unit test which consists of including all the UDFs in a single script to see if there are any issues of possible variable duplication. If it fails we fix it, if it doesn't then of course everyone is happy!
    1 point
  4. The warnings are built into IE.au3, DaleHohm wrote them in there. That's why accessing the properties/methods directly from the object doesn't show a warning/error. Run this script and you'll see what I'm talking about. #include <IE.au3> _IEErrorNotify(0) Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("http://www.autoitscript.com") _IELoadWait($oIE) __IENavigate($oIE, "http://www.autoitscript.com/forum/", 1, 0x0800) ; [n] = the object to the tab Global $ga_IETabs = 0 $ga_IETabs = __IE_TabLoadWait($oIE, "http://www.autoitscript.com/forum/", "url") If @error Then Exit 101 Local $go_NewTab = $ga_IETabs[1] ; I know it's only returning 1 _IEQuit($go_NewTab) ; this will return the objects of the tabs matching type/str and wait if need be Func __IE_TabLoadWait(ByRef $o_obj, $s_str = "", $s_type = "", $n_msecexpire = 0) If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $a_objret = 0 Local $n_timer = TimerInit() While 1 $a_objret = __IE_GetTabObjs($o_obj, $s_str, $s_type) If IsArray($a_objret) Then ExitLoop ; return if we set the wait timer and it's reached If $n_msecexpire > 0 Then If $n_timer >= $n_msecexpire Then Return SetError(2, 0, 0) EndIf EndIf Sleep(250) WEnd If Not IsArray($a_objret) Then Return SetError(3, 0, 0) EndIf ; set normal _ieloadwait default If $n_msecexpire < 1 Then $n_msecexpire = -1 For $i = 1 To UBound($a_objret) - 1 _IELoadWait($a_objret[$i], 0, $n_msecexpire) Next ; this could return multiple if there is more than 1 tab ; with the same url/title for $s_type passed Return $a_objret EndFunc ; returns all the instances of tabs matching type/str criteria Func __IE_GetTabObjs(ByRef $o_obj, $s_str = "", $s_type = "") If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $a_otabs[101], $i_add = 0, $i_next = 1, $o_ieattach $s_type = StringLower($s_type) While 1 ; we start at instance 1 and enum as we find more instances $o_ieattach = _IEAttach($o_obj, "instance", $i_next + 1) If @error = $_IEStatus_NoMatch Or Not IsObj($o_ieattach) Then ExitLoop ; control array size If Mod($i_add + 1, 100) = $i_add Then ReDim $a_otabs[$i_add + 101] EndIf Switch StringLower($s_type) Case "url" If String(Execute("$o_ieattach.locationurl")) = $s_str Then $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndIf Case "title" If WinGetText(String(Execute("$o_ieattach.hwnd"))) = $s_str Then $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndIf Case Else $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndSwitch $i_next += 1 WEnd If $i_add = 0 Then Return SetError(2, 0, 0) ReDim $a_otabs[$i_add + 1] $a_otabs[0] = $i_add Return $a_otabs EndFunc See, no warnings/errors .
    1 point
  5. water

    Excel - Go to Next Column

    Choose the solution that best fits your needs
    1 point
  6. Fun times... #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("http://www.autoitscript.com") _IELoadWait($oIE) __IENavigate($oIE, "http://www.autoitscript.com/forum/", 1, 0x0800) ; [n] = the object to the tab Global $ga_IETabs = 0 $ga_IETabs = __IE_TabLoadWait($oIE, "http://www.autoitscript.com/forum/", "url") If @error Then Exit 101 Local $go_NewTab = $ga_IETabs[1] ; I know it's only returning 1 _IEQuit($go_NewTab) ; this will return the objects of the tabs matching type/str and wait if need be Func __IE_TabLoadWait(ByRef $o_obj, $s_str = "", $s_type = "", $n_msecexpire = 0) If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $a_objret = 0 Local $n_timer = TimerInit() While 1 $a_objret = __IE_GetTabObjs($o_obj, $s_str, $s_type) If IsArray($a_objret) Then ExitLoop ; return if we set the wait timer and it's reached If $n_msecexpire > 0 Then If $n_timer >= $n_msecexpire Then Return SetError(2, 0, 0) EndIf EndIf Sleep(250) WEnd If Not IsArray($a_objret) Then Return SetError(3, 0, 0) EndIf ; set normal _ieloadwait default If $n_msecexpire < 1 Then $n_msecexpire = -1 For $i = 1 To UBound($a_objret) - 1 _IELoadWait($a_objret[$i], 0, $n_msecexpire) Next ; this could return multiple if there is more than 1 tab ; with the same url/title for $s_type passed Return $a_objret EndFunc ; returns all the instances of tabs matching type/str criteria Func __IE_GetTabObjs(ByRef $o_obj, $s_str = "", $s_type = "") If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $a_otabs[101], $i_add = 0, $i_next = 1, $o_ieattach $s_type = StringLower($s_type) While 1 ; we start at instance 1 and enum as we find more instances $o_ieattach = _IEAttach($o_obj, "instance", $i_next + 1) If @error = $_IEStatus_NoMatch Or Not IsObj($o_ieattach) Then ExitLoop ; control array size If Mod($i_add + 1, 100) = $i_add Then ReDim $a_otabs[$i_add + 101] EndIf Switch StringLower($s_type) Case "url" If String(Execute("$o_ieattach.locationurl")) = $s_str Then $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndIf Case "title" If WinGetText(String(Execute("$o_ieattach.hwnd"))) = $s_str Then $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndIf Case Else $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndSwitch $i_next += 1 WEnd If $i_add = 0 Then Return SetError(2, 0, 0) ReDim $a_otabs[$i_add + 1] $a_otabs[0] = $i_add Return $a_otabs EndFunc
    1 point
  7. The .Navigate method has no return value, so you must attach to the new IE on your own. I'd suggest that you put the _IEAttach into a loop, waiting for the new window to be found. Something like: While 1 $oIE2 = _IEAttach("http://www.autoitscript.com/forum/", "url") If IsObj($oIE2) Then ExitLoop WEND SmOke_N's method will work too. Dale
    1 point
  8. I've messed with this before a couple of years ago. I had to enum through the IE objects and match it up that way.
    1 point
  9. dear @StefanoVR 1. please read: >How to post code on the forum 2. Function header should be before function declaration ; #FUNCTION# ==================================================================================================================== ; Name...........: My_SQL_Connessione ; Description ...: Si collega al database SQL usando i parametri forniti ; Syntax.........: My_SQL_Connessione ($sPercorso,$sDatabase,$sUser,$sPassword) ; Parameters ....: $sPercorso - Stringa contenente il percorso di rete del server ; $sDatabase - Stringa contenente il nome del datatabase SQL ; $sUser - Stringa contenente il nome dell' utente ; $sPassword - Stringa contenente la password ; Return values .: Success - Restituisce l' oggetto connessione - viene settato l' errore in caso di errore ; Failure - Returns 0 and sets @error ad 1 in caso la connessione non vada a buon fine ; =============================================================================================================================== Func My_SQL_Connessione($sPercorso, $sDatabase, $sUser, $sPassword) _SQL_RegisterErrorHandler() Local $oConnessioneSQL = _SQL_Startup() If $oConnessioneSQL = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg()) If _sql_Connect(-1, $sPercorso, $sDatabase, $sUser, $sPassword) = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg(), 30) _SQL_Close() Return SetError(1, 0, 1) EndIf Return $oConnessioneSQL EndFunc ;==>My_SQL_Connessione 3. use Tidy before you post code. 4. here you have connection string: $ADODBHandle.Open("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") ;<==Connect with required credentials so you are using $ADODBHandle.Open("DRIVER={SQL Server}; I use: $ADODBHandle.Open("PROVIDER=SQLNCLI10; check my updated _sql.au3 btw. my updated _sql.au3 is still in BETA version. and to see any special effect you must install MS sqlncli.... _sql.au3
    1 point
  10. If GUICtrlRead($input1) <> "" Then ; this should work If not GUICtrlRead($input1) = "" Then ; this may also work
    1 point
  11. water

    Help with check fields

    If you need to make sure that spaces are treated as empty as well I suggest: #include <StringConstants.au3> If StringStripWS(GUICtrlRead($input1), $STR_STRIPALL) = "" Then
    1 point
  12. Your telling autoit that the first window is $oIE and so when you say $oIE.quit it closes the first window Name the second window something else like $SecondIE or $NotoIE
    1 point
  13. So your code snipet is this Const $ie_new_in_tab=0x0800 $oIE = _IECreate("http://www.autoitscript.com") $oIE.Navigate("http://www.autoitscript.com/forum/", $ie_new_in_tab) $oIE.Quit The second line $oIE = is the important part. You've said I want this IE window to be marked as this variable $oIE so when in your last line you say $oIE.Quit your telling autoit to close that first window you specified to be the variable $oIE The second window you open DOES NOT have a variable name for you to tell autoit that you want to close it. You need to tell autoit what the second window is called before you can do anything with it.
    1 point
  14. >Here's some reading to do.
    1 point
  15. Looks like even though you navigated to the new /forums page $oIE is still set to autoitscript.com so to close out the new game you need to specify it a variable and tell autoit to close that $var
    1 point
  16. #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;### OP's code - Start $hGui = GUICreate("Browser-test",500,500,0,0) $Obj = ObjCreate("Shell.Explorer.2") $CtrlObj = GUICtrlCreateObj($Obj,-1,-1,500,500) GUISetState (@SW_SHOW) _IENavigate($Obj, "http://test.xjz.nl/") _IELoadWait($Obj) ;### OP's code - End ;[n][0] = object id string name ;[n][1] = object (by _iegetobjbyid) ;[n][2] = clicked (bool, 1 = true, 0 = false) Global $ga_ObjsOnClick Global $go_ObjDoc = $obj.document Global $gs_ObjId = "closeWindow" ; I'd probably create more preceise functions to add to/remove ; from the global array to make it somewhat more dynamic, ; something like the below _myIE_AddClickObjData($Obj, $gs_ObjId, $ga_ObjsOnClick) ObjEvent($go_ObjDoc, "shutdown_", "HTMLDocumentEvents2"); While GUIGetMsg() <> $GUI_EVENT_CLOSE If _myIE_IsClickObjBool($ga_ObjsOnClick, $gs_ObjId) Then MsgBox(64 + 262144, "Clicked", "You clicked closeWindow object.") ; clear out bool _myIE_ResetClickObjBool($ga_ObjsOnClick, $gs_ObjId) exit; EndIf WEnd Volatile Func shutdown_onclick($o_obj) If Not IsObj($o_obj) Then Return If String(Execute("$o_obj.type")) <> "click" Then Return ; obviously you'd have something like objects by name/id/class/etc ; system setup in an array or multiple functions to achieve your goal ; where you're not interfering with the callback (with something like ; a msgbox call) ; for simplicity, I'm only going to show an id method ; I would normally iterate through all of what I felt needed to be ; but I know this works, so I'll keep it simple Local $o_src = $o_obj.srcElement Local $o_psrc = $o_obj.srcElement.parentNode Local $o_id = $o_src.id Local $o_objelem = $o_src If Not $o_id Then $o_id = $o_psrc.id $o_objelem = $o_psrc EndIf For $iobjs = 0 To UBound($ga_ObjsOnClick) - 1 If String($o_id) = $ga_ObjsOnClick[$iobjs][0] Then ; I'm not sold on using this ID method unless you'll religously ; check the id's yourself with _IEGetObjByID when pages load and reload If $ga_ObjsOnClick[$iobjs][1] = $o_objelem Then $ga_ObjsOnClick[$iobjs][2] = 1 Return EndIf EndIf Next EndFunc ; these functions were primarily for my own amusement Func _myIE_AddClickObjData(ByRef $o_obj, $s_idstr, ByRef $a_objsclick) If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $o_id = _IEGetObjById($o_obj, $s_idstr) If Not IsObj($o_id) Then Return SetError(2, 0, 0) EndIf Local $i_ub = UBound($a_objsclick) If Not $i_ub Then Dim $a_objsclick[1][3]; ugh, magic numbers... fun (Not!) Else ReDim $a_objsclick[$i_ub + 1][UBound($a_objsclick)] EndIf $a_objsclick[$i_ub][0] = $s_idstr $a_objsclick[$i_ub][1] = $o_id $a_objsclick[$i_ub][2] = 0 Return 1 EndFunc Func _myIE_ResetClickObjBool(ByRef $a_objsclick, $v_index = 0) If IsObj($v_index) Then For $i = 0 To UBound($a_objsclick) - 1 If $a_objsclick[$i][1] = $v_index Then $a_objsclick[$i][2] = 0 Return EndIf Next ElseIf IsInt($v_index) Then ;normally I'd check scope, but meh $a_objsclick[$v_index][2] = 0 Else For $i = 0 To UBound($a_objsclick) - 1 If $a_objsclick[$i][0] = $v_index Then $a_objsclick[$i][2] = 0 Return EndIf Next EndIf EndFunc Func _myIE_IsClickObjBool(ByRef $a_objsclick, $v_index) If IsObj($v_index) Then For $i = 0 To UBound($a_objsclick) - 1 If $a_objsclick[$i][1] = $v_index Then Return $a_objsclick[$i][2] EndIf Next ElseIf IsInt($v_index) Then ;normally I'd check scope, but meh Return $a_objsclick[$v_index][2] Else For $i = 0 To UBound($a_objsclick) - 1 If $a_objsclick[$i][0] = $v_index Then Return $a_objsclick[$i][2] EndIf Next EndIf EndFunc
    1 point
  17. Without direct access to the website, there's no way to be specific on what is wrong. I assume you'll need to debug data in the event call function (the onclick one). Probably something to do with the parentnode area. I did all of that generic as I stated in my comments within the code, you would need to spend quite some time putting in ever variation within there. But I would start with if it even shows up within that event first.
    1 point
  18. llc

    Themes for SciTE

    Monokai theme SCITE vs ST2 google drive Download edit 28/03/2020; updated links
    1 point
  19. I'm curious on what's expected here. I do not see an event for "onclick" set for that DIV-ID. What exactly do you think ObjEvent does? You'll need this for a reference: http://msdn.microsoft.com/en-us/library/hh801967(v=vs.85).aspx And probably specifically this from that: http://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx Do a search for ObjEvent and HTMLDocumentEvents2, I bet someone has an example.
    1 point
  20. Your API call is wrong. Should be so: Local $iRas = DllCall("Rasapi32.dll", "dword", "RasGetConnectStatusW","handle",$yourhandle,"ptr",DllStructGetPtr($tRASStatus)) Remember set the dwSize before the call. Saludos
    1 point
  21. Melba doesn't the topic title say add columns ? #include <Array.au3> Local $aArray[3][2] = [["Item 0 - 0", "Item 0 - 1"],["Item 1 - 0", "Item 1 - 1"],["Item 2 - 0", "Item 2 - 1"]] Local $aFill[3] = ["Add Item 2 - 0", "Add Item 2 - 1", "Add Item 2 - 2"] _ArrayDisplay($aArray) $u = UBound($aArray) $c = UBound($aArray, 2) ReDim $aArray[$u][$c + 1] For $i = 0 to $u - 1 $aArray[$i][$c] = $aFill[$i] Next _ArrayDisplay($aArray, "Redimmed") ; OR Local $aArray[3][2] = [["Item 0 - 0", "Item 0 - 1"],["Item 1 - 0", "Item 1 - 1"],["Item 2 - 0", "Item 2 - 1"]] ; Local $sFill = "Add Item 2 - 0|Add Item 2 - 1|Add Item 2 - 2" Local $aFill[1][3] = [["Add Item 2 - 0","Add Item 2 - 1","Add Item 2 - 2"]] _ArrayTranspose($aArray) ; _ArrayAdd($aArray, $sFill) _ArrayAdd($aArray, $aFill) _ArrayTranspose($aArray) _ArrayDisplay($aArray, "Concatenated")
    1 point
×
×
  • Create New...