Jump to content

Recommended Posts

Hi guys,
you can know the @namecomputer or ip address of the client who opened a notepad file?

I created a chat through a shared notepad .. and I thought of adding an edit "who is online" ..

here it is the code: :lmao:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GuiButton.au3>
#include <TrayConstants.au3>
#include <Color.au3>
#include <ColorConstants.au3>
#include <ButtonConstants.au3>
#include <GUIComboBox.au3>
#Include <GuiComboBoxEx.au3>
#include <GuiConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <GuiTreeView.au3>
#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <GuiEdit.au3>
#include <Array.au3>
#include <Misc.au3>
#include <ColorConstantS.au3>

Local $hDLL = DllOpen("user32.dll")

FileInstall("C:\birra.ico",@TempDir & "\birra.ico")
GUISetIcon(@TempDir & "\birra.ico", -1)

Global $sFileToCheck = "\\\cond\chat.txt"
Global $bFileChanged = False
Global $sFileDateTime = _ArrayToString(FileGetTime($sFileToCheck))
AdlibRegister("_CheckFile", 250)

$FormComunicazioni = GUICreate("NAME CHAT", 450, 500, -1, -1)
GUISetFont(11, 400, 0, "Calibri")
$EditComunicazioni = GUICtrlCreateEdit("",20, 20, 410, 350, BitOR($ES_READONLY, $CBS_AUTOHSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "- Chat" & " " & @MDAY & "\" & @MON & "\" & @YEAR)
$AggiornaComunicazioni = GUICtrlCreateButton("recupera conversazione iniziale", 20, 385, 200, 30)
$edit = GUICtrlCreateEdit("", 20, 430, 340, 55, BitOR($CBS_AUTOHSCROLL, $WS_VSCROLL))
$invia = GUICtrlCreateButton("Invia", 365, 428, 67, 58)


While 1
   If $bFileChanged Then
      $file= FileOpen ("\\\cond\chat.txt",0)
      $last_line = FileReadLine ($file, -1)
      _GUICtrlEdit_AppendText($EditComunicazioni, @CRLF & $last_line)
      $sFileDateTime = _ArrayToString(FileGetTime($sFileToCheck))
      $bFileChanged = False
      TrayTip("Stranguglie e previdi", "è presente un nuovo messaggio", 0, $TIP_ICONASTERISK)
   $nMsg = GUIGetMsg()
   Switch $nMsg
   Case $invia
      FileWrite("\\\cond\chat.txt", @CRLF & "[" & @UserName & "]" & " scrive: " & ClipGet())
   Case $AggiornaComunicazioni
      $file = FileOpen("\\\cond\chat.txt", 0)
      $FileContent = FileRead($file)
      _GUICtrlEdit_AppendText($EditComunicazioni, @CRLF & @CRLF & $FileContent)
      GUICtrlSetState($AggiornaComunicazioni, $GUI_DISABLE)


Func _CheckFile()
    If $sFileDateTime <> _ArrayToString(FileGetTime($sFileToCheck)) Then $bFileChanged = True


Link to post
Share on other sites

you can't. that's because the text file does not remain open while you edit it; it is opened (and closed) only when you save.

but, if you rely on a central file, then you can expand the idea to use another file - a file that each client writes its hostname and username to when launched. so each client can read that file to know who wrote to it.

Link to post
Share on other sites

you have a variable named $sFileToCheck in your script. add another one - call it $sFileOfStats, set it to the same path (and a different name, of course). when your script begins, write to it your hostname, username or whatever.  read it once to see who already wrote to it. at run time, check it for changes to see if anyone wrote anything new. when you close, write that also.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Rskm
      Hi, I have 5 notepad files with lot of data in each of it. The data are arranged in lines and i wish to get it pasted/copied into excel.  Say, i need to read notepad1 and paste the contents into sheet1 of excel and notepad2 to sheet2 and so on.  If i read the notepad and paste it line by line, it is taking lot of time.  Is there a way by which i can paste the whole of notepad file into excel sheet(and get it pasted line by line as shown in the attached excel), instead of using code to write it line by line?.. I was using Filewriteline(data, line i) initially to write to excel.  The 'i' value was incremented with for loop and the excel was updated, but this takes lot of time.  The expected excel format is attached here.  any help is appreciated.  thanks
    • By Langmeister
      Hi, I'm sure that this is a simple question regarding webdriver udf but my search on the forum did not result in the exact same scenario that I need. I will adapt it to my corporate needs but at first I want it to work with an example everybody can reproduce if needed.
      I navigate to https://www.daysoftheyear.com/ and want to find out what special day today is. Using the following Code returns the wanted text that today is 'shark awareness day' in the console but it is not pasted in notepad as it is not copied as it probably should be.
      #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.daysoftheyear.com/?timezone_offset=nan") _WD_LoadWait($sSession) Sleep(3000) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/header/div/div[1]/div/div[2]/h3/a") _WD_ElementAction($sSession, $sElement, 'text') ClipGet() Run("notepad.exe") Sleep(500) Send("^v") Scite returns this, therefore the text has been found but the last mile to paste it to notepad or excel does not work for me.
      __WD_Get: URL=HTTP:// __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"Shark Awareness Day"}... _WD_ElementAction: {"value":"Shark Awareness Day"}... Thanks in advance! 
    • By AZJIO
      My Notepad v0.4 (En, Ru)

      Black theme

      My_Notepad.7z (560kb sources + EXE)
      I wanted to make an example for the help file. But I could not stop, and made more complicated.
    • By Ronster
      I would like to create an auto login program using mouseclicks, controlclicks only, or whatever is required to send characters from Windows 10 On-Screen Keyboard to a User/Password login form. I thought I would start with OSK to NotePad. Using mouseclicks to enter ID/Password seems more secure than typing plain text. Seems like if I can get that to work I should be able to send the characters to any login form. I have tried many things but cannot send a character(s) from OSK to Notepad. Of course manually works great. Here is some code I have tried:
      ControlGetFocus ("Untitled - Notepad")
          ; go to Notepad window
          MouseMove(649, 206 , 0)  ;move to Notepad, then click below
          Sleep (1000)
          ControlGetFocus ("On-Screen Keyboard")
          ; go to OSK window then click on a character key
          MouseMove(642, 807 , 0) ;letter - t
          Sleep (1000)
      ControlClick("On-Screen Keyboard","","[CLASS:OSKMainClass]","left","",642, 807)
      The above move to the correct position and appear to click but focus is lost to Notepad. Any help would be appreciated.
    • By SkysLastChance
      Run("notepad.exe") GLOBAL $One = ('Line1' & _ 'Line2' & _ 'Line3' & _ 'Line4' & _ 'Line5') ClipPut($One) $Notepad = WinWait("[CLASS:Notepad]", "", 10) ControlSend("Untitled - Notepad", "", "", ("^v")) Instead of having this paste as Line1Line2Line3Line4Line5
      How can I make it paste it into notepad as (without double spacing.)
  • Create New...