Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/14/2019 in all areas

  1. It is general hook (not related to any GUI), you just have to manage multiple windows...
    1 point
  2. Let me get a better version : #include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPIConstants.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <WinAPIError.au3> Global Const $tagMSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" OnAutoItExitRegister("Cleanup") _Main() Func _Main() Global $g_hStub_MouseProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam") Local $hMod = _WinAPI_GetModuleHandle(0) Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_MouseProc), $hMod) Global $Gui = GUICreate("Test", 500, 150) Local $Button = GUICtrlCreateButton("OK", 220, 100, 60) GUISetState() GUISetState(@SW_DISABLE) MsgBox($MB_SYSTEMMODAL, "Clicking parent title flash", "clicking parent client area NOW does flash !", 60, $Gui) GUISetState(@SW_ENABLE) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button ExitLoop EndSwitch WEnd EndFunc ;==>_Main Func _MouseProc($nCode, $wParam, $lParam) If $nCode < 0 Or $wParam <> $WM_LBUTTONDOWN Then Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) Local $tStruct = DllStructCreate($tagPOINT) Local $tMouseHOOKS = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam) Local $ptx = DllStructGetData($tMouseHOOKS, "X") Local $pty = DllStructGetData($tMouseHOOKS, "Y") DllStructSetData($tStruct, "x", $ptx) DllStructSetData($tStruct, "y", $pty) If WinExists("Clicking") And _WinAPI_WindowFromPoint($tStruct) = $Gui Then _WinAPI_MessageBeep(1) _WinAPI_FlashWindowEx(WinGetHandle("Clicking"), 3, 5, 100) EndIf Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndFunc ;==>_MouseProc Func Cleanup() GUIDelete() _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_MouseProc) EndFunc ;==>Cleanup
    1 point
  3. jchd

    Autoit Struct Help

    If you download and Install SciTe4AutoIt3 toolchain, you will get instant notice for this kind of error.
    1 point
  4. jchd

    Autoit Struct Help

    No, you initially just typed DllStructSetData($Vector2,1,$x) instead of DllStructSetData($xVector2,1,$x).
    1 point
  5. @notwilltoledo The "c" character is not a special key, so, just use "^c" to Copy and "^v" to paste. Pay attention at the capitalization of the characters, since "c" and "C" are threatened differently in the Send() function
    1 point
  6. That is why it is important to give an example of what you are actually working on. How you obtain this information from the Calc app vs. a Web App vs. a Java App is going to be different. Using an example that has nothing to do with what you're trying to actually accomplish is only going to frustrate you when it doesn't work. Please explain in detail what you are trying to accomplish, and in what application, and we will do our best to help.
    1 point
  7. It's 5am here. Need to sleep some, I'll check in a few hours...
    1 point
  8. RTFC

    Autoit Struct Help

    Almost right. Func Vector2($x,$y) $xVector2 = DllStructCreate("float;float") DllStructSetData($xVector2,1,$x) DllStructSetData($xVector2,2,$y) Return $xVector2 EndFunc
    1 point
  9. I found a few related topics for some reference: Basically the issue has always been how to interpret and work with the results of IsAdmin() when running under UAC, and the desire for developers to not force the use of #RequireAdmin (or the AutoIt3Wrapper manifest equivalent) for all of their users. A lot of programs have that nice 'Elevate' button which is presented to you when the function is available, to selectively elevate the application and enable administrative functions. Here's my attempt at detecting this scenario. The function will return the current admin status, and the ability of the current app to elevate itself under UAC in @extended. A small example should show how it is used. The example can be run from SciTE or compiled, allowing you to test all kinds of scenarios. Something interesting I found... if an app is launched from another fully elevated app, and that new app is launched with restricted privileges by way of the SAFER api, then that app CANNOT re-elevate itself to full admin status. The other way to lower a launched app's privileges uses either CreateProcessAsUser or CreateProcessWithTokenW (there are scripts on the forum that show their usage). Apps launched with either of those functions CAN re-elevate themselves to full admin status. _IsUACAdmin #include <Security.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsUACAdmin ; Description ...: Determines if process has Admin privileges and whether running under UAC. ; Syntax ........: _IsUACAdmin() ; Parameters ....: None ; Return values .: Success - 1 - User has full Admin rights (Elevated Admin w/ UAC) ; Failure - 0 - User is not an Admin, sets @extended: ; | 0 - User cannot elevate ; | 1 - User can elevate ; Author ........: Erik Pilsits ; Modified ......: ; Remarks .......: THE GOOD STUFF: returns 0 w/ @extended = 1 > UAC Protected Admin ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _IsUACAdmin() ; check elevation If StringRegExp(@OSVersion, "_(XP|20(0|3))") Or (Not _IsUACEnabled()) Then ; XP, XPe, 2000, 2003 > no UAC ; no UAC available or turned off If IsAdmin() Then Return SetExtended(0, 1) Else Return SetExtended(0, 0) EndIf Else ; check UAC elevation ; ; get process token groups information Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_QUERY) Local $tTI = _Security__GetTokenInformation($hToken, $TOKENGROUPS) _WinAPI_CloseHandle($hToken) ; Local $pTI = DllStructGetPtr($tTI) Local $cbSIDATTR = DllStructGetSize(DllStructCreate("ptr;dword")) Local $count = DllStructGetData(DllStructCreate("dword", $pTI), 1) Local $pGROUP1 = DllStructGetPtr(DllStructCreate("dword;STRUCT;ptr;dword;ENDSTRUCT", $pTI), 2) Local $tGROUP, $sGROUP = "" ; ; S-1-5-32-544 > BUILTINAdministrators > $SID_ADMINISTRATORS ; S-1-16-8192 > Mandatory LabelMedium Mandatory Level (Protected Admin) > $SID_MEDIUM_MANDATORY_LEVEL ; S-1-16-12288 > Mandatory LabelHigh Mandatory Level (Elevated Admin) > $SID_HIGH_MANDATORY_LEVEL ; SE_GROUP_USE_FOR_DENY_ONLY = 0x10 ; ; check SIDs Local $inAdminGrp = False, $denyAdmin = False, $elevatedAdmin = False, $sSID For $i = 0 To $count - 1 $tGROUP = DllStructCreate("ptr;dword", $pGROUP1 + ($cbSIDATTR * $i)) $sSID = _Security__SidToStringSid(DllStructGetData($tGROUP, 1)) If StringInStr($sSID, "S-1-5-32-544") Then ; member of Administrators group $inAdminGrp = True ; check for deny attribute If (BitAND(DllStructGetData($tGROUP, 2), 0x10) = 0x10) Then $denyAdmin = True ElseIf StringInStr($sSID, "S-1-16-12288") Then $elevatedAdmin = True EndIf Next ; If $inAdminGrp Then ; check elevated If $elevatedAdmin Then ; check deny status If $denyAdmin Then ; protected Admin CANNOT elevate Return SetExtended(0, 0) Else ; elevated Admin Return SetExtended(1, 1) EndIf Else ; protected Admin Return SetExtended(1, 0) EndIf Else ; not an Admin Return SetExtended(0, 0) EndIf EndIf EndFunc ;==>_IsUACAdmin Func _IsUACEnabled() Return (RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA") = 1) EndFunc ;==>_IsUACEnabled Example #include <_IsUACAdmin.au3> #include <GuiButton.au3> #include <GuiConstantsEx.au3> $g = GUICreate("UAC Test", 200, 100) $b = GUICtrlCreateButton("Elevate", 200-72, 100-27, 70, 25) _GUICtrlButton_SetShield($b) $admin = _IsUACAdmin() $canelevate = @extended GUICtrlCreateLabel("IsAdmin (built-in): " & (IsAdmin() = 1), 4, 4) GUICtrlCreateLabel("_IsUACAdmin (full admin): " & ($admin = 1), 4, 24) GUICtrlCreateLabel("Process can elevate: " & ($canelevate = 1), 4, 44) If $admin Or (Not $canelevate) Then GUICtrlSetState($b, $GUI_DISABLE) GUISetState() While 1 Switch GUIGetMsg() Case -3 ExitLoop Case $b ; restart elevated If @Compiled Then ShellExecute(@ScriptFullPath, "", @WorkingDir, "runas") Else ShellExecute(@AutoItExe, '/AutoIt3ExecuteScript "' & @ScriptFullPath & '"', @WorkingDir, "runas") EndIf Exit EndSwitch WEnd
    1 point
×
×
  • Create New...