Leaderboard
Popular Content
Showing content with the highest reputation on 03/24/2023 in all areas
-
The following code draws a picture from the clipboard to a gui window. The original code hasn't displayed the picture from the clipboard, and after a lot of trial and errors i found the solution which does work (i'm using windows 10). You have to have a screenshot or a picture in the clipboard for this to work (this script is sending a printscreen key if the clipboard content is not bitmap). Resizing reloads the picture from the clipboard. ;modified code from https://www.autoitscript.com/forum/topic/57053-updating-a-picture-control-without-a-file/?do=findComment&comment=514735 #include <ScreenCapture.au3> #include <Clipboard.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIHObj.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Draw Image from Clipboard ", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) GUISetState() If Not _ClipBoard_IsFormatAvailable($CF_BITMAP) Then Send("{printscreen}") EndIf ClipDrawBitmap() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESIZED ClipDrawBitmap() EndSwitch WEnd Func ClipDrawBitmap() Local $WPos, $hBitmap, $hImage, $hGraphics $WPos = WinGetPos($hGUI) _ClipBoard_Open($hGUI) $hBitmap = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() If $hBitmap > 0 Then _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_DrawImagePoints($hGraphics, $hImage, 0, 0, $WPos[2], 0, 0, $WPos[3]) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() EndIf EndFunc ;==>ClipDrawBitmap2 points
-
I don't have time now, I'll look at it in the afternoon1 point
-
Interview style GUI creation - (Moved)
argumentum reacted to IvanCodin for a topic
OK I will start clicking away . I assume I would read the INI into an array to speed it up. Comment? use of single INI or multiple INI files? Because the INI is limited to a 64K files size this would likely be more scalable. Comment? GUI title base on INI variable? Think this would be the cleanest Comment? I know the questions may seem basic but before I go off on a coding tangent I wanted to have my ducks in a row.1 point -
how to pass a multi-line data value or JSON with curl?
argumentum reacted to gcue for a topic
that worked! hardcoding the json AND replacing the file contents like this... $txt_file = "file.txt" $txt_query = FileRead($txt_file) $txt_query = StringStripWS($txt_query, 8) $txt_query = StringReplace($txt_query, '"', '\"') $iPID = Run(@ComSpec & ' /c curl.exe --header "accept:application/json" --data "' & $txt_query & '"', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) thank youuuuu!!!!1 point -
msgbox focus
KaFu reacted to pixelsearch for a topic
As an alternative, I remember @KaFu did something interesting using Timers, in this link Adapted to OP's need : #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> MouseMove(200, 200, 0) ; 0 = fastest mouse move ToolTip("See the mouse pointer ?") Sleep(2000) ; just to see where is the mouse pointer on the screen (200, 200) ToolTip("") Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, 10, DllCallbackGetPtr($hTimerProc)) MsgBox($MB_TOPMOST, "_WinAPI_SetTimer", "Does not block") ; mouse moved automatically over Msgbox _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) ;=============================================== Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime) Local $hActive = WinActive("_WinAPI_SetTimer") If $hActive Then _WinAPI_KillTimer(0, $iTimerID) Local $Wpos = WinGetPos($hActive) MouseMove($Wpos[0] + $Wpos[2] /2, $Wpos[1] + $Wpos[3] /2, 0) EndIf EndFunc ;==>_TimerProc1 point -
in line 142 i put Exit ; <-- ************************************************ so you can check if it's okay which is to turn it into a comment or delete it #RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; FUNCTION: _Example ; DESCRIPTION: This function opens the Group Policy Object Editor, ; navigates to the specified policy setting, and changes its value ; to the specified setting. ; PARAMETERS: ; $CmdLine[1] - The path of nodes to navigate. ; $CmdLine[2] - The name of the policy setting to be changed. ; $CmdLine[3] - The value of the policy setting to be changed 0=Disabled, 1=Enabled, 2=Configured ;============================================================== ; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0 If Not $CmdLine[0] Then Global $CmdLine[4] = [3, "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service", "Allow Basic authentication", 0] EndIf Global $iMsgBoxAnswer = MsgBox(4097, "message", "The setting " & $CmdLine[1] & @CRLF & $CmdLine[2] & " set to " & $CmdLine[3] & @CRLF & " This box will time out in 5 seconds", 5) Select Case $iMsgBoxAnswer = 1 ;OK ;nothing Case $iMsgBoxAnswer = 2 ;Cancel Exit EndSelect If $CmdLine[0] = 3 Then _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3]) Else $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters" , $CmdLine[0]) EndIf Exit ; #FUNCTION# ;--------------------------------------------------------------------------- ; Name...........: _GroupPolicy() ; Description ...: Opens and uses the Group Policy Editor to configure the given settings ; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") ConsoleWrite("$hGPO=" & $hGPO & @CRLF) ;Retrieves the SysTreeView321 control handle Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321") ;Sets the focus to $hTreeView_1 ControlFocus($hGPO, "", $hTreeView_1) Sleep(50) $sPolicyPath = "Local Computer Policy" & $sPolicyPath ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF) ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ;ConsoleWrite("" & @CRLF) For $i = 1 To $aPath[0] $tmpPath &= $aPath[$i] & "|" ;ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF) ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1)) ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1)) Sleep(50) Next ;at the bottom tabs we go right to the standard tab ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(250) ConsoleWrite("$FindItem=" & $FindItem & @CRLF) ;If not found then Return Error If $FindItem = -1 Then ConsoleWrite("not found the entry:'" & $sPolicyItem & "'" & @CRLF) Return SetError(1, 0, "") EndIf ;select the found item ControlListView($hGPO, "", $hListView, "Select", $FindItem) Sleep(50) ;and send enter to open it ControlSend($hGPO, '', $hListView, '{ENTER}') ; we give some time until the edit window appears Sleep(100) Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") Switch $iMode Case 0 ;Disabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}") Sleep(50) Exit ; <-- ************************************************ ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}") Sleep(50) Local $hGPO = WinWait("Microsoft Management Console") ControlSend($hGPO, "", "[CLASS:Static; INSTANCE:2]", "{N}") Return $sPolicyItem EndFunc ;==>_GroupPolicy ;----------------------------------------------------------------------------------------1 point