Leaderboard
Popular Content
Showing content with the highest reputation on 10/14/2015 in all areas
-
In the last versions of Windows, it has been difficult to automate Windows Explorer. But there are many examples of code like this to extract the selected items: ; Windows Explorer on XP, Vista, 7, 8 $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then Exit ; Shell object $oShell = ObjCreate( "Shell.Application" ) ; Find window For $oWindow In $oShell.Windows() If $oWindow.HWND() = $hExplorer Then ExitLoop Next ; Selected items For $oItem In $oWindow.Document.SelectedItems() ConsoleWrite( $oItem.Path() & @CRLF ) Next It's possible to create these objects with ObjCreateInterface. More precisely, create an IShellBrowser interface for the top level browser of an open Windows Explorer. Plan and code This is the plan: Create an IShellWindows interface to get a list of shell windows Get an IWebBrowserApp object for each window. This is done in two steps: Get an IDispatch object for the window Get the IWebBrowserApp interface Identify the proper shell window with get_HWND of IWebBrowserApp Get an IServiceProvider interface with QueryInterface of IWebBrowserApp Get the IShellBrowser interface with QueryService of IServiceProvider This is the code: Func GetIShellBrowser( $hExplorer ) ; IShellWindows interface Local $pIShellWindows, $oIShellWindows CoCreateInstance( $tCLSID_ShellWindows, $NULL, $CLSCTX_ALL, $tRIID_IShellWindows, $pIShellWindows ) $oIShellWindows = ObjCreateInterface( $pIShellWindows, $sIID_IShellWindows, $dtag_IShellWindows ) ; Number of shell windows Local $iWindows $oIShellWindows.get_Count( $iWindows ) ; Get an IWebBrowserApp object for each window ; This is done in two steps: ; 1. Get an IDispatch object for the window ; 2. Get the IWebBrowserApp interface ; Check if it's the right window Local $pIDispatch, $oIDispatch Local $pIWebBrowserApp, $oIWebBrowserApp, $hWnd For $i = 0 To $iWindows - 1 $oIShellWindows.Item( $i, $pIDispatch ) If $pIDispatch Then $oIDispatch = ObjCreateInterface( $pIDispatch, $sIID_IDispatch, $dtag_IDispatch ) $oIDispatch.QueryInterface( $tRIID_IWebBrowserApp, $pIWebBrowserApp ) If $pIWebBrowserApp Then $oIWebBrowserApp = ObjCreateInterface( $pIWebBrowserApp, $sIID_IWebBrowserApp, $dtag_IWebBrowserApp ) $oIWebBrowserApp.get_HWND( $hWnd ) If $hWnd = $hExplorer Then ExitLoop EndIf EndIf Next ; IServiceProvider interface Local $pIServiceProvider, $oIServiceProvider $oIWebBrowserApp.QueryInterface( $tRIID_IServiceProvider, $pIServiceProvider ) $oIServiceProvider = ObjCreateInterface( $pIServiceProvider, $sIID_IServiceProvider, $dtag_IServiceProvider ) ; IShellBrowser interface Local $pIShellBrowser $oIServiceProvider.QueryService( $tRIID_STopLevelBrowser, $tRIID_IShellBrowser, $pIShellBrowser ) $oIShellBrowser = ObjCreateInterface( $pIShellBrowser, $sIID_IShellBrowser, $dtag_IShellBrowser ) EndFunc Now it's easy to create the shell interfaces. The main interfaces are: Func GetShellInterfaces() Local $pIFolderView, $pIFolderView2, $pIPersistFolder2, $pIShellFolder, $pPidlFolder, $pPidlRel, $i = 0 ; IShellView interface $oIShellBrowser.QueryActiveShellView( $pIShellView ) $oIShellView = ObjCreateInterface( $pIShellView, $sIID_IShellView, $dtag_IShellView ) ; IFolderView interface $oIShellView.QueryInterface( $tRIID_IFolderView, $pIFolderView ) $oIFolderView = ObjCreateInterface( $pIFolderView, $sIID_IFolderView, $dtag_IFolderView ) If @OSVersion <> "WIN_XP" Then ; IFolderView2 interface (Vista and later) $oIShellView.QueryInterface( $tRIID_IFolderView2, $pIFolderView2 ) $oIFolderView2 = ObjCreateInterface( $pIFolderView2, $sIID_IFolderView2, $dtag_IFolderView2 ) EndIf ; IPersistFolder2 interface $oIFolderView.GetFolder( $tRIID_IPersistFolder2, $pIPersistFolder2 ) $oIPersistFolder2 = ObjCreateInterface( $pIPersistFolder2, $sIID_IPersistFolder2, $dtag_IPersistFolder2 ) $oIPersistFolder2.GetCurFolder( $pPidlFolder ) ; IShellFolder interface If ILIsEqual( $pPidlFolder, $pPidlAbsDesktop ) Then SHGetDesktopFolder( $pIShellFolder ) Else Local $pIParentFolder, $oIParentFolder, $pPidlRel SHBindToParent( $pPidlFolder, DllStructGetPtr( $tRIID_IShellFolder ), $pIParentFolder, $pPidlRel ) $oIParentFolder = ObjCreateInterface( $pIParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) $oIParentFolder.BindToObject( $pPidlRel, $NULL, $tRIID_IShellFolder, $pIShellFolder ) EndIf $oIShellFolder = ObjCreateInterface( $pIShellFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Free memory used by $pPidlFolder _WinAPI_CoTaskMemFree( $pPidlFolder ) ; Wait for Explorer to refresh $pPidlRel = GetFocusedItem() While Not $pPidlRel And $i < 10 Sleep( 25 ) $pPidlRel = GetFocusedItem() $i += 1 WEnd ; Free memory used by $pPidlRel If $pPidlRel Then _ _WinAPI_CoTaskMemFree( $pPidlRel ) EndFunc Features The methods of the interfaces supports the following features: You can handle items in Windows Explorer: Get current folder, get all items, get/set selected items and get/set focused item. A selected file is opened by executing the InvokeCommand for the default item in the context menu. You can browse to a specific folder or a parent/child folder. You can set icon view mode. Functions AutomatingWindowsExplorer.au3 contains the two functions above. And it contains a number of functions to implement the features: GetCurrentFolder SetCurrentFolder CountItems GetItems GetFiles GetFolders GetPidls GetFocusedItem SetFocusedItem SetSelectedItem GetIconView SetIconView When the interfaces are created, the functions can be implemented with a few lines of code. This is the code for GetCurrentFolder and SetCurrentFolder: Func GetCurrentFolder() Local $pPidlAbs $oIPersistFolder2.GetCurFolder( $pPidlAbs ) Return $pPidlAbs EndFunc ; After this command $oIShellBrowser is the only valid interface object. To ; be able to use the other interfaces you must execute GetShellInterfaces(). Func SetCurrentFolder( $pPidl, $fFlag ) $oIShellBrowser.BrowseObject( $pPidl, BitOR( $SBSP_DEFBROWSER, $fFlag ) ) EndFunc For examples search the functions in Example.au3 and Example*.au3. Depending on parameters most functions can return PIDLs. Some functions return only PIDLs. In these cases you must free memory (_WinAPI_CoTaskMemFree) used by the PIDLs, when you have finished using the PIDLs. There are many more methods that are not implemented in these functions, and there are available interfaces that have not been created. Example Example.au3 demonstrates the features. Example folder contains scripts with functions used in the example. It's important that there is consistency between the interfaces, and the current folder in Windows Explorer. If the GUI loses and gets focus, it's checked if the current folder is changed. In that case the interfaces are updated to match the new folder. This is a picture of the GUI: Items and selected items are shown with _ArrayDisplay. The number of rows in the listview to the right is limited to 100. The listview can only be used for the buttons in the lower right group. The buttons in the lower left group are disabled, if there are more than 100 items in the folder. There is also a listview on the second tab item. It's limited to 100 rows, and can only be used for the Child folder button. You can also double click a child folder in the listview, to browse to this folder. Control Panel The example does not work for the Control Panel. The reason is that the child windows which are created for the Control Panel, are different from the child windows which are created for other folders. You can verify that with the UI Automation framework. Zipfile Example - include files used in example Includes - include files used for Automating Windows Explorer Example.au3 - Example For AutoIt 3.3.10 and later. Testet on Windows XP 32 bit and Windows 7 32/64 bit. Automating Windows Explorer.7z Examples in posts below Post 7 is a collection of small examples. Post 15 shows how to automate a search with UI Automation code. Post 31 shows how to execute a function on a double-click in empty space of the right pane window (the listview). The code contains UI Automation code. Post 38 is UI Automation code to make a selected item visible by scrolling the listview up or down.1 point
-
Hi! Today I want to show you my current AutoIt project: The ISN AutoIt Studio. The ISN AutoIt Studio is a complete IDE made with AutoIt, for AutoIt! It includes a GUI designer, a code editor (with syntax highlighting, auto complete & intelisense), a file viewer, a backup system, trophies and a lot more features!! Here are some screenshots: Here some higlights: -> easy to create/manage/public your AutoIt-projects! ->integrated GUI-Editor (ISN Form Studio 2) ->integrated - file & projectmanager ->auto backupfunction for your Projects ->extendable with plugins! ->available in several languages ->trophies ->Syntax highlighting /Autocomplete / Intelisense ->Dynamic Script ->detailed overview of the project (total working hours, total size...) And much more!!! -> -> Click here to download ISN AutoIt Studio <- <- Here is the link to the german autoit forum where I posted ISN AutoIt Studio the first time: http://autoit.de/index.php?page=Thread&threadID=29742&pageNo=1 For more information visit my Homepage: https://www.isnetwork.at So….have fun with ISN AutoIt Studio! PS: Sorry for my bad English! ^^1 point
-
Thanks for the tip with _Timer_GetIdleTime JohnOne! I will include it this way: If No input in 60 secounds or the window is not active the timer stops. @Rex: Hmm..hard to say what´s the error in this case... But the error with the abbrev (gcss) will be fixed in the next update. (and yes it should not be case sensitive)1 point
-
Is not like get it dinamically. I more like create/register that message. Here are the parameters. https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx Saludos1 point
-
Sure you can. Saludos1 point
-
You can do something like this: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <TrayConstants.au3> $hGUI = GUICreate("Window", 500, 400, -1, -1) Global $hButton = GUICtrlCreateButton("Button", 144, 179, 202, 60) GUISetState() GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') _WinAPI_RegisterShellHookWindow($hGUI) While 1 Sleep(30) $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE _WinAPI_DeregisterShellHookWindow($hGUI) Exit Case $hButton BtnClick() EndSwitch WEnd Func BtnClick() Local $sPath = FileOpenDialog("TestWindow", "D:\AutoIt Works\EXEs", "(*.*)") ConsoleWrite($sPath & @LF) EndFunc ;==>BtnClick Func Print() ConsoleWrite("Yes, it is there" & @CRLF) EndFunc ;==>Print Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg Local $sTitle = "" Local Const $sDlgTitle = "TestWindow" Switch $wParam Case $HSHELL_WINDOWCREATED $sTitle = WinGetTitle($lParam) If WinGetProcess($lParam) = @AutoItPID And $sTitle = $sDlgTitle Then Print() EndIf EndSwitch EndFunc ;==>WM_SHELLHOOK Saludos1 point
-
No (with the current script), because function Checker will be called after the FileOpenDailog has been closed. You could try AdLibRegister but I'm not sure if FileOpenDailog is a blocking function.1 point
-
#include <GDIplus.au3> #include <GUIConstantsEx.au3> AutoItSetOption("MouseCoordMode", 0) AutoItSetOption("GUIOnEventMode", 1) Global Const $iW = 400, $iH = 400, $iBgColor = 0xF0F0F0 Global Const $hGUI = GUICreate("", $iW, $iH) GUISetBkColor($iBgColor, $hGUI) GUISetState() _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate() $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2) $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, 4) Global Const $iPosX = 50, $iPosY = 50, $iWidth = 300, $iHeight = 300 Global $iMPosX, $iMPosY Local Const $fDeg = ACos(-1) / 180, $iRadius = 31, $iRadius2 = $iWidth / 2, $iWh1 = $iW / 2, $iHh1 = $iH / 2 Local $fAngle = 0 , $fAngle2 = 155 , $fAngle3 =333, $i = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Do _GDIPlus_GraphicsClear($hCtxt, 0xFF000000 + $iBgColor) _GDIPlus_GraphicsDrawRect($hCtxt, $iPosX, $iPosY, $iWidth, $iHeight, $hPen) $hPos = GUIGetCursorInfo($hGUI) _GDIPlus_GraphicsDrawEllipse($hCtxt , $iWh1, $iHh1 , 1 ,1, $hPen2 ) ; circle1 _GDIPlus_GraphicsDrawEllipse($hCtxt , $iWh1 - 15, $iHh1 - 15, 30 , 30 , $hPen) ; circle2 _GDIPlus_GraphicsDrawEllipse($hCtxt , $iWh1 - 15 + Cos($fAngle * $fDeg) * $iRadius ,$iHh1 - 15 + Sin($fAngle * $fDeg) * $iRadius , 30 , 30 , $hPen) $iX1 = $iWh1 + Cos($fAngle3 * $fDeg) * $iRadius $iY1 = $iHh1 + Sin($fAngle3 * $fDeg) * $iRadius $iX2 = $iWh1 + Cos($fAngle3 * $fDeg + 180) * $iRadius $iY2 = $iHh1 + Sin($fAngle3 * $fDeg + 180) * $iRadius ;tangent1 $i = 0.1 ;value depends on $iRadius2! $iX1 = $iWh1 + Cos($fAngle * $fDeg + $i) * $iRadius2 $iY1 = $iHh1 + Sin($fAngle * $fDeg + $i) * $iRadius2 $iX2 = $iWh1 + Cos((180 + $fAngle) * $fDeg - $i) * $iRadius2 $iY2 = $iHh1 + Sin((180 + $fAngle) * $fDeg - $i) * $iRadius2 _GDIPlus_GraphicsDrawLine($hCtxt, $iX1, $iY1, $iX2, $iY2, $hPen) ;tangent2 $i = -0.1 ;value depends on $iRadius2! $iX1 = $iWh1 + Cos($fAngle * $fDeg + $i) * $iRadius2 $iY1 = $iHh1 + Sin($fAngle * $fDeg + $i) * $iRadius2 $iX2 = $iWh1 + Cos((180 + $fAngle) * $fDeg - $i) * $iRadius2 $iY2 = $iHh1 + Sin((180 + $fAngle) * $fDeg - $i) * $iRadius2 _GDIPlus_GraphicsDrawLine($hCtxt, $iX1, $iY1, $iX2, $iY2, $hPen) $fAngle += 1 $fAngle2 += 1 $fAngle3 += 1 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) Until Not Sleep(10) Func _Exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc1 point
-
Alex, please wait at least 24 hours before bumping a thread. This is no 24/7/365 service hotline1 point
-
It's not that bad. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hProgram2 = GUICreate("Program 2", 810, 330) GUISetBkColor("0x9A9A9A", $hProgram2) Local $aLabels = _GUICtrlsMatrix_Create(5, 5, 50, 20, 15, 15) GUISetState( @SW_SHOW, $hProgram2 ) Local $hProgram1 = GUICreate( "Program 1", 200, 100, 100, 100 ) Local $idColors = GUICtrlCreateButton( "Set colors", 50, 30, 100, 40 ) GUISetState( @SW_SHOW, $hProgram1 ) Local $j = 0 While 1 Switch GUIGetMsg() Case $idColors While $j < 25 For $i = 0 To 999 GUICtrlSetBkColor( $aLabels[$i], Random(0,255,1)+256*Random(0,255,1)+256*256*Random(0,255,1) ) Next $j += 1 WEnd $j = 0 Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hProgram2 ) GUIDelete( $hProgram1 ) EndFunc Func _GUICtrlsMatrix_Create($xPanelPos, $yPanelPos, $nrPerLine, $nrOfLines, $Width, $Height, $xSpace = 1, $ySpace = 1) Local $aGuiControls[1000], $j = 0 For $i = 1 To $nrPerLine * $nrOfLines $row = Int($i / $nrPerLine) + Not(Not(Mod($i, $nrPerLine))) $col = $i - ($row * $nrPerLine - $nrPerLine) $left = $xPanelPos + (($Width + $xSpace) * $col) - ($Width + $xSpace) $top = $yPanelPos + (($Height + $ySpace) * $row) - ($Height + $ySpace) $aGuiControls[$j] = GUICtrlCreateLabel("", $left, $top, $Width, $Height) GUICtrlSetBkColor(-1, "0xFFFFFF") $j += 1 Next Return $aGuiControls EndFunc1 point
-
If you get nothing then there is nothing Which is the active Window when you run the script? How do you run the script (compiled from Windows Explorer, from SciTE ...)?1 point
-
#include <Array.au3> Local $s = _ "2.1. This is 1st line" & @CRLF & _ "2.2. This is 2nd line [5,4]" & @CRLF & _ "4.2.1 This is 3rd line [5.5]" & @CRLF & _ "4.2.2. This is 4th line [5½]" Local $a1 = StringRegExp($s, "(?m)^((?:\d+\.?)+)\h+([^\[\v]+)(?|\h+\[([^\]]+)\]|())$", 3) $a2 = _ArrayDiv($a1, 3) _ArrayDisplay($a2) ;==================================== Func _ArrayDiv($array, $div, $cols = $div) If Mod(UBound($array), $div) <> 0 Then Return SetError(1, 0, 0) If $cols < $div Then Return SetError(2, 0, 0) Local $tmp[UBound($array)/$div][$cols] For $i = 0 to UBound($array)-1 step $div For $j = 0 to $div-1 $tmp[$i/$div][$j] = $array[$i+$j] Next Next Return $tmp EndFunc1 point
-
LarsJ, No idea - and until we get some more information on exactly what is the link between the external processes and the labels I would argue that we cannot sensibly test which is better. I was intending to run some tests on the 3 basic ideas with largish number of labels later this week (today and tomorrow are already reserved for golf) so that we could at least see if they were feasible at a larger scale - and how they compared in terms of speed. M231 point
-
peggy, Glad I could help - it was a fun problem to solve. M231 point
-
Forum Rules
edenwheeler reacted to Jon for a topic
We want the forum to be a pleasant place for everyone to discuss AutoIt scripting, and we also want to protect the reputation of AutoIt. So we ask you to respect these simple rules while you are here: Forum Posting 1. Do not ask for help with AutoIt scripts, post links to, or start discussion topics on the following subjects: Malware of any form - trojan, virus, keylogger, spam tool, "joke/spoof" script, etc. Bypassing of security measures - log-in and security dialogs, CAPTCHAs, anti-bot agents, software activation, etc. Automation of software/sites contrary to their EULA (see Reporting bullet below). Launching, automation or script interaction with games or game servers, regardless of the game. Running or injecting any code (in any form) intended to alter the original functionality of another process. Decompilation of AutoIt scripts or details of decompiler software. This list is non-exhaustive - the Moderating team reserve the right to close any thread that they feel is contrary to the ethos of the forum. 2. Do not post material that could be considered pornographic, violent or explicit - or express personal opinions that would not be acceptable in a civilized society. Do not post any copyrighted material unless the copyright is owned by you or by this site. 3. To protect this community, any files posted by you are subject to checks to ensure that they do not contain malware. This includes, but is not limited to, decompilation and reverse engineering. 4. Do not flame or insult other members - and just report the thread to a Moderator (see below) if you are so attacked. 5. Do not PM other users asking for support - that is why the forum exists, so post there instead. 6. Do not create multiple accounts - if you inadvertently created multiple accounts then contact a Moderator to close the unwanted ones. 7. Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above. 8. Do not delete your posts, nor completely remove their content, if doing so will interrupt the flow of the thread. 9. Do not post in a thread while the Moderating team are actively trying to determine whether it is legal. The Moderation team will do their best to act in fair and reasonable manner. Sanctions will only be applied as a last resort and any action taken will be explained in the relevant thread. If moderation action is taken, you will need to acknowledge this through a dialog or you will be unable to post further in the forum. Please note that this dialog is not an agreement that the warning was justified - it is only there so that members are aware that moderation action has been taken and that they may have certain restrictions applied to their account. If you feel that you have been unfairly moderated then contact the Moderator concerned - using a PM or the "Report" button is preferable to opening a new thread (although new members may have to do this). But do be aware that the Moderation team has the final word - the rules are set out by the site owner and you are only welcome here if you respect his wishes. Signatures and Avatars There is no formal policy for the use of signatures but if a moderator thinks it is too big and/or distracting then you may be asked to tone it down. No-one likes wading through signatures that are a page high. Similarly for avatars, expect distracting flashing and animated gifs to be removed. Reporting If you feel a post needs Moderator attention, please use the "Report" button next to the post date at the top. You can then enter details of why you have reported the post - but there is no need to include the content of the post as that is done automatically. The Moderating team will be alerted to the post and will deal with it as soon as they can. If you suspect a EULA violation, do not expect the Moderating team to do all the work - please provide some evidence in the report such as a copy of (or link to) the EULA in question, as well as the section you believe has been violated. Finally, please do not enter into an argument with the original poster - that is why we have Moderators. Spam Please do not react to spam in any way other than reporting it. Multiple reports are combined by the forum software, so there is no need to announce that you have reported the spam - in fact doing so only increases the work for the Moderator who deals with it. Interacting with this website Anyone found abusing the website is subject to harsh punishment without warning. A non-exhaustive list of potential abuses include: Automated forum registration or login. Automated posting or sending messages on the forum. Automated manipulation of polls, user reputation or other forum features. Automated creation or comments on issue tracker tickets. Automated creation or editing of wiki pages. Other abuses which are either examples of excessive bandwidth usage or automation of the site. Use common sense. If you do not have common sense, don't do anything. Do not automate the forum, wiki or issue tracker in any way at all. Scripts which automatically update AutoIt such as AutoUpdateIt are acceptable as long as they are not abused and do not generate excessive bandwidth usage.1 point -
This worked for me on W7 note that @WindowsDir return the path with no "" at the end. you must include that at the beginning of the "Fonts" folder. #Include <APIConstants.au3> #Include <StaticConstants.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) dim $font, $source $source="\\server\Apps\NewInstalls\fonts\AllFonts\" ; plug the location of you fonts FileCopy($source&'addict.ttf', @WindowsDir & "\Fonts",1) $font = @WindowsDir & '\Fonts\ADDICT.TTF' _WinAPI_AddFontResourceEx($font)1 point
-
Just stumbled across this when i was searching for help with the exact same project. im also working on a server/client remote control as such that will control my media server - RD is a pain when it logs off Currently stuck on getting an image into the gui so i can actually see where im clicking when the other comp isnt next to me well anyways this is what i have. hope it helps you! Send.au3 #include <Misc.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> TCPStartup() $ip = InputBox("Address", "ip", "192.168.0.2", " M") $_sock = TCPConnect($ip, 33891) If @error Then Exit MsgBox(16, "Wsa:" & @error, "Unable to connect to the host!") $click = "" Do $recv = TCPRecv($_sock, 1000) If @error Then Exit MsgBox(16, "WSA:" & @error, "Lost connection!") Sleep(1) Until $recv <> "" TCPSend($_sock, "OK") $stat = StringSplit($recv, "|") $GUI = GUICreate("Remotey", $stat[1], $stat[2], 0, 0,$WS_SYSMENU, $WS_EX_TOPMOST) $gui_graphic = GUICtrlCreatePic($GUI, 0, 0, $stat[1], $stat[2] + 20) GUISetState() While 1 $pos = GUIGetCursorInfo() If _IsPressed(01) Then $click = "Lclick" If _IsPressed(02) Then $click = "Rclick" TCPSend($_sock, $pos[0] & "|" & $pos[1] & "|" & $click) $click = "" ToolTip($pos[0] & "|" & $pos[1] & "|" & $click, 0, 0) If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit Sleep(1000) WEnd Recive.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> Opt('MustDeclareVars', 1) ; Set Some reusable info ; Set your Public IP address (@IPAddress1) here. ; Local $szServerPC = @ComputerName ; Local $szIPADDRESS = TCPNameToIP($szServerPC) Local $szIPADDRESS = @IPAddress1 Local $nPORT = 33891 Local $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted Local $msg, $recv, $recv2 Local $pos ; Start The TCP Services ;============================================== TCPStartup() ; Create a Listening "SOCKET". ; Using your IP Address and Port 33891. ;============================================== $MainSocket = TCPListen($szIPADDRESS, $nPORT) ; If the Socket creation fails, exit. If $MainSocket = -1 Then Exit ; Create a GUI for messages ;============================================== $GOOEY = GUICreate("My Server (IP: " & $szIPADDRESS & ")", 300, 200) $edit = GUICtrlCreateEdit("", 10, 10, 280, 180) GUISetState() ; Initialize a variable to represent a connection ;============================================== $ConnectedSocket = -1 ;Wait for and Accept a connection ;============================================== Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 ; Get IP of client connecting $szIP_Accepted = SocketToIP($ConnectedSocket) Do TCPSend($ConnectedSocket, @DesktopWidth & "|" & @DesktopHeight) $recv2 = TCPRecv($ConnectedSocket, 1000) If @error Then Exit MsgBox(16, "WSA:" & @error, "Lost connection!") Sleep(1) Until $recv2 <> "" ; GUI Message Loop ;============================================== While 1 $msg = GUIGetMsg() ; GUI Closed ;-------------------- If $msg = $GUI_EVENT_CLOSE Then ExitLoop ; Try to receive (up to) 2048 bytes ;---------------------------------------------------------------- $recv = TCPRecv($ConnectedSocket, 2048) ; If the receive failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop ; Update the edit control with what we have received ;---------------------------------------------------------------- If $recv <> "" Then GUICtrlSetData($edit, $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit)) $pos = StringSplit($recv, "|") MouseMove($pos[1], $pos[2]) If $pos[3] = "Lclick" Then MouseClick("left") If $pos[3] = "Rclick" Then MouseClick("right") EndIf WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() ; Function to return IP Address from a connected socket. ;---------------------------------------------------------------------- Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP1 point
-
At least this shows that he used the search.1 point
-
So far i have find the problem: You write this ;Draw the loaded image onto the blank bitmap at the size you want _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iW) and the correction is ;Draw the loaded image onto the blank bitmap at the size you want _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH) It's just a typing error $iW instead of $IH Now it work great ! thank's.1 point
-
Bit late but here's a function to resize #include <GDIPlus.au3> _ImageResize("C:\WINDOWS\Web\Wallpaper\bliss.bmp", @ScriptDir & "\Bliss.jpg", 400, 300) Func _ImageResize($sInImage, $sOutImage, $iW, $iH) Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0 ;OutFile path, to use later on. Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1)) ;OutFile name, to use later on. Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1) ;OutFile extension , to use for the encoder later on. Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1)) ; Win api to create blank bitmap at the width and height to put your resized image on. $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) ;Start GDIPlus _GDIPlus_Startup() ;Get the handle of blank bitmap you created above as an image $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP) ;Load the image you want to resize. $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage) ;Get the graphic context of the blank bitmap $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) ;Draw the loaded image onto the blank bitmap at the size you want _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iW) ;Get the encoder of to save the resized image in the format you want. $CLSID = _GDIPlus_EncodersGetCLSID($Ext) ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image. Do $i += 1 Until (Not FileExists($sOP & $i & "_" & $sOF)) ;Prefix the number to the begining of the output filename $sOutImage = $sOP & $i & "_" & $sOF ;Save the new resized image. _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID) ;Clean up and shutdown GDIPlus. _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc Cheers1 point