Jump to content

Get Full Path (win32all)? And Possible Bugs In While And Enum


Recommended Posts

1) Does anyone know how to get the full path of a process instead of just a process name? I think something like GetModuleFileNameEx in win32api but I have no idea how to use it :o

I'm trying to make something for Win32 All, and with no supporting dlls (except pskill.dll for windows nt of course), so WMI is out of the question :mellow:

I could do it by reading prcview's output, but I want to learn some win32api manipulation by beginning from small stuff:P (Or if AutoIt has something that can be used for this)

2) Also, I was playing with While and I think I found a bug with $list[$a][0]:

$a = 1
$list = ProcessList()
$makemsg = "Total:" & $list[0][0]
While $list[$a][0]
    While $countbox < 11 And Number($list[0][0] - $a) > 11
        $makemsg = $makemsg & @CR & $a & ". " & $list[$a][1] & "=" & $list[$a][0]
        $countbox = $countbox + 1
        $a = $a + 1
    WEnd
    While Number($list[0][0] - $a) <= 11 And $list[$a][0]
        $makemsg = $makemsg & @CR & $a & ". " & $list[$a][1] & "=" & $list[$a][0]
        $a = $a + 1
    WEnd
    MsgBox("", "Process", $makemsg, 5)
    $countbox = 1
    $makemsg = ""
WEnd

...\enumproc.au3 (11) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
While Number($list[0][0] - $a) <= 11 And $list[$a][0] 
While Number($list[0][0] - $a) <= 11 And ^ ERROR

I had to use While $a <= $list[0][0]:

$a = 1
$list = ProcessList()
$makemsg = "Total:" & $list[0][0]
While $a <= $list[0][0]
    While $countbox < 11 And Number($list[0][0] - $a) > 11
        $makemsg = $makemsg & @CR & $a & ". " & $list[$a][1] & "=" & $list[$a][0]
        $countbox = $countbox + 1
        $a = $a + 1
    WEnd
    While Number($list[0][0] - $a) <= 11 And $a <= $list[0][0]
        $makemsg = $makemsg & @CR & $a & ". " & $list[$a][1] & "=" & $list[$a][0]
        $a = $a + 1
    WEnd
    MsgBox("", "Process", $makemsg, 5)
    $countbox = 1
    $makemsg = ""
WEnd

3) The enum example doesn't work:

D:\programs\AutoIt3\beta\Examples\Helpfile\Enum.au3 (1) : ==> Unknown function name.: 
Enum $E2VAR1 = 10, $E2VAR2, $E2VAR3 = 15 
^ ERROR
->AutoIT3.exe ended.rc:1

I'm using the current beta. An example would be more than welcome :)

Thanks for your replies :)

Link to comment
Share on other sites

  • Moderators

#1... I did this the other day: http://www.autoitscript.com/forum/index.ph...ndpost&p=165980

#3... probably have to declare Enum with Global or Dim I would imagine?

Edit:

For #3

Global Enum $E1VAR1, $E1VAR2, $E1VAR3

MsgBox(4096, "", "Expect 0: " & $E1VAR1)

MsgBox(4096, "", "Expect 1: " & $E1VAR2)

MsgBox(4096, "", "Expect 2: " & $E1VAR3)

Global Enum $E2VAR1 = 10, $E2VAR2, $E2VAR3 = 15

MsgBox(4096, "", "Expect 10: " & $E2VAR1)

MsgBox(4096, "", "Expect 11: " & $E2VAR2)

MsgBox(4096, "", "Expect 15: " & $E2VAR3)

Global Enum Step *2 $E3VAR1, $E3VAR2, $E3VAR3

MsgBox(4096, "", "Expect 1: " & $E3VAR1)

MsgBox(4096, "", "Expect 2: " & $E3VAR2)

MsgBox(4096, "", "Expect 4: " & $E3VAR3)

This works with Beta (Alt+F5) Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

That screen shot says your using 3.1.1.0, the latest beta is 3.1.117

Edit:

Might want to update your SciTe Definitions too: http://www.autoitscript.com/forum/index.ph...ndpost&p=160434

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

That screen shot says your using 3.1.1.0, the latest beta is 3.1.117

Edit:

Might want to update your SciTe Definitions too: http://www.autoitscript.com/forum/index.ph...ndpost&p=160434

Great! the problem was the definitions, forgot to update :)

I cleared #2 a bit, no double whiles:

Dim $list = ProcessList(),$a = 1,$countbox = 1,$makemsg = "Total:" & $list[0][0]
While $a <= $list[0][0]
    $makemsg = $makemsg & @CR & $a & ". " & $list[$a][1] & "=" & $list[$a][0]
    If $countbox = 11 Then
        MsgBox( "", "Process", $makemsg, 5)
        $makemsg = ""
        $countbox = 0
    ElseIf $countbox > 11 And $a > Number($list[0][0] - 11) Then
        MsgBox( "", "Process", $makemsg, 5)
        $makemsg = ""
        $countbox = 0
    ElseIf $countbox < 11 And $a > Number($list[0][0] - 11) Then
        If $a = $list[0][0] Then
            MsgBox( "", "Process", $makemsg, 5)
            $makemsg = ""
            $countbox = 0
        EndIf
    EndIf
    $countbox = $countbox + 1
    $a += 1
WEnd

But it still produces an error at the end with While $list[$a][0] (instead of While $a <= $list[0][0])

I mean, the script finishes ok, then after the last msgbox it produces an error.

Not that it makes any problems using the above code, but I'm wondering why it doesn't work. Here's the output:

>"D:\programs\AutoIt3\SciTE\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "D:\project\autoit\enum proc.au3" /autoit3dir "D:\programs\AutoIt3\beta" /UserParams 
>Running AU3Check (1.54.1.1)  params:  from:D:\programs\AutoIt3\beta
+>AU3Check ended.rc:0
>Running:(3.1.1.117):D:\programs\AutoIt3\beta\autoit3.exe "D:\project\autoit\enum proc.au3" 
D:\project\autoit\enum proc.au3 (2) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
While $list[$a][0] 
While ^ ERROR
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 4.835
Edited by forger
Link to comment
Share on other sites

  • Moderators

I get no errors doing it this way (or the other way to be honest):

Dim $list = ProcessList(), $countbox = 1, $makemsg = "Total:"
For $a = 1 To $list[0][0]
    $makemsg = $makemsg & @CR & $a & ". " & $list[$a][1] & "=" & $list[$a][0]
    If $countbox = 11 Then
        MsgBox( "", "Process", $makemsg, 5)
        $makemsg = ""
        $countbox = 0
    ElseIf $countbox > 11 And $a > (UBound($list) - 1) - 11 Then
        MsgBox( "", "Process", $makemsg, 5)
        $makemsg = ""
        $countbox = 0
    ElseIf $countbox < 11 And $a > (UBound($list) - 1) - 11 Then
        If $a = $list[0][0] Then
            MsgBox( "", "Process", $makemsg, 5)
            $makemsg = ""
            $countbox = 0
        EndIf
    EndIf
    $countbox = $countbox + 1
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

hm ok, I was just curious why "While $list[$a][0]" instead of "While $a <= $list[0][0]" produces an error when done :)

Anyway, doesn't matter, thanks for your help so far:)

Edited by forger
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...