Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/30/2016 in all areas

  1. UEZ

    Ghost Interface

    Something like this here? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Global $hGUI = GUICreate("Ghost", 100, 50, @DesktopWidth - 100, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0x808080) Global $iLbl = GUICtrlCreateLabel("Hover me :-)", 10, 10) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState() AdlibRegister("HoverChk", 50) Do Until GUIGetMsg() = -3 AdlibUnRegister("HoverChk") GUIDelete() Func HoverChk() Local $iFadeIn = 8, $iFadeOut = 64 Local Static $iTransparency = 255 Local $aPos = WinGetPos($hGUI) If _WinAPI_PtInRectEx(MouseGetPos(0), MouseGetPos(1), $aPos[0], $aPos[1], $aPos[2] + $aPos[0] + 1, $aPos[3] + $aPos[1] + 1) Then If $iTransparency >= 0 Then $iTransparency -= $iFadeOut $iTransparency = $iTransparency < 0 ? 0 : $iTransparency WinSetTrans($hGUI, "", $iTransparency) EndIf Else If $iTransparency <= 255 Then $iTransparency += $iFadeIn $iTransparency = $iTransparency > 255 ? 255 : $iTransparency WinSetTrans($hGUI, "", $iTransparency) EndIf EndIf EndFunc
    3 points
  2. After AutoIt 3.3.12.0 the handling of COM errors has been "fixed". Now nested COM operations crash the script in case of an error even when there is a COM error handler. Edit: All 3 problems have been fixed in AutoIt 3.3.14.3. Here you find a fixed version of function _Excel_RangeFind. I simply removed all nestings and added the missing COM error hander: Another function that needed some modification is _Excel_BookOpen. It crashed when a workbook was opened using _Excel_BookOpen with parameter $bVisible = True, saved and then reopened. The following modification solves the problem: 2017/06/19: Another function that needed some modification is _Word_DocSaveAs. It doesn't work with Word 2013 or later as MS felt the urge to change the name of the save method from SaveAs to SaveAs2. The following modification solves the problem: Please tell me if you still have problems with this or any other function from the Excel or Word UDF!
    1 point
  3. ViciousXUSMC

    Beginners problem

    With VPN are you not getting access to an inside address that you otherwise do not have access too? All that matters is that you know an internal IP you can ping, not the IP your connecting with. Else if your checking your adapter IP's and looking to see if you have a VPN IP usually they are in the same subnet range so you can check for the "general" IP instead of the exact one. Example: Local IP = 192.168.1.15 VPN IP = 10.0.15.63 VPN Check If IP = 10.X.X.X then VPN is connected
    1 point
  4. Code rearranged a little bit: #NoTrayIcon #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;#include <GuiButton.au3> ;#include <GuiTab.au3> #include <EditConstants.au3> #include <GUIToolbar.au3> ;#include <ToolbarConstants.au3> #include <GUIImageList.au3> ;Opt("GUIOnEventMode", 1) Global $main _main() Func _main() $main = GUICreate("main", 368, 343, -1, -1, -1, -1) ;GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ;$ToolbarGUI = GUICreate('', 350, 62, 1, 1, $WS_CHILD, 0, $main) $Toolbar = _GUICtrlToolbar_Create($main, BitOR($BTNS_BUTTON, $BTNS_SHOWTEXT, $TBSTYLE_FLAT, $TBSTYLE_TOOLTIPS), $TBSTYLE_EX_DOUBLEBUFFER) $ToolbarImageList = _GUIImageList_Create(32, 32, 5, 1) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\mmc.exe", 0, 1) _GUIImageList_AddIcon($ToolbarImageList, "C:\Windows\System32\cmd.exe", 0, 1) _GUICtrlToolbar_SetImageList($Toolbar, $ToolbarImageList) _GUICtrlToolbar_AddString($Toolbar, 'MMC') _GUICtrlToolbar_AddString($Toolbar, 'CMD') _GUICtrlToolbar_AddButton($Toolbar, 10000, 0, 0) _GUICtrlToolbar_AddButton($Toolbar, 10001, 1, 1) _GUICtrlToolbar_SetButtonSize($Toolbar, 62, 50) _GUICtrlToolbar_SetMetrics($Toolbar, 0, 0, 1, 0) _GUICtrlToolbar_SetIndent($Toolbar, 1) _SendMessage($Toolbar, $TB_AUTOSIZE) GUICtrlCreateLabel('', 0, 63, 372, 1, $SS_ETCHEDHORZ) GUICtrlCreateButton("button", 248, 313, 100, 20, -1, -1) $tab = GUICtrlCreateTab(4, 70, 363, 226, -1, -1) GUICtrlCreateTabItem("Page 1") GUICtrlCreateTabItem("Page 2") GUICtrlCreateTabItem("") GuiRegisterMsg( $WM_NCACTIVATE, "WM_NCACTIVATE" ) ; Prevent child windows (for Tab items) in making main GUI title bar dimmed GUISetState(@SW_SHOW, $main) $pageOneGUI = GUICreate("", 352, 198, 9, 93, $WS_POPUP, $WS_EX_MDICHILD, $main) GUISetBkColor(0xCCFFCC) GUICtrlCreateGroup("Group", 6, 3, 341, 180, -1, -1) GUICtrlCreateEdit("this is an edit control", 15, 40, 325, 67, BitOR($ES_READONLY, $WS_VSCROLL), $WS_EX_CLIENTEDGE) GUICtrlCreateInput("This is an inputbox", 15, 130, 325, 20, -1, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW, $pageOneGUI) $pageTwoGUI = GUICreate("", 352, 198, 9, 93, $WS_POPUP, $WS_EX_MDICHILD, $main) GUISetBkColor(0xCCFFCC) $idButPage2 = GUICtrlCreateButton( "Button page 2", 10, 10, 100, 20 ) GUISetState( @SW_HIDE, $pageTwoGUI ) GUISwitch($main) While 1 Switch GUIGetMsg() Case $tab Switch GUICtrlRead( $tab ) Case 0 ; Page 1 GUISetState( @SW_HIDE, $pageTwoGUI ) GUISetState( @SW_SHOW, $pageOneGUI ) Case 1 ; Page 2 GUISetState( @SW_HIDE, $pageOneGUI ) GUISetState( @SW_SHOW, $pageTwoGUI ) EndSwitch Case $idButPage2 MsgBox( 0, "Page 2", "Button clicked", 0, $main ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #cs While 1 Sleep(100) WEnd #ce EndFunc ;==>_main Func _exit() Exit EndFunc ;==>_exit ; Prevent child windows (for Tab items) in making main GUI title bar dimmed Func WM_NCACTIVATE( $hWnd, $iMsg, $wParam ) If $hWnd = $main Then If Not $wParam Then Return 1 EndIf EndFunc The reason for message loop mode is just that I was too lazy to create all the functions.
    1 point
  5. You do not have write permission to this directory where AutoIt is installed. Either edit the file as administrator or copy the following code to your script Func _Excel_SheetCopyMoveEX($oSourceBook, $vSourceSheet = Default, $oTargetBook = Default, $vTargetSheet = Default, $bBefore = Default, $bCopy = Default) ; Error handler, automatic cleanup at end of function Local $oError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc") #forceref $oError Local $vBefore = Default, $vAfter = Default If Not IsObj($oSourceBook) Or ObjName($oSourceBook, 1) <> "_Workbook" Then Return SetError(1, 0, 0) If $vSourceSheet = Default Then $vSourceSheet = $oSourceBook.ActiveSheet If $oTargetBook = Default Then $oTargetBook = $oSourceBook If Not IsObj($oTargetBook) Or ObjName($oTargetBook, 1) <> "_Workbook" Then Return SetError(2, 0, 0) If $vTargetSheet = Default Then $vTargetSheet = 1 If $bBefore = Default Then $bBefore = True If $bCopy = Default Then $bCopy = True If Not IsObj($vSourceSheet) Then $vSourceSheet = $oSourceBook.Sheets($vSourceSheet) If @error Or Not IsObj($vSourceSheet) Then SetError(3, @error, 0) EndIf If Not IsObj($vTargetSheet) Then $vTargetSheet = $oTargetBook.Sheets($vTargetSheet) If @error Or Not IsObj($vTargetSheet) Then SetError(4, @error, 0) EndIf If $bBefore Then $vBefore = $vTargetSheet Else $vAfter = $vTargetSheet EndIf If $bCopy Then $vSourceSheet.Copy($vBefore, $vAfter) Else $vSourceSheet.Move($vBefore, $vAfter) EndIf If @error Then Return SetError(5, @error, 0) If $bBefore Then Return $oTargetBook.Sheets($vTargetSheet.Index - 1) Else Return $oTargetBook.Sheets($vTargetSheet.Index + 1) EndIf EndFunc ;==>_Excel_SheetCopyMoveEX and replace all function calls to _Excel_SheetCopyMove to _Excel_SheetCopyMoveEX so the modified version gets called.
    1 point
  6. It's a bug so it does not report @error correctly. Now it is: If @error Then Return SetError(5, 0, 0) but it needs to be: If @error Then Return SetError(5, @error, 0)
    1 point
  7. Well, if the array size is too large AutoIt will copy the data from the array to the gfx handle slower than 40 fps. To boost it you have to save it to a struct and use for example assembler or an external DLL by passing the struct and the gfx handle.
    1 point
  8. See this sharing memory example by GreenCan. There's also this, by ThisIsMe.
    1 point
  9. I've run plenty of scripts on VirtualBox and VMware, though never on Cloudify. You are talking about running the script inside the VM, not from the host trying to control the VM, right?
    1 point
  10. In case you need AscW() of all individual characters, StringToASCIIArray is there (not limited to ASCII despite the name).
    1 point
  11. UEZ

    Ghost Interface

    Check out 4th return array value of GUIGetCursorInfo
    1 point
  12. I assume you do this to keep your computer not getting locked another trick vbscript is to numlock on/off not converted to AutoIT code (I assume if mousemove gets blocked by policy its just a matter of time they block other tools) so far never seen getting wscript locked out by policy ' Function to prevent locking the screen Function BlinkNumlock() Dim WxhShell Set WxhShell = CreateObject("WScript.Shell") WxhShell.SendKeys "{NUMLOCK}" WxhShell.SendKeys "{NUMLOCK}" Set WxhShell = Nothing End Function
    1 point
  13. TurionAltec

    cmd with autoit

    "@comspec / c" is only needed when calling an internal cmd.exe command (like dir, del, type, etc). If the command being run is from an external program, like netstat.exe, it can be run on it's own. In this example I call netstat -n which will return quicker as it's showing just IP addresses, and not trying to resolve the name. Also, depending on what your script is doing, if it's waiting on the results, Using ProcessWaitClose is easier than continuously polling and concatenating the string. #include <Constants.au3> ConsoleWrite(_GetDOSOutput("netstat -n") & @CRLF) Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" ;$iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $iPID = Run($sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID, False, False) Return $sOutput EndFunc ;==>_GetDOSOutput That said, what is the OP looking for? Netstat will show connections, but not transfer of data. I have used AutoIT to interpret raw data coming out of "Tshark" (a CLI tool from Wireshark), but if you don't have a very specific filter to narrow down traffic, it will get quickly bogged down with all traffic on your PC.
    1 point
  14. So I've looked into it and it is indeed possible, though i argue not worth the effort. From what i found via google there's 2 ways to center inputbox and msgbox, source: How do I change the MessageBox location? I made a crude example with the hook method: #include <WinAPI.au3> #include <WinAPIDiag.au3> $HCBT_ACTIVATE = 5 Opt("GuiOnEventMode", 1) $hWnd = GUICreate("", 700, 320) GUISetOnEvent(-3, "_MyExit", $hWnd) GUICtrlCreateButton("MsgBox", 10, 10) GUICtrlSetOnEvent(-1, "_MsgBox") GUICtrlCreateButton("InputBox", 10, 40) GUICtrlSetOnEvent(-1, "_InputBox") ;~ $hProg = DllCallbackGetPtr( $pProg = DllCallbackRegister("WH_CBT", "LONG_PTR", "INT;UINT_PTR;LONG_PTR") GUISetState() While 1 Sleep(10) WEnd Func _MyExit() DllCallbackFree($pProg) Exit EndFunc Func _InputBox() Local $hHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($pProg), Null, _WinAPI_GetCurrentThreadId()) InputBox("title", "promt", "default") _WinAPI_UnhookWindowsHookEx($hHook) EndFunc Func _MsgBox() Local $hHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($pProg), Null, _WinAPI_GetCurrentThreadId()) MsgBox(0, "Title", "Message") _WinAPI_UnhookWindowsHookEx($hHook) EndFunc ;~ When the message box is about to be shown, ;~ centre the dialog Func WH_CBT($uMsg, $wParam, $lParam) If $uMsg < 0 Then Return _WinAPI_CallNextHookEx($hHook, $uMsg, $wParam, $lParam) EndIf Local $tagCBTACTIVATESTRUCT = "BOOL fMouse;HWND hWndActive" If ( $uMsg = $HCBT_ACTIVATE ) And ( Not ( $wParam = $hWnd ) ) Then ;~ in a HCBT_ACTIVATE message, wParam holds ;~ the handle to the messagebox Local $hwndMsgBox = $wParam Local $tCBTACTIVATESTRUCT = DllStructCreate($tagCBTACTIVATESTRUCT, $lParam) ;~ Just as was done in other API hook demos, ;~ position the dialog centered in the calling ;~ parent form Local $rc = _WinAPI_GetWindowRect($hwndMsgBox) Local $rc2 = _WinAPI_GetWindowRect($hWnd) $dlgWidth = $rc.Right - $rc.Left $dlgHeight = $rc.Bottom - $rc.Top $newLeft = $rc2.Left + ( ($rc2.Right - $rc2.Left)/2 - $dlgWidth/2 ) $newTop = $rc2.Top + ( ($rc2.Bottom - $rc2.Top)/2 - $dlgHeight/2 ) _WinAPI_MoveWindow($hwndMsgBox, $newLeft, $newTop, $dlgWidth, $dlgHeight) EndIf ;~ return False to let normal ;~ processing continue Return False EndFunc The above code was parsed mostly from: SetWindowsHookEx: Centre the API Message Box Also i found a possible other option using TaskDialogIndirect, but couldn't find it used in a autoit related thread and long story short i got sidetracked converting TASKDIALOGCONFIG structure to autoit dllstruct Anyway i hope some of this was useful to someone, especially @kashamalasha Credits to: MSDN, SetWindowsHookEx: Centre the API Message Box and _WinAPI_SetWindowsHookEx Example Edit: I made TaskDialogIndirect work. Special Thanks to @Danyfirex for the conversion of the TASKDIALOGCONFIG structure #include <WinAPI.au3> #include <WinAPIDiag.au3> #include <WinAPISys.au3> $HCBT_ACTIVATE = 5 Opt("GuiOnEventMode", 1) $hWnd = GUICreate("", 700, 320) GUISetOnEvent(-3, "_MyExit", $hWnd) GUICtrlCreateButton("TaskDialog", 10, 70) GUICtrlSetOnEvent(-1, "_TaskDialog") GUISetState() While 1 Sleep(10) WEnd Func _MyExit() Exit EndFunc Func _TaskDialog() Local $TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000;vista and above, see: https://msdn.microsoft.com/en-us/library/gg157196.aspx Local $TDCBF_OK_BUTTON = 0x0001 Local $TDCBF_YES_BUTTON = 0x0002 Local $TDCBF_NO_BUTTON = 0x0004 Local $TDCBF_CANCEL_BUTTON = 0x0008 Local $TDCBF_RETRY_BUTTON = 0x0010 Local $TDCBF_CLOSE_BUTTON = 0x0020 Local $tagTASKDIALOGCONFIG = "uint cbSize;hwnd hwndParent;handle hInstance;int dwFlags;int dwCommonButtons;ptr pszWindowTitle; ptr hMainIcon_pszMainIcon;ptr pszMainInstruction;ptr pszContent;uint cButtons;ptr pButtons;int nDefaultButton;uint cRadioButtons;ptr pRadioButtons;int nDefaultRadioButton;ptr pszVerificationText;ptr pszExpandedInformation;ptr pszExpandedControlText;ptr pszCollapsedControlText;ptr hFooterIcon_pszFooterIcon;ptr pszFooter;ptr pfCallback;LONG_PTR lpCallbackData;uint cxWidth;" Local $tagTASKDIALOG_BUTTON = "int nButtonID;ptr pszButtonText" Local $tTASKDIALOGCONFIG = DllStructCreate($tagTASKDIALOGCONFIG) $tTASKDIALOGCONFIG.cbSize = DllStructGetSize($tTASKDIALOGCONFIG) $tTASKDIALOGCONFIG.hwndParent = $hWnd $tTASKDIALOGCONFIG.hInstance = Null $tTASKDIALOGCONFIG.dwFlags = $TDF_POSITION_RELATIVE_TO_WINDOW $tTASKDIALOGCONFIG.dwCommonButtons = $TDCBF_OK_BUTTON $tTASKDIALOGCONFIG.pszWindowTitle = Null $tTASKDIALOGCONFIG.hMainIcon_pszMainIcon = Null $tTASKDIALOGCONFIG.pszMainInstruction = _WinAPI_CreateString("string to be used for the main instruction") $tTASKDIALOGCONFIG.pszContent = _WinAPI_CreateString("the dialog's primary content") $tTASKDIALOGCONFIG.cButtons = 0 $tTASKDIALOGCONFIG.pButtons = 0; change ptr in type to STRUCT* $tTASKDIALOGCONFIG.nDefaultButton = $IDOK $tTASKDIALOGCONFIG.cRadioButtons = 0 $tTASKDIALOGCONFIG.pRadioButtons = 0; change ptr in type to STRUCT* $tTASKDIALOGCONFIG.nDefaultRadioButton = 0 $tTASKDIALOGCONFIG.pszVerificationText = _WinAPI_CreateString("string to be used to label the verification checkbox") $tTASKDIALOGCONFIG.pszExpandedInformation = _WinAPI_CreateString("string to be used for displaying additional information") $tTASKDIALOGCONFIG.pszExpandedControlText = _WinAPI_CreateString("string to be used to label the button for collapsing the expandable information") $tTASKDIALOGCONFIG.pszCollapsedControlText = _WinAPI_CreateString("string to be used to label the button for expanding the expandable information") $tTASKDIALOGCONFIG.hFooterIcon_pszFooterIcon = Null $tTASKDIALOGCONFIG.pszFooter = _WinAPI_CreateString("string to be used in the footer area of the task dialog");<A HREF="executablestring">Hyperlink Text</A> Warning Enabling hyperlinks when using content from an unsafe source may cause security vulnerabilities. $tTASKDIALOGCONFIG.pfCallback = 0;Pointer to an application-defined callback function. For more information see TaskDialogCallbackProc $tTASKDIALOGCONFIG.lpCallbackData = 0;A pointer to application-defined reference data. This value is defined by the caller. $tTASKDIALOGCONFIG.cxWidth = 0;The width of the task dialog's client area, in dialog units. If 0, the task dialog manager will calculate the ideal width. Local $aReutn = DllCall("Comctl32.dll", "LONG", "TaskDialogIndirect", "STRUCT*", $tTASKDIALOGCONFIG, "INT*", 0, "INT*", 0, "BOOL*", 0) EndFunc
    1 point
  15. Chromed

    cmd with autoit

    I think something along the lines of .. #include <Constants.au3> ConsoleWrite( _GetDOSOutput("netstat") & @CRLF) Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput
    1 point
  16. Try this, work for me #RequireAdmin MsgBox(0, 0, @UserName) MsgBox(0, 0, _GetUsername()) Func _GetUsername() Local $aResult = DllCall("Wtsapi32.dll", "int", "WTSQuerySessionInformationW", "int", 0, "dword", -1, "int", 5, "dword*", 0, "dword*", 0) If @error Or $aResult[0] = 0 Then Return SetError(1, 0, 0) Local $sUsername = BinaryToString(DllStructGetData(DllStructCreate("byte[" & $aResult[5] & "]", $aResult[4]), 1), 2) DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $aResult[4]) Return $sUsername EndFunc ;==>_GetUsername If someone is expert of DllCall check please if all parameter are correct
    1 point
  17. 1 point
×
×
  • Create New...