• Dear visitors,

    The email issue seems to have been finally solved.
    Thank you for your patience and happy browsing.

    Team ACM.

QUESTION app AC with getlogin (windows user name)

jerome30

New Member
Hello

I try to write some info on a file and put the file on the desktop
but we have not the same path for the desktop because windows use our login name for that.
so, if we see my script :

Code:
import os
user=os.getlogin()
save_folder = "C:\\Users\{}\Desktop\\".format(user)
this is work on PYHON 3.8 but not on ASSETTO (python 2.7.x)

any idea ? thanks
 

fughettaboutit

aka leBluem
Code:
import ctypes

userDir=''
ID_DOCS = 5 # My Documents
SH_TYPE = 0 # Get current, not default value
buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, ID_DOCS, None, SH_TYPE, buf)
userDir = buf.value # bingo, userdir/documents!
 

jerome30

New Member
you are really incredible ! thanks so much
it seems on the good way

the file was writted on the user folder, not desktop yet
I try it to change some infos, but it seems not work yet too

Code:
save_folder=''
ID_DOCS = 3 # My Documents  this is the way to put
SH_TYPE = 0 # Get current, not default value not interresting  finally
buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, ID_DOCS, None, SH_TYPE, buf)
save_folder = buf.value # bingo, userdir/desktop!
 
Top