Leaderboard
Popular Content
Showing content with the highest reputation on 11/17/2017 in all areas
-
Hello, it's quite often, that someone asks how to change the texts of the MsgBox buttons or the InputBox buttons or how to change the position of ta MsgBox. Since years I use CBT hooks for that, but now I made a small UDF out of it for the ease of use. Of course you can build your own GUI or use already existing UDFs to do the same, but I like this way and you can hack (hook) the inbuild InputBox. HookDlgBox.au3 #include-once #include <WinAPI.au3> Global Const $tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND" Global Const $tagCREATESTRUCT = "ptr lpCreateParams;handle hInstance;HWND hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;ptr lpszName;ptr lpszClass;DWORD dwExStyle" Global $g__hProcDlgBox = DllCallbackRegister("__DlgBox_CbtHookProc", "LRESULT", "int;WPARAM;LPARAM") Global $g__TIdDlgBox = _WinAPI_GetCurrentThreadId() Global $g__hHookDlgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g__hProcDlgBox), 0, $g__TIdDlgBox) Global Const $g__MaxDlgBtns = 5 ; maximum of 5 buttons to rename text Global Const $g__MaxDlgItemId = 11 ; maximun ID of buttons to search is 11 as this is the maximun used in Messagebox Global $g__DlgBoxPosX, $g__DlgBoxPosY, $g__DlgBoxWidth, $g__DlgBoxHeight Global $g__aDlgBoxBtnText[$g__MaxDlgBtns] Global $g__DlgBtnCount = 0 _DlgBox_SetDefaults() OnAutoItExitRegister("__DlgBox_UnregisterHook") Func _DlgBox_SetButtonNames($TxtBtn1 = Default, $TxtBtn2 = Default, $TxtBtn3 = Default, $TxtBtn4 = Default, $TxtBtn5 = Default) $g__aDlgBoxBtnText[0] = $TxtBtn1 $g__aDlgBoxBtnText[1] = $TxtBtn2 $g__aDlgBoxBtnText[2] = $TxtBtn3 $g__aDlgBoxBtnText[3] = $TxtBtn4 $g__aDlgBoxBtnText[4] = $TxtBtn5 $g__DlgBtnCount = @NumParams EndFunc ;==>_DlgBox_SetButtonNames Func _DlgBox_SetPosition($x = Default, $y = Default) ;only for MsgBox, not working and not needed for InputBox $g__DlgBoxPosX = $x $g__DlgBoxPosY = $y EndFunc ;==>_DlgBox_SetPosition Func _DlgBox_SetSize($w = Default, $h = Default) $g__DlgBoxWidth = $w $g__DlgBoxHeight = $h EndFunc ;==>_DlgBox_SetSize Func _DlgBox_SetDefaults() $g__DlgBoxPosX = Default $g__DlgBoxPosY = Default $g__DlgBoxWidth = Default $g__DlgBoxHeight = Default For $i = 0 To UBound($g__aDlgBoxBtnText) - 1 $g__aDlgBoxBtnText[$i] = Default Next EndFunc ;==>_DlgBox_SetDefaults Func __DlgBox_CbtHookProc($nCode, $wParam, $lParam) Local $tcw, $tcs Local $iSearch = 0 Local $ahBtn[$g__DlgBtnCount] If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndIf Switch $nCode Case 3 ;5=HCBT_CREATEWND If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class $tcw = DllStructCreate($tagCBT_CREATEWND, $lParam) $tcs = DllStructCreate($tagCREATESTRUCT, DllStructGetData($tcw, "lpcs")) If $g__DlgBoxPosX <> Default Then DllStructSetData($tcs, "x", $g__DlgBoxPosX) If $g__DlgBoxPosY <> Default Then DllStructSetData($tcs, "y", $g__DlgBoxPosY) If $g__DlgBoxWidth <> Default Then DllStructSetData($tcs, "cx", $g__DlgBoxWidth) If $g__DlgBoxHeight <> Default Then DllStructSetData($tcs, "cy", $g__DlgBoxHeight) EndIf Case 5 ;5=HCBT_ACTIVATE If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class For $i = 1 To $g__MaxDlgItemId If IsHWnd(_WinAPI_GetDlgItem($wParam, $i)) Then If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch]) $iSearch += 1 If $iSearch >= UBound($ahBtn) Then ExitLoop EndIf Next EndIf EndSwitch Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndFunc ;==>__DlgBox_CbtHookProc Func __DlgBox_UnregisterHook() _WinAPI_UnhookWindowsHookEx($g__hHookDlgBox) DllCallbackFree($g__hProcDlgBox) EndFunc ;==>__DlgBox_UnregisterHook Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText Simple example to see how to use it #include "HookDlgBox.au3" _DlgBox_SetButtonNames("1", "two", "3") MsgBox(4, "Test 1", "Custom button texts") _DlgBox_SetPosition(20, 20) MsgBox(66, "Test 2", "Custom position and button texts") _DlgBox_SetButtonNames("Submit", "Don't submit", "Don't know") InputBox("Test 3", "Where were you born?", "Planet Earth") _DlgBox_SetSize(800, 800) InputBox("Test 4", "Where were you born?", "Planet Earth") _DlgBox_SetSize(Default, 800) MsgBox(66, "Test 5", "Strange but working") _DlgBox_SetButtonNames(Default, "Wait", "What?") _DlgBox_SetSize(Default, Default) _DlgBox_SetPosition(500, 500) MsgBox(66, "Test 6", "So far so good!") _DlgBox_SetDefaults() MsgBox(6, "Test 7", "Default position and button texts") Hope you like it. Best regards funkey HookDlgBox Example.au3 HookDlgBox.au32 points
-
Hi all, I make this thread in reference to this help topic. Call it my "thank you" for the help. This actually came about as a random thought while I was taking a smoke break. I personally almost never use the capslock button, so why not find a way to make it more useful right? And yes, the title is a play on MAGA. No political attachment , just thought it funny. Anyway, here is code. Global Const $VK_CAPITAL = 0x14 $WshShell = ObjCreate("WScript.Shell") While 1 Sleep(100) If _Key_Is_On($VK_CAPITAL) Then Run("notepad.exe") $WshShell.SendKeys("{CAPSLOCK}") EndIf WEnd Func _Key_Is_On($nVK_KEY, $vDLL = 'User32.dll') Local $a_Ret = DllCall($vDLL, "short", "GetKeyState", "int", $nVK_KEY) Return Not @error And BitAND($a_Ret[0], 0xFF) = 1 EndFunc This is autoit that we are talking about, so you can probably come up with a number of functions and scripts to be fired on press. I hope someone finds this useful.1 point
-
[Software] AICS / AutoIt Compiler Suite
Earthshine reacted to Deye for a topic
because it's an unsigned executable .. @TRAGENALPHA The main feature of what I was thinking this could do, not sure maybe it does.. That it creates a new "include" directory which collects only the used includes of what the script uses (master UDF's + custom + #AutoIt3Wrapper directions + fileinstall .etc ) I like the concept of the idea and what you managed to get with it so far, this can be a great portable tool if one wants for example to quickly amend something into the script and (compile) when something doesn't work as expected on some other computer (environment) Thanks for sharing1 point -
Ini files are not generic text files, and have VERY specific formatting rules. Random pictures aren't part of that. Use another type of file and don't use IniWrite/IniRead with it.1 point
-
Automatic Restart and Shutdown Utility
argumentum reacted to Danyfirex for a topic
Hola Manuel un gusto verte en el foro en Ingles. La forma que sugiere JohnOne es una buena alternativa. Intenta compartir el código seguro muchos se animan a darte sugerencias y criticas constructivas. No es bien visto en el foro solo compartir los ejecutables por cuestiones de seguridad. Sorry for writing in Spanish. lol. Saludos1 point -
Secutity method - get code from server
Earthshine reacted to JLogan3o13 for a topic
This has been discussed ad nauseam, and the response is not going to change. Locking this thread before it descends into stupidity.1 point -
Secutity method - get code from server
Earthshine reacted to iamtheky for a topic
its not that "there is no perfect method". its that there is NO method. You can create as many hops as you want, but you are spending a significant number of manhours on something that will be undone in minutes. Like, not even double digit minutes.1 point -
My version is 3,5 years older :)...1 point
-
Automatic Restart and Shutdown Utility
antonioj84 reacted to Jos for a topic
Me making that comment means that I knew that already and also means it is not safe!!! Jos1 point -
#include <FileConstants.au3> #include <MsgBoxConstants.au3> #Region AppCompatFlags Constants ;~ HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers ;~ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers ; #CONSTANTS# =================================================================================================================== ; Privilege level value Global Const $__sACF_RUNASADMIN = 'RUNASADMIN' ; Run this program as an Administrator ; Settings value Global Const $__sACF_HIGHDPIWARE = 'HIGHDPIWARE' ; Disable display scaling on high DPI settings Global Const $__sACF_256COLOR = '256COLOR' ; Reduce color mode (8-bit 256) Global Const $__sACF_16BITCOLOR = '16BITCOLOR' ; Reduce color mode (16-bit 65536) Global Const $__sACF_640X480 = '640X480' ; Run in 640 x 480 screen resolution Global Const $__sACF_PLACEHOLDERFILES = 'PLACEHOLDERFILES' ; Enable this program to work on SkyDrive files ; Compatibility mode value Global Const $__sACF_WIN95 = 'WIN95' ; Windows 95 Global Const $__sACF_WIN98 = 'WIN98' ; Windows 98 / Windows ME Global Const $__sACF_WINXPSP2 = 'WINXPSP2' ; Windows XP (Service Pack 2) Global Const $__sACF_WINXPSP3 = 'WINXPSP3' ; Windows XP (Service Pack 3) Global Const $__sACF_VISTARTM = 'VISTARTM' ; Windows Vista Global Const $__sACF_VISTASP1 = 'VISTASP1' ; Windows Vista (Service Pack 1) Global Const $__sACF_VISTASP2 = 'VISTASP2' ; Windows Vista (Service Pack 2) Global Const $__sACF_WIN7RTM = 'WIN7RTM' ; Windows 7 Global Const $__sACF_WIN8RTM = 'WIN8RTM' ; Windows 8 Global Const $__sACF_WINSRV08SP1 = 'WINSRV08SP1' ; Windows Server 2008 SP1 Global Const $__sACF_REGEXP_Compability = '(WIN95|WIN98|WINXPSP2|WINXPSP3|VISTARTM|VISTASP1|VISTASP2|WIN7RTM|WIN8RTM|WINSRV08SP1)' #Region EXAMPLE Func Example() MsgBox($MB_SYSTEMMODAL, 'TEST', '_IsProgramInCompabilityMode() = ' & _IsProgramInCompabilityMode(@AutoItExe)) MsgBox($MB_SYSTEMMODAL, 'TEST', '_IsProgramRunWithSetting() = ' & _ _IsProgramRunWithSetting( _ FileOpenDialog('Chose file to test', '', 'Program (*.exe)', $FD_FILEMUSTEXIST), _ $__sACF_RUNASADMIN) _ ) EndFunc ;==>Example #EndRegion EXAMPLE #Region CURRENT Func _IsProgramInCompabilityMode($sFileFullPath) Local $sRegKey = 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers' Local $sValue For $i = 1 To 1000 $sValueName = RegEnumVal($sRegKey, $i) If @error <> 0 Then ExitLoop If $sFileFullPath = $sValueName Then If StringRegExp(RegRead($sRegKey, $sValueName), $__sACF_REGEXP_Compability) Then Return True EndIf EndIf Next Return False EndFunc ;==>_IsProgramInCompabilityMode Func _IsProgramRunWithSetting($sFileFullPath, $sSetting) Local $sRegKey = 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers' Local $sValue For $i = 1 To 1000 $sValueName = RegEnumVal($sRegKey, $i) If @error <> 0 Then ExitLoop If $sFileFullPath = $sValueName Then If StringInStr(RegRead($sRegKey, $sValueName), $sSetting) Then Return True EndIf EndIf Next Return False EndFunc ;==>_IsProgramRunWithSetting #EndRegion CURRENT HOWTO: Example() ps. Not finished jet.1 point