Leaderboard
Popular Content
Showing content with the highest reputation on 11/19/2014 in all areas
-
Skype UDF v1.2 Introduction :Skype4COM represents the Skype API as objects, with :methodspropertieseventscollectionscachingSkype4COM provides an ActiveX interface to the Skype API. Develop for Skype in a familiar programming environment, such as Visual Studio or Delphi, using preferred scripting languages such as VBScript, PHP, or Javascript. Requirements : Skype 3.0+ must be installedWindows 2000, XP+ Update : Version 1.2 Fixed _Skype_ProfileGetHandle function Version 1.1 Fixed _Skype_ChatGetBookmarked function Added missing _Skype_ChatGetTopic function Version 1.0 Fixed _Skype_ChatGetAll function Version 0.9 Fixed Mute value returned by the _Skype_OnEventMute callback function Version 0.8 Error ObjEvent is set if none already set Version 0.7 Changed _Skype_GetChatActive to _Skype_GetChatAllActive Version 0.6 Added _Skype_GetCache Added _Skype_SetCache Changed Skype_Error function Minor bugs fixed Version 0.5 Fixed _Skype_ChatCreate Version 0.4 Fixed _Skype_ChatGetMessages Fixed "Skype - SciTE.au3" script Version 0.3 Minor changes Updated Skype in AutoIt example Version 0.2 Fixed _Skype_ChatAddMembers Various bugs fixed _Functions list : (346) Example GUI : Notes : Skype's access control must be accepted manually :After running the example script, click on the "Allow access" button of SkypeThis version is NOT complete If you are running on a 64 bits OS, add this line to your script : #AutoIt3Wrapper_UseX64=n Attachments :Pack (UDF + ExampleGUI)Version 1.2 : Skype-UDF_1.0.0.2.zip Examples : (put them into the "Example folder")-Answers to incomming calls even if you are already in a call : Auto Answer.au3-Shows how to use the OnMute event : Mute Event.au3 Happy coding1 point
-
Hello! Here is a short example to get the notification when the monitors are going to sleep. Have fun! #NoTrayIcon Global Const $WM_POWERBROADCAST = 0x0218 Global Const $PBT_POWERSETTINGCHANGE = 0x8013 Global Const $WM_SYSCOMMAND = 0x0112 Global Const $SC_MONITORPOWER = 0xF170 Global Const $MONITOR_ON = -1 Global Const $MONITOR_OFF = 2 Global Const $MONITOR_STANDBY = 1 Global Const $tagGUID = "struct; ulong Data1;ushort Data2;ushort Data3;byte Data4[8]; endstruct" Global Const $tagPOWERBROADCAST_SETTING = $tagGUID & ";DWORD DataLength;DWORD Data;" Global Const $DEVICE_NOTIFY_WINDOW_HANDLE = 0 Global Const $DEVICE_NOTIFY_SERVICE_HANDLE = 1 Global Const $GUID_CONSOLE_DISPLAY_STATE = "{6fe69556-704a-47a0-8f24-c28d936fda47}" ; Win8 Global Const $GUID_MONITOR_POWER_ON = "{02731015-4510-4526-99e6-e5a17ebd1aea}" ; Vista and Win7 Global $hGui = GUICreate("Gui for registering Windows Message", 600, 400) GUIRegisterMsg($WM_POWERBROADCAST, "_PowerSettingNotification") Global $nBtnSleep = GUICtrlCreateButton("Hey monitors, please sleep!", 50, 50, 500, 100) GUICtrlSetFont(-1, 25) Global $nEdit = GUICtrlCreateEdit("Informations:", 50, 180, 500, 200, 0x200840) ;$WS_VSCROLL | $ES_AUTOVSCROLL | $ES_READONLY GUICtrlSetFont(-1, 14) Global $hNotify If @OSBuild >= 5000 And @OSBuild < 9000 Then $hNotify = _RegisterPowerSettingNotification($hGui, $GUID_MONITOR_POWER_ON) ElseIf @OSBuild >= 9000 Then $hNotify = _RegisterPowerSettingNotification($hGui, $GUID_CONSOLE_DISPLAY_STATE) Else MsgBox(64, "Sorry", "PowerSettingNotification is only supported by Windows Vista and above!") Exit EndIf If @error Then MsgBox(16, "Sorry", "PowerSettingNotification failed with error: " & @error & " - " & @extended & " !") Exit EndIf GUISetState() Global $iMsg Do $iMsg = GUIGetMsg() If $iMsg = $nBtnSleep Then DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hGui, 'int', $WM_SYSCOMMAND, 'int', $SC_MONITORPOWER, 'int', $MONITOR_OFF) Until $iMsg = -3 _UnregisterPowerSettingNotification($hNotify) Func _PowerSettingNotification($hWndGUI, $MsgID, $wParam, $lParam) Local $tSetting, $iSetting Local $sDateNow, $sTimeNow, $sMsg If $wParam = $PBT_POWERSETTINGCHANGE Then $tSetting = DllStructCreate($tagPOWERBROADCAST_SETTING, $lParam) $iSetting = DllStructGetData($tSetting, "Data") $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC Switch $iSetting Case 2 ;The display is dimmed --> Win8 and above $sMsg = $sDateNow & " " & $sTimeNow & " : " & "The display is dimmed now" ConsoleWrite("> " & $sMsg & @CRLF) GUICtrlSetData($nEdit, GUICtrlRead($nEdit) & @CRLF & $sMsg) ;do some stuff here Case 1 ;The monitor in on $sMsg = $sDateNow & " " & $sTimeNow & " : " & "The display is on now" ConsoleWrite("> " & $sMsg & @CRLF) GUICtrlSetData($nEdit, GUICtrlRead($nEdit) & @CRLF & $sMsg) ;do some stuff here Case 0 ;The monitor in off $sMsg = $sDateNow & " " & $sTimeNow & " : " & "The display is off now" ConsoleWrite("> " & $sMsg & @CRLF) GUICtrlSetData($nEdit, GUICtrlRead($nEdit) & @CRLF & $sMsg) ;do some stuff here EndSwitch EndIf EndFunc ;==>_PowerSettingNotification Func _RegisterPowerSettingNotification($hGui, $GUID) Local $aRet Local $tGuid = DllStructCreate($tagGUID) $aRet = DllCall('ole32.dll', 'long', 'CLSIDFromString', 'wstr', $GUID, 'struct*', $tGuid) If @error Or $aRet[0] <> 0 Then Return SetError(1, @error, 0) $aRet = DllCall("user32.dll", "handle", "RegisterPowerSettingNotification", "handle", $hGui, "struct*", $tGuid, "DWORD", $DEVICE_NOTIFY_WINDOW_HANDLE) If @error Or $aRet[0] = 0 Then Return SetError(2, @error, 0) Return $aRet[0] EndFunc ;==>_RegisterPowerSettingNotification Func _UnregisterPowerSettingNotification($hNotify) Local $aRet = DllCall("user32.dll", "BOOL", "UnregisterPowerSettingNotification", "handle", $hNotify) If @error Or $aRet[0] = 0 Then Return SetError(1, @error, 0) Return $aRet[0] EndFunc ;==>_UnregisterPowerSettingNotification1 point
-
Non-standard naming convention and trying to hit a button
trdunsworth reacted to SmOke_N for a topic
It gives you the function name: onclick="bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')" ;I'd try using something like: Execute("$oFrame2.document.parentwindow.eval(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;or Execute("$oFrame2.document.parentwindow.execScript(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;If that doesn't work: Execute("$oFrame2.parentwindow.eval(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;or Execute("$oFrame2.parentwindow.execScript(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;And If that doesn't work: Execute("$oFrame2.document.eval(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;or Execute("$oFrame2.document.execScript(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;And if still that doesn't work: Execute("$oFrame2.eval(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")") ;or Execute("$oFrame2.execScript(""bClicked('submenu.htm?ref=OOPMENU', 'Orders Of Protection')"")")1 point -
Non-standard naming convention and trying to hit a button
trdunsworth reacted to Inververs for a topic
Or $oIe.document.querySelector('button[submitname="Orders Of Protection"]').click() IE 9+ required.1 point -
Non-standard naming convention and trying to hit a button
trdunsworth reacted to jdelaney for a topic
Grab all buttons, and loop through until one of the attributes matches what's present.1 point -
Do.... Until WinActivate stuck (nested in If... Then)
SorryButImaNewbie reacted to alienclone for a topic
instead of waiting for a window to be active, wait for it to exist or is visible, then activate it. also if you put this tray icon option in, you can hover over the tray icon for your script while it is running and see the exact line number that your script is running, or hanging on. Opt("TrayIconDebug", 1)1 point -
Context Menu on Hotkey
Xandy reacted to ResNullius for a topic
How about something like this, based on Holger's example @ Creates a tray menu that will popup on the screen wherever your cursor is when you press your hotkey combo. I used the concept to create an app that would paste predefined items into different programs #include <Constants.au3> Opt("TrayMenuMode", 1) Opt("WinTitleMatchMode", 4) Global Const $TPM_BOTTOMALIGN = 0x0020 $item1 = TrayCreateItem("item_1") $item2 = TrayCreateItem("item_2") TrayCreateItem("") ; spacer $aboutItem = TrayCreateItem("About") $exitItem = TrayCreateItem("Exit") HotKeySet("^+v", "ShowTrayMenu") ; Ctrl + Shift + V While 1 $Msg = TrayGetMsg() Switch $Msg Case $item1 MsgBox(4096, "", "Item 1...") Case $item2 MsgBox(4096, "", "Item 2...") Case $exitItem ExitLoop Case $aboutItem MsgBox(4096, "Info", "Just for fun...") EndSwitch WEnd Exit Func ShowTrayMenu() Local $stPoint = DllStructCreate("int;int") DllCall("user32.dll", "int", "GetCursorPos", _ "ptr", DllStructGetPtr($stPoint)) DllCall("user32.dll", "int", "TrackPopupMenuEx", _ "hwnd", TrayItemGetHandle(0), _ "int", $TPM_BOTTOMALIGN, _ "int", DllStructGetData($stPoint, 1), _ "int", DllStructGetData($stPoint, 2), _ "hwnd", WinGetHandle("classname=AutoIt v3"), _ "ptr", 0) EndFunc ;==>ShowTrayMenu1 point -
hello peggy, welcome to AutoIt and to the forum! you tell us. what exactly does not work? do you get any error messages? have you checked @error or the return values of your function calls? but that's for next time. for now, your issues are: 1) syntax of HotKeySet() - the name of the function needs not the brackets. like this: HotKeySet("{RIGHT}" , "RIGHT") HotKeySet("{LEFT}" , "LEFT") 2) the variable $set is used globally, but is not declared as such, so any function treats it as a different variable. add this at the top of your script: Global $set you may have other issues as well, but start by fixing these and see how it goes.1 point
-
Send key ( Ctrl+A) Help Me!!
nguyenvanhieu01 reacted to Melba23 for a topic
nguyenvanhieu01, Why not use the Send function directly? M23 Edit: Just seen the "Inactive" mention. Have you tried ControlSend with an empty controlID field?1 point -
Did you try registering the dll then using dllopen? This of course is a guess, no code, no dll, no operating system, leads to nothing but guessing.1 point
-
Let's say I have two separate IE windows open, without even keeping in mind that other applications could have IE instances open as well. In the first, I only have: http://autoitscript.com for the url and no other tabs The second I have: http://google.com for the url And I have a tab: http://autoitscript.com If I use _IEAttach("http://autoitscript.com", "url"), which of the window objects am I grabbing the object instance from? In addition, debug mode with that could be horrible too, you don't know how many times I forget to close the IE window I'm testing code in before running my code again! IMO, the proper way to actually grab the "correct" instance of the tab would be to use _IEAttach() with instance, eg. _IEAttach("", "instance", number of tab I want starting from 0 (original page)) Then to match up either url/hwnd/title/innertext/etc. That's what the code I provided does, it matches the instance, then it matches your criteria (url, title, or just return anything with a blank string for 3 param). It's quick and dirty, but it works. The reason I safeguard code like this, is because I know how fickle IE really is. Doesn't matter what version. If I'm going to do work in it, I need my code reliable at the very least, to not be the reason why something is failing.1 point
-
This is why I took the time to create the array, functions, and the comments I did. They were supposed to give you an idea on how to approach adding more items for onclick, monitoring as many items as you needed, and the ability to reset them and continue on with the rest of your script. 1. $ga_ObjsOnClick (note the $ga <-) the "a" there represents an array variable, I labled the rest ObjsOnClick, with OnClick being the event I wanted to monitor, it's a reference visually for myself. This array allows you to add multiple items for "onclick" using the "add" function I've provided for "click" events. 2. The functions: _myIE_AddClickObjData, _myIE_ResetClickObjBool, _myIE_IsClickObjBool. These are used to add, reset, and validate if an event of "onclick/click" was fired. If you were going to add multiple event items for "click", you'd simply use the _myIE_AddClickObjData, it will control the size of the array of data and allow you to continuously add items. You'd need to monitor them by either a unique "id" (user-agent) or by the "id" object (_IEGetObjById). You can create more arrays for the different events, you can create more functions for the different events. You could write a multi-purpose udf that would be much less functions using strings and a container array that would take care of the several event types. This whole concept could be done much more efficient, but I don't feel like writing an entire udf on it. For your convenience, I've changed the shutdown_onclick function to add all the different events that HTMLDocumentEvents2 will return to a multi-purpose function. Hopefully this provides you some sort of roadmap and a aha! moment. I'm half asleep as I write this, so I hope it makes sense. Good luck. #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, "_myevent_", "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 ; these volatile functions would be from all the options in ; the _mymultipurposeevent_functionhandler function Volatile Func _myevent_afterupdate($o_obj) _mymultipurposeevent_functionhandler($o_obj) EndFunc Volatile Func _myevent_beforeactivate($o_obj) _mymultipurposeevent_functionhandler($o_obj) EndFunc Volatile Func _myevent_onclick($o_obj) _mymultipurposeevent_functionhandler($o_obj) EndFunc Func _mymultipurposeevent_functionhandler($o_obj) If Not IsObj($o_obj) Then Return Local $s_objtype = String(Execute("$o_obj.type")) If Not $s_objtype 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 Switch StringLower($s_objtype) Case "afterupdate" ; onafterupdate ; put action data here Case "beforeactivate" ; onbeforeactivate ; put action data here Case "beforeeditfocus" ; onbeforeeditfocus ; put action data here Case "beforeupdate" ; onbeforeupdate ; put action data here Case "cellchange" ; onbeforecellchange ; put action data here Case "click" ; onclick ; here is action data 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 Case "contextmenu" ; oncontextmenu ; put action data here Case "dataavailable" ; ondataavailable ; put action data here Case "datasetchanged" ; ondatasetchanged ; put action data here Case "dblclick" ; ondblclick ; put action data here Case "dragstart" ; ondragstart ; put action data here Case "errorupdate" ; onerrorupdate ; put action data here Case "focusin" ; onfocusin ; put action data here Case "focusout" ; onfocusout ; put action data here Case "help" ; onhelp ; put action data here Case "keypress" ; onkeypress ; put action data here Case "mousedown" ; onmousedown ; put action data here Case "mousemove" ; onmousemove ; put action data here Case "mouseout" ; onmouseout ; put action data here Case "mouseover" ; onmouseover ; put action data here Case "mouseup" ; onmouseup ; put action data here Case "mousewheel" ; onmousewheel ; put action data here Case "ondatasetcomplete" ; onondatasetcomplete ; put action data here Case "onkeyup" ; ononkeyup ; put action data here Case "propertychange" ; onpropertychange ; put action data here Case "readystatechange" ; onreadystatechange ; put action data here Case "rowenter" ; onrowenter ; put action data here Case "rowexit" ; onrowexit ; put action data here Case "rowsdelete" ; onrowsdelete ; put action data here Case "rowsinserted" ; onrowsinserted ; put action data here Case "selectionchange" ; onselectionchange ; put action data here Case "selectstart" ; onselectstart ; put action data here Case "stop" ; onstop ; put action data here EndSwitch 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 EndFunc1 point
-
I'm humbled, but isn't that the point witting code? So the next guy, including yourself can make sence if it?1 point
-
odd or even?
ahmeddzcom reacted to weaponx for a topic
$number = 4 If NOT Mod($number ,2) Then ;Even MsgBox(0,"",$number & " is even") Else ;Odd MsgBox(0,"",$number & " is odd") EndIf1 point