Jump to content
RyukShini

Uploading files with AutoIT in Wordress

Recommended Posts

RyukShini

Hello everyone!

I am trying to make a script that uploads files for me in wordpress(All I need to do is to manually choose which files to upload)
Here is my script so far:
 

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Upload()

Func Upload()
    
    $sPD = "log=username&pwd=mypassword&wp-submit=Log+ind&redirect_to=http%3A%2F%2Fmyurl.com%2Fwp-admin%2F&testcookie=1"
oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://myurl.com/wp-login.php " & $sUSR, False) ; Post url
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
$oHTTP.SetRequestHeader("Accept-Language", "en-US,en;q=0.5")
$oHTTP.SetRequestHeader("User-Agent", "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.52 YaBrowser/15.12.2490.3614 (beta) Yowser/2.5 Safari/537.36")
$oHTTP.SetRequestHeader("Referer", "http://myurl.com/wp-login.php?redirect_to=http%3A%2F%2Fmyurl.com%2Fwp-admin%2F&reauth=1")
$oHTTP.SetRequestHeader("Cookie", "wordpress_test_cookie=WP+Cookie+check")
$oHTTP.SetRequestHeader("Connection", "keep-alive")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") ; Header data >


$oHTTP.Send($sPD)
$oHTTP.Open("GET", "http://myurl.com/wp-admin/media-new.php", False) ; Post url
$oHTTP.SetRequestHeader("Host", "myurl.com")
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0")
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
$oHTTP.SetRequestHeader("Accept-Language", "en-US,en;q=0.5")
$oHTTP.SetRequestHeader("Referer", "http://myurl.com/wp-admin/")
$oHTTP.Send()

Endfunc

The upload button = "Choose Files"

Example code from:

https://www.autoitscript.com/autoit3/docs/functions/FileOpenDialog.htm

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Select a single file of any type."

    ; Display an open dialog to select a file.
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file was selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the selected file.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following file:" & @CRLF & $sFileOpenDialog)
    EndIf
EndFunc   ;==>Example

The HTML:
 

<p class="drag-drop-buttons"><input style="position: relative; z-index: 1;" id="plupload-browse-button" value="Choose Files" class="button" type="button"></p>

Some header info in the HTTP request:
 

POST http://myurl.com/wp-admin/async-upload.php HTTP/1.1
Host: myurl.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://myurl.com/wp-admin/media-new.php
Content-Length: 4555551
Content-Type: multipart/form-data; boundary=---------------------------12345678910
Cookie: LONG COOKIE HERE!
DNT: 1
Connection: keep-alive

-----------------------------102062144610664
Content-Disposition: form-data; name="name"

hdfhfg.jpg
-----------------------------102062144610664
Content-Disposition: form-data; name="post_id"

0
-----------------------------102062144610664
Content-Disposition: form-data; name="_wpnonce"

123456
-----------------------------102062144610664
Content-Disposition: form-data; name="type"


-----------------------------102062144610664
Content-Disposition: form-data; name="tab"


-----------------------------102062144610664
Content-Disposition: form-data; name="short"

1
-----------------------------102062144610664
Content-Disposition: form-data; name="async-upload"; filename="hdfhfg.jpg"
Content-Type: image/jpeg

This wouldn't be much of a problem if I just had some simple post data, but this makes my head spin....

Thanks in advance Masters!

(I could probably easily do this with IE, but I'd rather not use IE, I am not a big fan of it)
 

Share this post


Link to post
Share on other sites
JLogan3o13

@RyukShini you posted what you want to do, and where you pulled your code from, but I see nothing regarding what is not working for you. Are you getting an error? Are the files just not uploading? How about some actual detail rather than having us guess ;)

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
RyukShini
3 hours ago, JLogan3o13 said:

@RyukShini you posted what you want to do, and where you pulled your code from, but I see nothing regarding what is not working for you. Are you getting an error? Are the files just not uploading? How about some actual detail rather than having us guess ;)

 

Everything is working, I made all this happen without a problem.
Now my problem is that I don't have a clue about this form of data on how to implement it in a http request with AutoIT:
 

-----------------------------102062144610664
Content-Disposition: form-data; name="name"

hdfhfg.jpg
-----------------------------102062144610664
Content-Disposition: form-data; name="post_id"

0
-----------------------------102062144610664
Content-Disposition: form-data; name="_wpnonce"

123456
-----------------------------102062144610664
Content-Disposition: form-data; name="type"


-----------------------------102062144610664
Content-Disposition: form-data; name="tab"


-----------------------------102062144610664
Content-Disposition: form-data; name="short"

1
-----------------------------102062144610664
Content-Disposition: form-data; name="async-upload"; filename="hdfhfg.jpg"
Content-Type: image/jpeg

Normally a post data would simple look like this:
File=image.jpg&somedata=oakdoaksd
or in another script I made at some point:
fileurl=http://imur.com/oksokasd.png&somedata=blabla

But this is not the case here, I am not sure what to do with this sort of data.


Thanks in advance @JLogan3o13

(I coded all of it, learned from this forum and brugbart.dk, made many other web based scripts like these, but never with such HTTP Headers/Post info)

Share this post


Link to post
Share on other sites
trancexx

May I suggest WinHttp.au3 from the examples forum. It's made for this stuff, _WinHttpSimpleFormFill() function in particular.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
On 24/06/2016 at 6:54 PM, trancexx said:

May I suggest WinHttp.au3 from the examples forum. It's made for this stuff, _WinHttpSimpleFormFill() function in particular.

Thanks a lot @trancexx!
Will definitely look in to that first thing Monday morning!

 

Share this post


Link to post
Share on other sites
trancexx

np

It could be like this:

#include "WinHttp.au3"


$sDomain = "http://myurl.com/"
$sLoginPage = "/wp-login.php"
$sUploadPage = "/wp-admin/media-new.php"

$sLoginName = "username"
$sPassword = "mypassword"

; Choose file to upload
$sFileToUpload = FileOpenDialog("Choose something (Image better maybe?)", "", "All (*.*)")
If $sFileToUpload Then
    $hOpen = _WinHttpOpen()
    $hConnect = _WinHttpConnect($hOpen, $sDomain)

    ; Login first
    _WinHttpSimpleFormFill($hConnect, _
            $sLoginPage, _
            "loginform", _
            'user_login', $sLoginName, _
            'user_pass', $sPassword)

    ConsoleWrite('! Error for login = ' & @error & @LF)

    _WinHttpSimpleFormFill($hConnect, _
            $sUploadPage, _
            "file-form", _
            'async-upload', $sFileToUpload)

    ConsoleWrite('! Error for upload = ' & @error & @LF)


    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)
EndIf

 

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
19 hours ago, trancexx said:

np

It could be like this:

#include "WinHttp.au3"


$sDomain = "http://myurl.com/"
$sLoginPage = "/wp-login.php"
$sUploadPage = "/wp-admin/media-new.php"

$sLoginName = "username"
$sPassword = "mypassword"

; Choose file to upload
$sFileToUpload = FileOpenDialog("Choose something (Image better maybe?)", "", "All (*.*)")
If $sFileToUpload Then
    $hOpen = _WinHttpOpen()
    $hConnect = _WinHttpConnect($hOpen, $sDomain)

    ; Login first
    _WinHttpSimpleFormFill($hConnect, _
            $sLoginPage, _
            "loginform", _
            'user_login', $sLoginName, _
            'user_pass', $sPassword)

    ConsoleWrite('! Error for login = ' & @error & @LF)

    _WinHttpSimpleFormFill($hConnect, _
            $sUploadPage, _
            "file-form", _
            'async-upload', $sFileToUpload)

    ConsoleWrite('! Error for upload = ' & @error & @LF)


    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)
EndIf

 

Makes perfectly sense @trancexx
Thank you so much, I will try to finish my script now!

 

EDIT:
 

! Error for login = 4
! Error for upload = 3

I am looking through WinHTTP.au3 now to find out what this error means, but any help is appreciated.

Using simpleformfill is it possible to add costum headers?
I don't really see an example in the help file with costum Headers.

Thanks in advance @trancexx

Edited by RyukShini
error for login & upload

Share this post


Link to post
Share on other sites
trancexx

Of course it's possible, but shouldn't really be needed in case of usual wordpress installation.

 

Check addresses. Maybe there's specific htaccess configuration on the server in place which redirects in case of .php access.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
21 hours ago, trancexx said:

Of course it's possible, but shouldn't really be needed in case of usual wordpress installation.

 

Check addresses. Maybe there's specific htaccess configuration on the server in place which redirects in case of .php access.

Okay, I will be sure to check the redirects and what not.
Thanks a lot! ;)

 

I changed something in the wp-login.php?redirect thingy
but still no luck I get errors
! Error for login = 4
! Error for upload = 3 (This error being understandable since we aren't logged in)

What does 4 error in "Error for login = 4????" stand for?
Thanks in advance @trancexx

Edited by RyukShini

Share this post


Link to post
Share on other sites
trancexx
21 hours ago, RyukShini said:

Okay, I will be sure to check the redirects and what not.
Thanks a lot! ;)

 

I changed something in the wp-login.php?redirect thingy
but still no luck I get errors
! Error for login = 4
! Error for upload = 3 (This error being understandable since we aren't logged in)

What does 4 error in "Error for login = 4????" stand for?
Thanks in advance @trancexx

It means server isn't serving you for some reason. Could you create new user and send me credentials via mail, I would like to see it first hand. I won't touch anything else, no worries.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
3 hours ago, trancexx said:

It means server isn't serving you for some reason. Could you create new user and send me credentials via mail, I would like to see it first hand. I won't touch anything else, no worries.

Sorry I am not able to do so.
It is not my company, but I have another wordpress site I personally own, same principle?
you could try using that if you want.

You have messages disabled?
I can't sent it to you.

e80780a4c9d755054e33b32c941cf25e.png

Edited by RyukShini
Cannot receive messages

Share this post


Link to post
Share on other sites
trancexx

Use email. Mine is at top of the UDF.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
6 minutes ago, trancexx said:

Use email. Mine is at top of the UDF.

Replied, thanks in advance.

Share this post


Link to post
Share on other sites
trancexx
2 hours ago, RyukShini said:

Replied, thanks in advance.

Well, it works for me.
If you check uploads you'll see mine. I used this exact code (with my credentials):

#include "WinHttp.au3"

$sLoginPage = '/wp-login.php'
$sUploadPage = '/wp-admin/media-new.php'


$sDomain = 'theyogapants.club'
$sLogin = 'that_username'
$sPassword = 'that_passwrd'


$sFileToUpload = FileOpenDialog("Choose something (Image better maybe?)", "", "All (*.*)")


$hOpen = _WinHttpOpen()
$hConnect = _WinHttpConnect($hOpen, $sDomain)

; Login first
_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword)

ConsoleWrite('! Error for login = ' & @error & @LF)


$sResponse = _WinHttpSimpleFormFill($hConnect, _
        $sUploadPage, _
        "file-form", _
        'async-upload', $sFileToUpload)

ConsoleWrite('! Error for upload = ' & @error & @LF)


_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
3 hours ago, trancexx said:

Well, it works for me.
If you check uploads you'll see mine. I used this exact code (with my credentials):

#include "WinHttp.au3"

$sLoginPage = '/wp-login.php'
$sUploadPage = '/wp-admin/media-new.php'


$sDomain = 'theyogapants.club'
$sLogin = 'that_username'
$sPassword = 'that_passwrd'


$sFileToUpload = FileOpenDialog("Choose something (Image better maybe?)", "", "All (*.*)")


$hOpen = _WinHttpOpen()
$hConnect = _WinHttpConnect($hOpen, $sDomain)

; Login first
_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword)

ConsoleWrite('! Error for login = ' & @error & @LF)


$sResponse = _WinHttpSimpleFormFill($hConnect, _
        $sUploadPage, _
        "file-form", _
        'async-upload', $sFileToUpload)

ConsoleWrite('! Error for upload = ' & @error & @LF)


_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 

First of all, amazing support, second of all so simple!
will do this first thing in the morning, thanks.

Share this post


Link to post
Share on other sites
RyukShini
17 hours ago, trancexx said:

Well, it works for me.
If you check uploads you'll see mine. I used this exact code (with my credentials):

#include "WinHttp.au3"

$sLoginPage = '/wp-login.php'
$sUploadPage = '/wp-admin/media-new.php'


$sDomain = 'theyogapants.club'
$sLogin = 'that_username'
$sPassword = 'that_passwrd'


$sFileToUpload = FileOpenDialog("Choose something (Image better maybe?)", "", "All (*.*)")


$hOpen = _WinHttpOpen()
$hConnect = _WinHttpConnect($hOpen, $sDomain)

; Login first
_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword)

ConsoleWrite('! Error for login = ' & @error & @LF)


$sResponse = _WinHttpSimpleFormFill($hConnect, _
        $sUploadPage, _
        "file-form", _
        'async-upload', $sFileToUpload)

ConsoleWrite('! Error for upload = ' & @error & @LF)


_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 

Received this:

! Error for login = 1
! Error for upload = 3

:(

 

I checked the HTML/PHP on both pages and they are identical in the upload stage, no idea whats wrong.

Works for Yoga, does not work for other site(will check headers, cookies and everything)
Headers, Cookies are also identical(except for the domain of course)

 

Might be due to an extra layer of security and I may need to use user-agent in my header.
how would you add a costum header in the simpleformfill ?
Thanks in advance

Edited by RyukShini
user-agent

Share this post


Link to post
Share on other sites
trancexx
6 hours ago, RyukShini said:

Might be due to an extra layer of security and I may need to use user-agent in my header.
how would you add a costum header in the simpleformfill ?

If you want another user agent then do this:

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586")

...and it will be added to all requests that use that $hOpen.

Also you can add whatever header with _WinHttpSimpleFormFill:

_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword, _
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586")

You can also add more than one, just use @CRLF to separate each other:

_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword, _
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586" & @CRLF & _
        "Referer: http://google.com" & @CRLF & _
        "DNT: 1")

 

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
18 hours ago, trancexx said:

If you want another user agent then do this:

$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586")

...and it will be added to all requests that use that $hOpen.

Also you can add whatever header with _WinHttpSimpleFormFill:

_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword, _
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586")

You can also add more than one, just use @CRLF to separate each other:

_WinHttpSimpleFormFill($hConnect, _
        $sLoginPage, _
        "loginform", _
        'user_login', $sLogin, _
        'user_pass', $sPassword, _
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586" & @CRLF & _
        "Referer: http://google.com" & @CRLF & _
        "DNT: 1")

 

Amazing I am gonna try.
However I found out it might not be the error afterall.
It may be due to the wordpress installation being in Danish on the other site, but still the IDs, Class, all of the HTML code is still in English of course, so I am not sure if WinHTTP takes that in to consideration?
Will try to fool around with it a bit.

 

<form name="loginform" id="loginform" action="http://url.dk/wp-login.php" method="post">
    <p>
        <label for="user_login">Brugernavn eller e-mail<br />
        <input type="text" name="log" id="user_login" class="input" value="" size="20" /></label>
    </p>
    <p>
        <label for="user_pass">Adgangskode<br />
        <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label>
    </p>
        <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever"  /> Husk mig</label></p>
    <p class="submit">
        <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Log ind" />
        <input type="hidden" name="redirect_to" value="http://url.dk/wp-admin/" />
        <input type="hidden" name="testcookie" value="1" />
    </p>
<form name="loginform" id="loginform" action="http://url.com/wp-login.php" method="post">
    <p>
        <label for="user_login">Username or Email<br />
        <input type="text" name="log" id="user_login" class="input" value="" size="20" /></label>
    </p>
    <p>
        <label for="user_pass">Password<br />
        <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label>
    </p>
        <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever"  /> Remember Me</label></p>
    <p class="submit">
        <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Log In" />
        <input type="hidden" name="redirect_to" value="http://url.com/wp-admin/" />
        <input type="hidden" name="testcookie" value="1" />
    </p>

 

Share this post


Link to post
Share on other sites
trancexx

Language shouldn't make difference.

So you can do it from your browser by navigating to http://url.dk/wp-login.php


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
RyukShini
On 01/07/2016 at 6:48 PM, trancexx said:

Language shouldn't make difference.

So you can do it from your browser by navigating to http://url.dk/wp-login.php

Everything works in the same way.
only difference is the language, I honestly don't understand why this happens.

Share this post


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

  • Similar Content

    • ufukreis1212
      By ufukreis1212
      Hello, I am new members. Help me please. I want vbs convert to au3 .
      This vbs code : 
      'deneme Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") strOSArch = GetObject("winmgmts:root\cimv2:Win32_OperatingSystem=@").OSArchitecture Set objNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set oShell = WScript.CreateObject("WScript.Shell") proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Set oEnv = oShell.Environment("SYSTEM") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colMB = objWMIService.ExecQuery("Select * from Win32_BaseBoard") Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItemsx = objWMIService.ExecQuery( _ "SELECT * FROM Win32_VideoController",,48) '------------------------------------------------------------------- Set obj = GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory") i = 1 For Each obj2 In obj memTmp1 = obj2.capacity / 1024 / 1024 TotalRam = TotalRam + memTmp1 i = i +1 Next '-------------------------------------------------------------------- Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Architecture from Win32_Processor") For Each objItem in colItems if objItem.Architecture = 0 then strArchitecture = "x86" end if if objItem.Architecture = 9 then strArchitecture = "x64" end if next '-------------------------------------------------------------------- strComputer = "." ' Local computer strMemory = "" i = 1 set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") For Each objItem In colItems if strMemory <> "" then strMemory = strMemory & vbcrlf strMemory = strMemory & "Bank" & i & " : " & (objItem.Capacity /1024 /1024) & " Mb" i = i + 1 Next installedModules = i - 1 Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray") For Each objItem in colItems totalSlots = objItem.MemoryDevices Next '---------------------------------------------------------------------- Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" ) Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" ) For Each objItem in colItems strComputerDomain = objItem.Domain Next for each System in SystemSet For Each objItem in colItemsx For Each objProcessor in colProcessors For Each bbType In colMB MbVendor = bbType.Manufacturer MbModel = bbType.Product MsgBox "İşletim Sistemi : " & System.Caption & vbNewLine & _ "İşletim Sistemi Versionu : " & + System.Version & vbNewLine & _ "Windows Mimari Yapısı: " & strOSArch & vbNewLine & _ "Kullanıcı isminiz: " & objNetwork.UserName & vbNewLine & _ "Bilgisayar ismi: " & strComputerName & vbNewLine & _ "Çalışma Grubu: " & strComputerDomain & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Anakart: " & MbVendor & " " & "[" & MbModel & "]" & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Grafik Kartı: " & objItem.Caption & vbNewLine & _ "Driver Version: " & objItem.DriverVersion & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "İşlemci Üreticisi: " & objProcessor.Manufacturer & vbNewLine & _ "İşlemci İsmi: " & objProcessor.Name & vbNewLine & _ "CPU Mimarisi: " & strArchitecture & vbNewLine & _ "İşlemci Çekirdek sayısı: " & oEnv("NUMBER_OF_PROCESSORS") & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Toplam RAM: " & TotalRam & " MB" & vbNewLine & _ "Toplam Slot: " & totalSlots & vbNewLine & _ "Boş Slot: " & (totalSlots - installedModules) & vbNewLine & _ "Ramlerin bulunduğu slotlar:" & vbcrlf & strMemory,0,"deneme" Next Next Next Next please help me , thanks.
    • JuanFelipe
      By JuanFelipe
       
      Hello friends, I have a query, it happens that I have a matrix nxn, the first column of this contains each cell a number with 21 digits, when I pass this matrix to Excel I obviously write that number as 1,10016E + 20, I solved it by adding a * at the end of each cell, but I want it to be written as a text so that I do not have to remove that *, I searched in Google but could not find an effective solution, thanks in advance. 
    • Puls3
      By Puls3
      Hi, This is my first post on the AutoIt Forums, I most of the time was able to get help from this community by merely searching though google and have been able to solve hundreds of problems this way, though in this case I was incapable of finding a solution to my problem. I am quite confident that it is a user error (And my fault) but I haven't been able to determine what I did wrong, any and all help would be greatly appreciated! I have uploaded my whole script pardon passwords to provide as much information as possible.
      I declared a global array at the top of the script and am having issues when I try to set it's value, and I fail to understand why.
      Error Message:
      "D:\Projects\AutoIt\Arena\Base.au3" (270) : ==> Subscript used on non-accessible variable.:
      $ExpMax[$i] = IniRead($TempSavePath, "Combatant" & $i, "ExpMax", $ExpMax[0])
      $ExpMax^ ERROR
      ConsoleWrite Log:
      Ran.
      Checking launch parameters.
      No launch parameters.
      Initiating load.
      Checking for save file.
      Save file not found.
      Load canceled.
      Loading or creating Combatant 1
      Base.au3
    • RamDemon
      By RamDemon
      Hi,
      Did anyone tried to  use Redis  with AutoIT as store DB ?
       Redis <-- more about it
      Mladen
    • nooneclose
      By nooneclose
      Hey. I'm working on a new project and was wondering if there is a better way to "update" my Column E array. 
      Here is my code: 
      Local $nI  = 0                                                            ;Creates a name index of 0: nI = Name index Local $nII = 1                                                            ;Creates a name index of 1 for second loop: nII = Name Index 2 For    $iN = 0 To $IndexRows Step 1                                       ;Checks the roster for any names that appear twice      For $iN2 = 0 To $IndexRows Step 1          if $d_Names[$nI] == $d_Names[$nII] And $d_Names[$nII] <> "" Then              Local $timeSheetName = _ArraySearch($e_Names, $d_Names[$nI], 0, 0, 0, 0, 1)              ;MsgBox($MB_SYSTEMMODAL, "Found it", $d_Names[$nI] & " In column E on Row " & $timeSheetName)              Local $eI  = $timeSheetName + 1              ;ConsoleWrite($timeSheetName & @CRLF)              ;ConsoleWrite($eI & @CRLF)              ;ConsoleWrite(@CRLF)              _Excel_RangeInsert($OpenWorkbook.ActiveSheet, "E" & $eI & ":F" & $eI, $xlShiftDown)                                                                          ;Inserts a empty cell in columns E and F.              _Excel_RangeWrite($OpenWorkbook, $OpenWorkbook.ActiveSheet, $d_Names[$nII], "E" & $eI)                                                                         ;Fills the empty cell in columns E with the doubled name              $aArray_Index = 2                                           ;Array element counter              For $Index = 2 To $IndexRows Step 1                        ;Loops through every row in the Excel file unto no rows are found or a null row is found                  $Array_Value_E = _Excel_RangeRead($OpenWorkbook, Default, "E"&$Index)                  $e_names[$aArray_Index] = $Array_Value_E                ;While the code loops every value in column E is stored in the E array (updating the array)                  $aArray_Index += 1              Next              ExitLoop          EndIf      Next      $nI  += 1      $nII += 1 Next Basically, It checks a roster for people whose name appears twice then inserts a new "row" for that person because they work in two different departments.
      I have to find that name however in Column E if two appear in column D. My code works but I think it is not as efficient as it could be. 
      Any ideas on how to improve the "update" for my array?
      (once it finds the double names in Column D it then searches for that name by going name by name in the Column E array and once it finds it inserts a new row. However, the E array doesn't have that new row stored in it so I have to "update" the array to properly find the next name)
      Any and all tips would be greatly appreciated. 
       
      NOTE: Just assume I'm opening the excel file properly please do not add that code in, it only complicates your answer. 
×