Write username in a document

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
W8ne3
Posts: 4
Joined: 28 Mar 2019, 02:11

Write username in a document

28 Mar 2019, 02:28

A worte a script for my company. Now i want to read who runs my script.
My plan is:
When a user is opening/starting my Autohotkey.exe, in the background the script should write the Username in a excel/csv data.
It should not open a file in the foreground.
I need a list of all people who are runing my skript.
The username i will get with %A_UserName%
But i dont know how to get it into a excel or csv data.

thx
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Write username in a document

28 Mar 2019, 02:59

Hello and welcome to the AHK-forum.
Your task ist not so difficult, but leaking too much information, so I give you a simple way using Windows-clipboard.
Just store the username into clipboard and paste it manually where ever you want.

Code: Select all

F6::
clipboard := A_UserName
return
As you can see, pressing F6 stores username into clipboard and your next step is positioning the cursor and pressing CTRL+v for pasting with Windows function.

With more information, more automated scripts can be made.
Einfach nur ein toller Typ. :mrgreen:
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Write username in a document

28 Mar 2019, 04:20

W8ne3 wrote:
28 Mar 2019, 02:28
A worte a script for my company. Now i want to read who runs my script.
My plan is:
When a user is opening/starting my Autohotkey.exe, in the background the script should write the Username in a excel/csv data.
It should not open a file in the foreground.
I need a list of all people who are runing my skript.
The username i will get with %A_UserName%
But i dont know how to get it into a excel or csv data.

thx
Use COM for that. This can be automated in the background - it could be set up in a way that they would likely never notice.


you should be able to get close to what you are trying to achieve with this:

Code: Select all

filePath := A_Desktop "\yourCSV.csv" ; Specify file path 

,	Xl := ComObjCreate("Excel.Application") ; Create a new Active Excel instance - default window visibility is invisible window 
,	Xl.Workbooks.Open(filePath)	; Open existing Excel file
;,	Xl.Workbooks.Add	;	 <~~ use this if you want to create & open a new workbook

,	Xl.Range("A1").Value := "Username"	 ; overwrites Range "A1" with the string "Username"
,	Xl.Range("B1").Value := "TimeStamp"	 ; overwrites Range "B1" with the string "TimeStamp"
,	Xl.Range("A2").Value := A_UserName	 ; overwrites Range "A2" with currently logged in Username
,	Xl.Range("B2").Value := A_Now	 ; overwrites Range "B2" with YYYYMMDDHH24MISS format timestamp

,	Xl.ActiveWorkbook.Save	;	Save if file already exists
;,	Xl.Workbooks.SaveAs(Filepath)	; <~~ use this if you want to save it as something else, or when saving a new Excel file that doesn't have a name yet

,	Xl.ActiveWorkbook.Close	;	 closes the work book
,	Xl := ""	;	 frees the Excel Application object
return
-TL
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Write username in a document

28 Mar 2019, 04:31

But consider that, depending on the circumstances, surveilling your colleagues (without giving them notice) could be seen as non-collegial behavior.
I would always inform them that their usernames (or other infos) are getting logged (unless there are really good reasons no to do that). I would also check with the management about internal and general privacy rules (although the management might not even follow these rules themselves - but this is a different problem); these rules can vary immensely in different parts of the world, like all workers rights.
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Write username in a document

28 Mar 2019, 11:49

gregster wrote:
28 Mar 2019, 04:31
But consider that, depending on the circumstances, surveilling your colleagues (without giving them notice) could be seen as non-collegial behavior.
I would always inform them that their usernames (or other infos) are getting logged (unless there are really good reasons no to do that). I would also check with the management about internal and general privacy rules (although the management might not even follow these rules themselves - but this is a different problem); these rules can vary immensely in different parts of the world, like all workers rights.
I mentioned that it could be used in a way that they would not notice because it seemed like they wanted it to be somewhat hidden ("not open in foreground") - maybe not even as a privacy or incognito thing, but merely to lend itself to a consistent/uninterrupted user experience.

Definitely, if it's not a necessity for your employer to hide this from employees, letting them know they are being monitored is definitely the most ethical way of going about this.

I know that at my place of employment, our work computers are brought home with us often (well I work from home exclusively), and we all know that we are always being monitored.. so doesn't bother me that info/data on here may be being collected as a security measure. Your employer should line these kinds of things out during your hiring/onboarding phase.

I am of the mindset though that there is a huge problem with the way that our personal data is being taken and utilized against us with and without our knowledge. For some reason, the majority of us have been sheephearded into beleiving that our private data is not that valuable. I believe our data is extremely valuable and we are taking it for granted while others make a profit off uniquely you.
-TL
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Write username in a document

28 Mar 2019, 12:03

Good points. And slightly offtopic I might add that people are often, especially with their private data, surprisingly irrational - they sometimes care about certain minor things while they give away huge amounts of data freely in other settings. (Actually, not surprisingly irrational - because that's how humans often are. But it shows how people can be tricked.) Of course, work requirements can be a different thing.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: LepG, mapcarter, OrangeCat and 249 guests