Leaderboard
Popular Content
Showing content with the highest reputation on 06/02/2025 in all areas
-
Try: #include <WinAPISys.au3> $t = _WinAPI_GetStartupInfo() $tP = DllStructCreate("wchar title[255]", $t.Title) ConsoleWrite($tP.title & @CRLF) I was too slow...2 points
-
_WinAPI_GetStartupInfo() and getting the data from pointers
argumentum reacted to KaFu for a topic
Or this way. #include <WinAPISys.au3> Local $tInfo = _WinAPI_GetStartupInfo() ConsoleWrite(_WinAPI_GetString($tInfo.title) & @CRLF)1 point -
_WinAPI_GetStartupInfo() and getting the data from pointers
argumentum reacted to Nine for a topic
#include <WinAPISys.au3> Local $tInfo = _WinAPI_GetStartupInfo ( ) $tString = DllStructCreate("wchar str[256]", $tInfo.title) ConsoleWrite($tString.str & @CRLF)1 point -
If you mean the first attempt from @KaFu. No its not enough. It may take a few attempts but it will break eventually. Like I said before in this thread : Here a revised version of the code including x64 : #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Memory.au3> #include <WindowsConstants.au3> #include <WinAPIError.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> Global Const $WT_EXECUTELONGFUNCTION = 0x00000010 ; The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread. Global Const $WT_EXECUTEINTIMERTHREAD = 0x00000020 ; The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations. Global Const $WT_EXECUTEINPERSISTENTTHREAD = 0x00000080 ; The callback function is queued to a thread that never terminates. Local $a_h_CreateTimerQueue = DllCall("kernel32.dll", "handle", "CreateTimerQueue") ConsoleWrite("CreateTimerQueue = " & $a_h_CreateTimerQueue[0] & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) Local $i_TimerQueue_Start_after = 100 Local $i_TimerQueue_Repeat_after = 100 Local $pCallback = _RegisterSyncCallback(_CallBackFunction) ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485(v=vs.85).aspx Local $a_hCall = DllCall("kernel32.dll", "bool", "CreateTimerQueueTimer", _ "handle*", 0, _ "handle", $a_h_CreateTimerQueue[0], _ "ptr", $pCallback, _ "ptr", 678, _ "dword", $i_TimerQueue_Start_after, _ "dword", $i_TimerQueue_Repeat_after, _ "ulong", $WT_EXECUTEINTIMERTHREAD) Local $phNewTimer = $a_hCall[1] ConsoleWrite("CreateTimerQueueTimer = " & $a_hCall[0] & @TAB & $phNewTimer & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) Local $timer = TimerInit() While Sleep(10) ConsoleWrite("+ " & TimerDiff($timer) & @CRLF) If TimerDiff($timer) > 5000 Then ConsoleWrite("! fire Exitloop event" & @CRLF) ExitLoop EndIf WEnd Local $a_hCall = DllCall("kernel32.dll", "bool", "DeleteTimerQueueTimer", _ "handle", $a_h_CreateTimerQueue[0], _ "handle", $phNewTimer, _ "handle", 0) ConsoleWrite("DeleteTimerQueueTimer = " & $a_hCall[0] & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) ConsoleWrite("_WinAPI_CloseHandle($phNewTimer) = " & _WinAPI_CloseHandle($phNewTimer) & @CRLF) Local $a_hCall = DllCall("kernel32.dll", "bool", "DeleteTimerQueueEx", "handle", $a_h_CreateTimerQueue[0], "handle", 0) ConsoleWrite("DeleteTimerQueueEx = " & $a_hCall[0] & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) Func _CallBackFunction($lParam, $TimerOrWaitFired) ConsoleWrite("_CallBackFunction fired = " & $lParam & @TAB & $TimerOrWaitFired & @CRLF) EndFunc ;==>_CallBackFunction Func _RegisterSyncCallback($Function) Local Static $hGUI Local Static $pSendMessage Local Static $iMsg If Not $hGUI Then $hGUI = GUICreate("RegisterSyncCallback_Msg", 300, 200) $iMsg = $WM_APP GUIRegisterMsg($iMsg, RegisterSyncCallback_Msg) $pSendMessage = _WinAPI_GetProcAddress(_WinAPI_GetModuleHandle("user32.dll"), "SendMessageW") ConsoleWrite("$hGUI: " & Hex($hGUI) & @CRLF) ConsoleWrite("$pSendMessage: " & Hex($pSendMessage) & @CRLF) ConsoleWrite("$iMsg: " & Hex($iMsg) & @CRLF) EndIf Local $pRemoteCode = _MemVirtualAlloc(0, 96, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) If Not $pRemoteCode Then MsgBox(0, "Error", "_MemVirtualAlloc :(") Local $tCodeBuffer = DllStructCreate("byte[96]", $pRemoteCode) Local $hHandle = DllCallbackRegister($Function, "none", "int;int") If @AutoItX64 Then Local $sOPCode = "0x48894C240848895424104C894424184C894C24204883EC284989C8" & _ "48C7C1" & SwapEndian($hGUI, False) & _ "48C7C2" & SwapEndian($iMsg, False) & _ "49B9" & SwapEndian(DllCallbackGetPtr($hHandle)) & _ "48B8" & SwapEndian($pSendMessage) & _ "FFD04883C428C3" Else Local $sOPCode = "0x68" & SwapEndian(DllCallbackGetPtr($hHandle)) & _ "FF74240868" & SwapEndian($iMsg) & "68" & SwapEndian($hGUI) & _ "B8" & SwapEndian($pSendMessage) & "FFD0C20800" EndIf DllStructSetData($tCodeBuffer, 1, $sOPCode) ConsoleWrite("$tCodeBuffer: " & DllStructGetData($tCodeBuffer, 1) & @CRLF) Return $pRemoteCode EndFunc ;==>_RegisterSyncCallback Func RegisterSyncCallback_Msg($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite(">RegisterSyncCallback_Msg Called" & @CRLF) ;ConsoleWrite("$hWnd: " & Hex($hWnd) & @CRLF) ;ConsoleWrite("$iMsg: " & Hex($iMsg) & @CRLF) ;ConsoleWrite("$wParam: " & Hex($wParam) & @CRLF) ;ConsoleWrite("$lParam: " & Hex($lParam) & @CRLF) DllCallAddress("none", $lparam, "int", $wParam, "int", 1) EndFunc ;==>RegisterSyncCallback_Msg Func SwapEndian($uInt, $b64 = True) Local $iLen = (@AutoItX64 And $b64) ? 16 : 8, $sHex = Hex($uInt, $iLen), $sRes For $i = $iLen - 2 To 0 Step -2 $sRes &= StringMid($sHex, $i + 1, 2) Next Return $sRes EndFunc1 point
-
@KaFu op code worked as it is just need to add volatile volatile Func _CallBackFunction($lParam, $TimerOrWaitFired) ConsoleWrite("_CallBackFunction fired = " & TimerInit() & @TAB & $lParam & @TAB & $TimerOrWaitFired & @CRLF) EndFunc ;==>_CallBackFunction1 point
-
@atvaxn I would go some other way. Try this : #include <guiConstants.au3> #include <Misc.au3> #include <WinAPIShellEx.au3> #include <WinAPIRes.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", True) Opt("MouseCoordMode", 2) Example() Func Example() Local $hGUI = GUICreate("Gantt Chart", 300, 200, -1, -1, -1, $WS_EX_COMPOSITED) Local $idBar1 = GUICtrlCreateLabel("", 5, 50, 80, 20) GUICtrlSetBkColor(-1, 0xf00000) Local $idBar2 = GUICtrlCreateLabel("", 25, 80, 80, 20) GUICtrlSetBkColor(-1, 0xf0) Local $hDll = DllCallbackRegister(MoveProc, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBar1), DllCallbackGetPtr($hDll), $idBar1) _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBar2), DllCallbackGetPtr($hDll), $idBar2) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($idBar1), DllCallbackGetPtr($hDll), $idBar1) _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($idBar2), DllCallbackGetPtr($hDll), $idBar2) DllCallbackFree($hDll) EndFunc ;==>Example Func MoveProc($hWnd, $iMsg, $wParam, $lParam, $iID, $iData) If $iMsg <> $WM_LBUTTONDOWN Then Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Local $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) Local $iPosX = MouseGetPos(0), $iPosXN, $hCursor Select Case $iPosX - $aPosID[0] <= 3 ; left $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEWE) While _IsPressed("01") _WinAPI_SetCursor($hCursor) If $iPosX <> MouseGetPos(0) Then $iPosXN = MouseGetPos(0) GUICtrlSetPos($iID, $aPosID[0] + ($iPosXN - $iPosX), $aPosID[1], $aPosID[2] + $iPosX - $iPosXN) $iPosX = $iPosXN $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) EndIf WEnd Case $aPosID[0] + $aPosID[2] - $iPosX <= 3 ; right $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEWE) While _IsPressed("01") _WinAPI_SetCursor($hCursor) If $iPosX <> MouseGetPos(0) Then $iPosXN = MouseGetPos(0) GUICtrlSetPos($iID, $aPosID[0], $aPosID[1], $aPosID[2] + $iPosXN - $iPosX) $iPosX = $iPosXN $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) EndIf WEnd Case Else ; center $hCursor = _WinAPI_LoadCursor(0, $OCR_HAND) While _IsPressed("01") _WinAPI_SetCursor($hCursor) If $iPosX <> MouseGetPos(0) Then $iPosXN = MouseGetPos(0) GUICtrlSetPos($iID, $aPosID[0] + $iPosXN - $iPosX) $iPosX = $iPosXN $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) EndIf WEnd EndSelect Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>MoveProc1 point
-
Autoit Serialize
pat4005 reacted to tarretarretarre for a topic
About Serialize Serialize a given value to get it's string representation, that you can later unSerialize back to its original value. Including nested arrays and objects. This is useful for storing and transferring data between applications. 2021-02-14 update: you can now serialize and unSerialize data in JavaScript as well. Checkout the official npm package or the github repo. This makes it possible to pass data between AutoIt and JavaScript applications. Eventually I will make an package for PHP aswell. Limitations Mutli dim arrays are not supported Examples Basic example #include "Serialize.au3" #include <Array.au3> ; Define some data Global $array = [1,2,3] ; Serialize Global $serialized = _Serialize($array) MsgBox(64, "Serialized data", $serialized) ; Unserialize Global $unSerialized = _UnSerialize($serialized) _ArrayDisplay($unSerialized) Objects and nesting #include "Serialize.au3" #include <Array.au3> ; Define some data Global $preArray = [1, 2, 3] Global $array = [5, 6, $preArray] Global $obj = ObjCreate("Scripting.Dictionary") $obj.add("firstName", "Tarre") $obj.add("age", 29) $obj.add("array", $array) $obj.add("active", True) ; Serialize Global $serialized = _Serialize($obj) MsgBox(64, "Serialized data", $serialized) ; Unserialize Global $unSerialized = _UnSerialize($serialized) MsgBox(64, "Unserialized data", "firstName = " & $unSerialized.item("firstName") & @LF & "age = " & $unSerialized.item("age") & @LF & "active = " & $unSerialized.item("active")) Global $array = $unSerialized.item("array") Global $preArray = $array[2] _ArrayDisplay($array, "$array") _ArrayDisplay($preArray, "$preArray") The code is also available on Github Autoit-Serialize-1.0.0.zip1 point