Jump to content

Leaderboard

Popular Content

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

  1. The only way I can think of would be to use the Reg* funcs to change it in the registry when starting the script, and then change it back when closing the script Not tried so no assurance about this Edit http://stackoverflow.com/questions/23570606/change-cache-storage-location-for-individual-webbrowser-control-instances
    1 point
  2. TheSaint

    Help on Excel variable

    No worries, I was just curious, especially over your possible use of numbers in your Excel document rather than the words you eventually get. It seemed to me, that a step may have been able to be saved, unless you were using formulas for those cells. We won't laugh. A chuckle perhaps. We all started somewhere, and I can remember many milestones of enlightenment on my programming journey. So don't be ashamed to show us. All of us are still learning. @Jfish - Even though my relatively recent (probably previous) Help file doesn't have that particular function, I did realize it was something that had been edited, but I like to be sure of all relevant aspects when dealing with beginners.
    1 point
  3. Ok, yes I was bored... #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, "https://www.whatismybrowser.com/what-is-my-user-agent") _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 ; 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, "user-agent", $ga_ObjsOnClick) ObjEvent($go_ObjDoc, "shutdown_", "HTMLDocumentEvents2"); While GUIGetMsg() <> $GUI_EVENT_CLOSE If _myIE_IsClickObjBool($ga_ObjsOnClick, "user-agent") Then MsgBox(64 + 262144, "Clicked", "You clicked user-agent object.") ; clear out bool _myIE_ResetClickObjBool($ga_ObjsOnClick, "user-agent") 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_psrc = $o_obj.srcElement.parentNode For $iobjs = 0 To UBound($ga_ObjsOnClick) - 1 If String($o_psrc.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_psrc 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
  4. _IECreateEmbedded creates a Webbrowser object (shell.explorer.2) #include <GUIConstantsEx.au3> #include <IE.au3> $oIE = _IECreateEmbedded() GUICreate("Embedded Web control Test", 640, 200) GUICtrlCreateObj($oIE, 10, 50, 600, 100) $label = GUICtrlCreateLabel("", 10, 10, 500, 25) GUISetState() $oIE.Navigate2("shell:cache") GuiCtrlSetData($label, $oIE.locationurl) While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd
    1 point
  5. mikell

    TimerDiff behaving weird

    There is a nice typo : $Timer=TimerInit()
    1 point
  6. When you use this solution, the following will stop working: $oButton1 = _IEGetObjById($Obj, '_buttonId'); $oEvtButton1 = ObjEvent($oButton1, "clickedOnButton_"); Func clickedOnButton_onclick() MsgBox(0, "Yo", "Clicked on Button.") EndFunc Anyone know why that is? onClick listener stops working on IE8+ Thanks, Lion H
    1 point
  7. @Jos Excellent example, but the window appears for a brief period of time, to avoid this, we can use "WH_CBT", see example below: #include <WinAPI.au3> #cs HCBT_MOVESIZE = 0 HCBT_MINMAX = 1 HCBT_QS = 2 HCBT_CREATEWND = 3 HCBT_DESTROYWND = 4 HCBT_ACTIVATE = 5 HCBT_CLICKSKIPPED = 6 HCBT_KEYSKIPPED = 7 HCBT_SYSCOMMAND = 8 HCBT_SETFOCUS = 9 #ce Global Const $HCBT_ACTIVATE = 5 Global $MsgBox_Title Global $MsgBox_Text Global $MsgBox_X Global $MsgBox_Y Global $MsgBox_W Global $MsgBox_H OnAutoItExitRegister("Terminate") ;----> Global $hCBTPROC_CALLBK = DllCallbackRegister("_WH_CBT", "int", "int;int;int") If Not $hCBTPROC_CALLBK Then MsgBox(4096, "Error!", "DllCallbackRegister fail!") Exit EndIf Global $hCBTPROC_HOOK = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hCBTPROC_CALLBK), 0, _WinAPI_GetCurrentThreadId()) If Not $hCBTPROC_HOOK Then DllCallbackFree($hCBTPROC_CALLBK) MsgBox(4096, "Error!", "_WinAPI_SetWindowsHookEx fail!") Exit EndIf ;<---- ; _MessageBox(10, 10, Default, Default, 0, "Test", "This is just a test :)", 0) ;move the MsgBox to 10,10 ; Func _MessageBox($iMsgBox_X, $iMsgBox_Y, $iMsgBox_W, $iMsgBox_H, $iMsgBox_P1, $iMsgBox_P2, $iMsgBox_P3, $iMsgBox_P4 = 0, $iMsgBox_P5 = 0) $MsgBox_Title = $iMsgBox_P2 $MsgBox_Text = $iMsgBox_P3 $MsgBox_X = $iMsgBox_X $MsgBox_Y = $iMsgBox_Y $MsgBox_W = $iMsgBox_W $MsgBox_H = $iMsgBox_H MsgBox($iMsgBox_P1, $iMsgBox_P2, $iMsgBox_P3, $iMsgBox_P4, $iMsgBox_P5) EndFunc ;==>_MessageBox Func _WH_CBT($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hCBTPROC_HOOK, $nCode, $wParam, $lParam) EndIf Switch $nCode Case $HCBT_ACTIVATE If WinGetTitle(HWnd($wParam)) = $MsgBox_Title Then ;TrayTip("$HCBT_ACTIVATE", "Win title: " & WinGetTitle(HWnd($wParam)), 20, 1) WinMove(HWnd($wParam), $MsgBox_Text, $MsgBox_X, $MsgBox_Y, $MsgBox_W, $MsgBox_H) EndIf EndSwitch Return _WinAPI_CallNextHookEx($hCBTPROC_HOOK, $nCode, $wParam, $lParam) EndFunc ;==>_WH_CBT Func Terminate() _WinAPI_UnhookWindowsHookEx($hCBTPROC_HOOK) Exit EndFunc ;==>Terminate JS
    1 point
  8. Something like this? #include <WinAPISys.au3> Global $WM_TIMER = 0x0113 Global $hTimerProc Global $iTimerID Global $MsgBox_Title Global $MsgBox_Text Global $MsgBox_X Global $MsgBox_Y Global $MsgBox_W Global $MsgBox_H ; _MessageBox(10, 10, Default, Default, 0, "Test", "This is just a test :)", 0) ;move the MsgBox to 10,10 ; Func _MessageBox($iMsgBox_X, $iMsgBox_Y, $iMsgBox_W, $iMsgBox_H, $iMsgBox_P1, $iMsgBox_P2, $iMsgBox_P3, $iMsgBox_P4 = 0, $iMsgBox_P5 = 0) $hTimerProc = DllCallbackRegister('_MoveMsgBox', 'none', 'hwnd;uint;uint_ptr;dword') $iTimerID = _WinAPI_SetTimer(0, 0, 50, DllCallbackGetPtr($hTimerProc)) $MsgBox_Title = $iMsgBox_P2 $MsgBox_Text = $iMsgBox_P3 $MsgBox_X = $iMsgBox_X $MsgBox_Y = $iMsgBox_Y $MsgBox_W = $iMsgBox_W $MsgBox_H = $iMsgBox_H MsgBox($iMsgBox_P1, $iMsgBox_P2, $iMsgBox_P3, $iMsgBox_P4, $iMsgBox_P5) ; kill timer in case still there. _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) EndFunc ;==>_MessageBox ; Func _MoveMsgBox($hWnd, $iMsg, $iTimerID, $iTime) #forceref $hWnd, $iMsg, $iTimerId, $iTime $rc = WinMove($MsgBox_Title, $MsgBox_Text, $MsgBox_X, $MsgBox_Y, $MsgBox_W, $MsgBox_H) ; kill timer in case move was successfull. If $rc Then _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) EndIf EndFunc ;==>_MoveMsgBox Jos
    1 point
×
×
  • Create New...