Leaderboard
Popular Content
Showing content with the highest reputation on 04/16/2020 in all areas
-
Mimicking Wordpad using RichEdit
mLipok reacted to InunoTaishou for a topic
As the title implies, trying to mimic Microsoft Word (Older version) using RichEdit. Not an easy task, it's not even 1/10th of what word really is but I wanted to make a small text editor (That supported changing an individual word/letters properties). Some of the functions I wanted to use didn't have a whole lot of information/topics about them so I spent many many hours trying to figure out how to do some things... (Like getting the text from a ExComboBox or changing the color of the rich edit text without changing ALL of the rich edit text (Turns out I just needed to update my AutoIt version....)) Some of the things I struggled with was reading the Font Size from the ComboBoxEx (GUICtrlRead and ControlGetText do not work, by themselves, but if you use _GUICtrlComboBoxEx_GetEditControl to get the GUICtrlID of the ComboBoxEx you can use ControlGetText), trying to track a Popup menu for the font size (I didn't want to use a dropdown menu, trying to use the scroll wheel to increment/decrement the text in the ComboBoxEx, making sure the correct attribute buttons are Checked depending on the location of the caret (This isn't 100% perfect, I got it to pretty much work though... I originally had it checking the letter 1 left of the caret all the time, except when the caret is at the 0,0 mark, but if the caret is at the very end and the user presses one of the attribute buttons, it won't keep the button checked correctly). There are a few other things but I can't think of them. I don't know enough about the WinAPI in order to make a truly amazing wordpad but maybe this will help some others out there trying to use some of the controls I used. Also, this was actually made to be attached (_WinAPI_SetParent($frmEditor, WinGetHandle("[Class:LWJGL]")) to a game I play (PokeMMO), so there may be some remnants of the game stuff in here. I don't think so, but there might be... It still functions properly. (There is no gameplay automation, it's just supposed to be a child of the game and work as a simple text editor. I've currently submitted it to one of mods of the game so I can release it to the community) Beginnings of a Wordpad.rar1 point -
Subclassing _WinAPI_BrowseForFolderDlg
argumentum reacted to MrCreatoR for a topic
Ok, first task completed (getting the selected checkboxes), it was easier then i thought. Even without the subclassing: #include <WindowsConstants.au3> #include <WinAPIDlg.au3> #include <GUITreeView.au3> Global $sPrev_Path, $sChecked $sInitDir = @ProgramFilesDir $sRoot = _WinAPI_PathStripToRoot($sInitDir) $hBrowseProc = DllCallbackRegister('_BrowseProc', 'int', 'hwnd;uint;lparam;ptr') $pBrowseProc = DllCallbackGetPtr($hBrowseProc) $pText = _WinAPI_CreateString($sInitDir) $sPath = _WinAPI_BrowseForFolderDlg($sRoot, 'Select a folder from the list below.', BitOR($BIF_RETURNONLYFSDIRS, $BIF_UAHINT, $BIF_BROWSEINCLUDEFILES, $BIF_VALIDATE, $BIF_NEWDIALOGSTYLE, $BIF_NONEWFOLDERBUTTON), $pBrowseProc, $pText) _WinAPI_FreeMemory($pText) If $sPath Then ConsoleWrite($sChecked & @CRLF) ;ConsoleWrite('--------------------------------------------------' & @CRLF) ;ConsoleWrite($sPath & @CRLF) EndIf DllCallbackFree($hBrowseProc) Func _BrowseProc($hWnd, $iMsg, $wParam, $lParam) Local $sPath Local Static $hLastItem, $hTV = ControlGetHandle($hWnd, '', 'SysTreeView321') Switch $iMsg Case $BFFM_INITIALIZED ;Set checkboxes _WinAPI_SetWindowLong($hTV, $GWL_STYLE, BitOR(_WinAPI_GetWindowLong($hTV, $GWL_STYLE), $TVS_CHECKBOXES)) ;Set title _WinAPI_SetWindowText($hWnd, 'MyTitle') ;Set default selection _SendMessage($hWnd, $BFFM_SETSELECTIONW, 1, $lParam) Case $BFFM_SELCHANGED If $hLastItem Then _StringUpdate($sChecked, $sPrev_Path, _GUICtrlTreeView_GetChecked($hTV, $hLastItem)) EndIf $hLastItem = _GUICtrlTreeView_GetSelection($hTV) $sPath = _WinAPI_ShellGetPathFromIDList($wParam) If Not @error Then $sPrev_Path = $sPath EndIf EndSwitch Return 0 EndFunc Func _StringUpdate(ByRef $sString, $sValue, $bAdd, $bUnique = True, $sDelim = Default) If $sDelim == Default Then $sDelim = Opt('GUIDataSeparatorChar') EndIf If $bAdd Then If Not $bUnique Or ($bUnique And Not StringInStr($sDelim & $sString & $sDelim, $sDelim & $sValue & $sDelim, 2)) Then $sString &= ($sString ? $sDelim : '') & $sValue EndIf Return EndIf ;Remove If StringInStr($sDelim & $sString & $sDelim, $sDelim & $sValue & $sDelim, 2) Then Local $aString = StringSplit($sString, $sDelim) $sString = '' For $i = 1 To $aString[0] If $aString[$i] <> $sValue Then $sString &= ($sString ? $sDelim : '') & $aString[$i] EndIf Next EndIf EndFunc Now there is another task: How to pre-set the checkboxes from a similar paths list?1 point -
Don't loose your time. Do not search for Windows to do it, as you will not find anything. My solution is probably the best you can find.1 point
-
As @Exit said, it will create a new file, but the problem is that the key sequence changes from one language to another. Also on some circumstances, you could have 2 shortcut keys in the popup menu. But you are lucky, I made some times ago this script, maybe you will like it : #NoTrayIcon #include <Constants.au3> #include <WinAPISysWin.au3> #include <File.au3> #include <WinAPIFiles.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> HotKeySet ("^+{END}", _Exit) HotKeySet ("^+a", _NewAu3) While True Sleep (100) WEnd Func _NewAu3 () Local $hWnd = WinGetHandle ("[ACTIVE]") Local $sClass = _WinAPI_GetClassName ($hWnd) Local $sCurrentDir, $sFileName Switch $sClass Case "Progman" $sCurrentDir = @DesktopDir Case "CabinetWClass" If Not ControlCommand ($hWnd, "", "Edit1", "IsVisible", "") Then ControlClick ($hWnd, "", "ToolbarWindow322", "left", 1, 10, 20) Sleep (800) EndIf $sCurrentDir = ControlGetText($hWnd, "", "Edit1") ConsoleWrite ($sCurrentDir & @CRLF) If Not FileExists($sCurrentDir) Then Return MsgBox ($MB_SYSTEMMODAL,"Error","Select one folder only") Case Else Return EndSwitch $sFileName = ShowGUI () If @error Then Return $sFileName = MakeUniqueFileName ($sCurrentDir & "\" & $sFileName) ConsoleWrite ($sFileName & @CRLF) If FileExists (@WindowsDir & "\ShellNew\Template.au3") Then ConsoleWrite ("Template exists" & @CRLF) FileCopy (@WindowsDir & "\ShellNew\Template.au3", $sFileName) Else _FileCreate ($sFileName) EndIf EndFunc Func _Exit () Exit EndFunc Func MakeUniqueFileName ($sFile) Local $sDrive, $sDir, $sFileName, $sExtension, $iCount = 1 _PathSplit ($sFile, $sDrive, $sDir, $sFileName, $sExtension) $sFile = $sFileName While FileExists ($sDrive & $sDir & $sFileName & $sExtension) $iCount += 1 $sFileName = $sFile & " (" & $iCount & ")" WEnd Return $sDrive & $sDir & $sFileName & $sExtension EndFunc Func ShowGUI () Local Const $NEW_AU3_NAME = ".au3" Local $hGUI = GUICreate("", 300, 65, -1, -1, $WS_BORDER+$WS_POPUP) GUISetBkColor (0xFF0000) Local $Label = GUICtrlCreateLabel("FileName", 18, 24, 60, 17) GUICtrlSetColor (-1, 0xFFFFFF) GUICtrlSetFont (-1, 10) Local $Input = GUICtrlCreateInput("", 85, 22, 193, 21) GUISetState(@SW_SHOW) ControlSetText($hGUI, "", $Input, $NEW_AU3_NAME) Local $sFile While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete () Return SetError (1) Case $Input $sFile = GUICtrlRead ($Input) If StringLeft ($sFile, 1) = "." Then ContinueLoop GUIDelete () Return $sFile EndSwitch WEnd EndFunc1 point
-
_GDIPlus_HICONCreateFromBitmap(), _WinAPI_SaveHICONToFile() may help...1 point
-
I want my script working ONLY during holding "N" button
FrancescoDiMuro reacted to Danp2 for a topic
1 point -
"Appskey> N> A" does not create a shortcut but a new file. A free area on the desktop or in Explorer must be in focus.1 point
-
A free area on the desktop or in Explorer must be in focus. APPSKEY --> N --> A Appskey is a small icon depicting a pointer hovering above a menu, and it is typically found on the right side of the keyboard between the right Windows Logo Key and the right Control Key (or between the right Alt Key and the right Control Key).1 point
-
Here a workaround: #include <StaticConstants.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $hImage1 = _GDIPlus_ImageLoadFromFile("giftest-notrans.gif"), $hGDIBmp1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1), _ $hImage2 = _GDIPlus_ImageLoadFromFile("giftest-trans.gif"), $hGDIBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage2), _ $hImage3 = _GDIPlus_ImageLoadFromFile("giftest-bmp.bmp"), $hGDIBmp3 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage3) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_ImageDispose($hImage3) _GDIPlus_Shutdown() $hGUI = GUICreate('', 300, 200) $Pic1 = GUICtrlCreatePic("", 0, 0, 100, 100) $Pic2 = GUICtrlCreatePic("", 200, 0, 100, 100) $Pic3 = GUICtrlCreatePic("", 100, 100, 100, 100) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBmp1)) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic2, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBmp2)) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic3, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBmp3)) GUISetState() AdlibRegister(_RandomBG, 100) Do Until GUIGetMsg() = -3 _WinAPI_DeleteObject($hGDIBmp1) _WinAPI_DeleteObject($hGDIBmp2) _WinAPI_DeleteObject($hGDIBmp3) Func _RandomBG() GUISetBkColor(Random(0, 0xffffff, 1)) EndFunc1 point
-
The code in this post is slightly updated to show the top window as the first level. UIA_Constants.au3 can be copied from UI Automation UDFs.1 point
-
@LarsJ, Thanks. Like I said, I've been trying to understand recursive use of Treewalker() for what seems like weeks. I've still got to study your code in detail but I'm finally headed in the right direction.1 point
-
MouseClick is not your best strategy to automate something. What exactly are you trying to do ? Probably there is a better solution.1 point
-
Ventana de Ping Flotante - (Moved)
FrancescoDiMuro reacted to TheXman for a topic
Here's an over-simplified example that shows you some basic concepts involved in achieving your goal: (Press ESC to Exit) Change the threshold value to meet your needs. For me, the ping value is around 6ms. That allows me to see it turn red every once in a while when it exceeds 6ms. I didn't take into account any of the transparency stuff, just the pinging and changing the color of the value when the threshold is exceeded. Global $frmMain = GUICreate("Ping Test", 196, 96, -1, -1) Global $Label1 = GUICtrlCreateLabel("Ping (ms):", 8, 16, 60, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $lblPingTime = GUICtrlCreateLabel("", 72, 16, 68, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $Label2 = GUICtrlCreateLabel("ESC to QUIT", 8, 60, 150, 17) Global Const $PING_THRESHOLD_MS = 7 ;<== Change threshhold to meet needs Global $iPingMs = 0 HotKeySet("{esc}", terminate) GUISetState(@SW_SHOW) While 1 ;Ping host $iPingMs = Ping("www.google.es") If @error Then ConsoleWrite("Ping error - @error = " & @error & @CRLF) ExitLoop EndIf ;Update ping label GUICtrlSetData($lblPingTime, $iPingMs) ;Set label color based on whether threshhold is exceeded If $iPingMs > $PING_THRESHOLD_MS Then GUICtrlSetColor($lblPingTime, 0xFF0000) ;Red Else GUICtrlSetColor($lblPingTime, 0x06722E) ;Dark Green EndIf ;Wait a bit before next loop Sleep(500) WEnd Func terminate() Exit EndFunc1 point -
This topic will contain simple and working client server communication example along with some basic info for understanding. Examples are based on multi client communication that is happening on one computer (localhost). Changing (if it's not already set correctly) the IP address parameter on server script to reflect your network device IP address will allow you to communicate with other clients on network or even to communicate on internet if your network settings (forwarded router port, ip address on that port is seen from others on internet, you're not trying to do client server from identical computer on identical internet connection) are configured correctly. Every client connecting will need to have server IP address for network (or server public IP address for internet) connection in his client script. So edit client script to correspond to server address TCPConnect('type server ip address in client', 1018). Sometimes firewall can be your problem, if something isn't working turn off firewall and see if it helps. Server will always listen on his Network Adapter IP Address and not on his public address. In some rare occasions server can be set to listen on 0.0.0.0, with that he will listen from any device that he have physically connected on his MB USB or something third (with localhost included for listening). But i would not know the end result of what will happen if some other program that you have installed need that port (or you started 2 servers that interpret one with another). First part will hold just plain code.Second part will hold identical code with comments below commands for more info and understanding hopefully to help new autoit users to understand what and why that something is there.Other parts will hold additional info.First part: Working Code (working in two way communication, with multiple and-or identical client)Server #include <Array.au3> TCPStartup() Dim $Socket_Data[1] $Socket_Data[0] = 0 $Listen = TCPListen(@IPAddress1, 1018, 500) If @error Then ConsoleWrite('!--> TCPListen error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPListen to get more info about this error.' & @CRLF) Exit EndIf While 1 For $x = $Socket_Data[0] To 1 Step -1 $Recv = TCPRecv($Socket_Data[$x], 1000000) If $Recv Then MsgBox(0, 'Client Number ' & $x & ' with connected socket identifier ' & $Socket_Data[$x], 'Recived msg from Client: ' & @CRLF & $Recv, 5) TCPSend($Socket_Data[$x], 'bye') TCPCloseSocket($Socket_Data[$x]) _ArrayDelete($Socket_Data, $x) $Socket_Data[0] -= 1 EndIf Next _Accept() WEnd Func _Accept() Local $Accept = TCPAccept($Listen) If $Accept <> -1 Then _ArrayAdd($Socket_Data, $Accept) $Socket_Data[0] += 1 EndIf EndFunc ;==>_AcceptClient TCPStartup() $Socket = TCPConnect(@IPAddress1, 1018) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.' & @CRLF) Exit EndIf TCPSend($Socket, 'Hi there. My computer name is' & ", " & @ComputerName & ", and its drive serial is " & DriveGetSerial(@HomeDrive)) Do $Recv = TCPRecv($Socket, 1000000) Until $Recv MsgBox(0, 'Recived from server:', $Recv)Second part: Explained Working Code (for upper communication) Third Part: Understanding for how is msg received with TCPRecv on server (or on client) Forth Part: Packets Fifth Part: How to get or check IP address of your device? Sixth Part: How to forward ports? (2 nice youtube tutorials) Seventh Part: Internet communication? If i wrote something incorrectly or wrong please tell me so that i can correct it. Edited: Local and Global, added aditional info about reciving msgs for maxlen buffer.1 point