Sign in to follow this  
Followers 0
gsx

Middle Click Context Menu Script

25 posts in this topic

Hello,

I'm a beginner and planning to write the first script, which creates a context menu when the middle mouse button is clicked so that the menu item launches predefined shortcut.

Actually I don't know what to start with. In order to achieve this goal, could anybody direct me good example scripts to look at or commands which possibly be used in the script?

Thank you.

Share this post


Link to post
Share on other sites



So just to clarify, you want to create a context menu on a gui window? or you want to create a context menu that shows up no matter what window/not window you have your mouse over?

Share this post


Link to post
Share on other sites

Hello,

I'm a beginner and planning to write the first script, which creates a context menu when the middle mouse button is clicked so that the menu item launches predefined shortcut.

Actually I don't know what to start with. In order to achieve this goal, could anybody direct me good example scripts to look at or commands which possibly be used in the script?

Thank you.

To start see the function "_ispressed" for detect middle mouse button has been pressed...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

So just to clarify, you want to create a context menu on a gui window?

No.

or you want to create a context menu that shows up no matter what window/not window you have your mouse over?

Mostly yes. Hopefully I'd like to disable the script's middle click menu if a certain window is active such as Firefox or Notepad++. Mainly this script should be used on Windows Explorer.

When the script runs, it reads shortcut files from the predefined folder and store those paths. When a user presses the middle button, the scripts call a context menu which lists up the shortcuts. Then if a user choose one of them, the script run the path.

To start see the function "_ispressed" for detect middle mouse button has been pressed...

Thanks, I'll take a look at it.

Share this post


Link to post
Share on other sites

I got a tiny progress.

post-51211-12834792324064_thumb.jpg

Somehow I succeeded in bringing up a context menu but it's awkward and slow response. ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>


$dll = DllOpen("user32.dll")
Opt('MustDeclareVars', 1)
While 1
    Sleep ( 250 )
    If _IsPressed("04", $dll) Then
        Example1()
    EndIf
WEnd
DllClose($dll)


Func Example1()
    Local $contextmenu
    Local $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Local $pos


    $pos = MouseGetPos()
    GuiCreate("My GUI Context Menu",20,20, $pos[0]-10, $pos[1]-10,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
;   GuiCreate("My GUI Context Menu",50,50, $pos[0]-40, $pos[1]-40, BitOR($WS_POPUP,$WS_BORDER),BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    

    $contextmenu = GUICtrlCreateContextMenu()
    $newsubmenu = GUICtrlCreateMenu("folders", $contextmenu)
    ControlClick ( "My GUI Context Menu", "folders", "", "right")
    $folderitem = GUICtrlCreateMenuItem("folder1", $newsubmenu)
    $folderitem = GUICtrlCreateMenuItem("folder2", $newsubmenu)
    $programitem = GUICtrlCreateMenuItem("Notepad", $contextmenu)
    $programitem = GUICtrlCreateMenuItem("Paint", $contextmenu)
    $fileitem = GUICtrlCreateMenuItem("memos.txt", $contextmenu)
    GUICtrlCreateMenuItem("", $contextmenu)     ; separator
    $otheritem = GUICtrlCreateMenuItem("Network Connections", $contextmenu)


    GUISetState()

    Sleep(1000) 
    MouseUp('Right')
    GUIDelete()
EndFunc

What I need to learn for the next steps:

to assign programs to the menu items.

to hide the gui / to call the menu directly by middle clicks.

Any assistance would be appreciated.

Share this post


Link to post
Share on other sites

I improved the script a little bit.

This time, I could hide the gui by making it almost transparent and covered the screen with it.

But, the script's response is still very slow compared to the regular right click context menu. There should be a way to directly call a menu by pressing the muddle button. This thread discusses _IsPressed is slow. So I'm studying the code used in the thread now.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Global $aTSR

$dll = DllOpen("user32.dll")
Opt('MustDeclareVars', 1)
$aTSR = _GetTotalScreenResolution()
While 1
    Sleep ( 10 )
    If _IsPressed("04", $dll) Then
        Example1()
    EndIf
WEnd
DllClose($dll)


Func Example1()
    Local $GUI, $contextmenu
    Local $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Local $pos 
;   Global $aTSR


;   $pos = MouseGetPos()
    
    $GUI = GuiCreate("GUI Context Menu",$aTSR[0],$aTSR[1], 1, 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)


    $contextmenu = GUICtrlCreateContextMenu()
    $newsubmenu = GUICtrlCreateMenu("folders", $contextmenu)
    ControlClick ( "GUI Context Menu", "folders", "", "right")
    $folderitem = GUICtrlCreateMenuItem("folder1", $newsubmenu)
    $folderitem = GUICtrlCreateMenuItem("folder2", $newsubmenu)
    $programitem = GUICtrlCreateMenuItem("Notepad", $contextmenu)
    $programitem = GUICtrlCreateMenuItem("Paint", $contextmenu)
    $fileitem = GUICtrlCreateMenuItem("memos.txt", $contextmenu)
    GUICtrlCreateMenuItem("", $contextmenu)     ; separator
    $otheritem = GUICtrlCreateMenuItem("Network Connections", $contextmenu)


    GUISetState()

    Sleep(1000) 
    MouseUp('Right')
    GUIDelete()
EndFunc   

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

What I need to learn for the next steps:

to assign programs to the menu items.

to call the menu directly by middle clicks.

to call the menu only on Windows Explorer

Any assistance would be appreciated.

Share this post


Link to post
Share on other sites

The slow response was due to the sleep duration before the line "MouseUp('Right')." It is fixed. Also I figured out how to call a menu only on Windows Explorer with WinActive().

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

Global $aTSR, $WindowGroup 

$dll = DllOpen("user32.dll")
Opt('MustDeclareVars', 1)
$aTSR = _GetTotalScreenResolution()
While 1
    Sleep ( 10 )
    If _IsPressed("04", $dll) AND WinGroupActive() Then
        Example1()
    EndIf
WEnd
DllClose($dll)

Func Example1()
    Local $GUI, $contextmenu
    Local $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
;   Global $aTSR

    $GUI = GuiCreate("GUI Context Menu",$aTSR[0],$aTSR[1], 1, 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)

    $contextmenu = GUICtrlCreateContextMenu()
    $newsubmenu = GUICtrlCreateMenu("folders", $contextmenu)
    ControlClick ( "GUI Context Menu", "folders", "", "right")
    $folderitem = GUICtrlCreateMenuItem("folder1", $newsubmenu)
    $folderitem = GUICtrlCreateMenuItem("folder2", $newsubmenu)
    $programitem = GUICtrlCreateMenuItem("Notepad", $contextmenu)
    $programitem = GUICtrlCreateMenuItem("Paint", $contextmenu)
    $fileitem = GUICtrlCreateMenuItem("memos.txt", $contextmenu)
    GUICtrlCreateMenuItem("", $contextmenu)     ; separator
    $otheritem = GUICtrlCreateMenuItem("Network Connections", $contextmenu)

    GUISetState()
    Sleep(10)   
    MouseUp('Right')
    GUIDelete()
EndFunc   

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

Func WinGroupActive()
    AutoItSetOption("WinTitleMatchMode", 4)
    If WinActive("classname=ExploreWClass") _
        Or WinActive("classname=CabinetWClass") _
        Or WinActive("classname=#32770") _
        Or WinActive("classname=DV2ControlHost") _
        Or WinActive("classname=MMCMainFrame") _
        Or WinActive("classname=Program") Then 
        Return True
    Else
        Return False
    EndIf
EndFunc

At the same time, I got some isuues:

1.The active window flicks when the middle button is pressed. This must be because of the transparent GUI window to call a menu.

2.I cannot call a menu when the mouse cursor on Desktop. WinActive("classname=Program") does not seem to work.

I tried this but it does not work.

AutoItSetOption("WinTitleMatchMode", 4)

While 1
    If WinActive("[CLASS:Program; Title:Program Manager]") Then
        ToolTip("Desktop is active.")
    Else
        ToolTip("")
    EndIf
    Sleep(88)
WEnd

I found a thread possibly related to Desktop detection. The code below is from the thread. I hope somebody can break it down.

Opt("WinTitleMatchMode", 4)
$hWnd = WinGetHandle("classname=Progman")
DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 0x111, "int", 28931, "int", 0)

Regarding calling a context menu directly from the middle button, I found a thread about it. But I cannot see what is illustrated in the code posted in the thread. I just ran it and when I press the left mouse button, nothing happens.

Next steps for me:

to find out the solutions for the issues above.

to assign programs to launch to the menu items.

to call a menu directly by middle clicks.

Any assistance would be appreciated.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It seems I got thorough the most difficult part. ;) It's working very smooth by making a 1x1 pixel gui window in the corner of Desktop and a middle click sends ControlSend() to call the custom context menu.

Also, the reason why the Desktop detection did not work was the spell mistake, CLASS:Program. This had to be CLASS:Progman.

post-51211-12836178252485_thumb.png

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>


$dll = DllOpen("user32.dll")

;Opt('MustDeclareVars', 1)
BuildHiddenGUI()
While 1
    Sleep ( 10 )
    If _IsPressed("04", $dll) AND WinGroupActive() Then CallCustomContextMenu()
    $msg = GUIGetMsg()
    Switch $msg
        Case $folderitem1
            Run("explorer /e, " & '"' & @MyDocumentsDir & '"')
        Case $folderitem2
            Run("explorer /e, " & '"c:\"')
        Case $programitem1
            Run("notepad.exe")
        Case $programitem2
            Run("mspaint.exe")
        Case $otheritem
            Run("RunDll32.exe shell32.dll,Control_RunDLL ncpa.cpl")
    EndSwitch

WEnd
DllClose($dll)

Func BuildHiddenGUI()
    Global $contextmenu, $msg, $GUI, $aTSR
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    $aTSR = _GetTotalScreenResolution() 
    $GUI = GuiCreate("GUI Context Menu",1,1, $aTSR[0], 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)
    GUISetState()
    $contextmenu = GUICtrlCreateContextMenu()
    $newsubmenu = GUICtrlCreateMenu("Folders", $contextmenu)
    $folderitem1 = GUICtrlCreateMenuItem("My Documents", $newsubmenu)
    $folderitem2 = GUICtrlCreateMenuItem("C Drive", $newsubmenu)
    $programitem1 = GUICtrlCreateMenuItem("Notepad", $contextmenu)
    $programitem2 = GUICtrlCreateMenuItem("Paint", $contextmenu)
;   $fileitem = GUICtrlCreateMenuItem("memos.txt", $contextmenu)
    GUICtrlCreateMenuItem("", $contextmenu)     ; separator
    $otheritem = GUICtrlCreateMenuItem("Network Connections", $contextmenu) 
EndFunc

Func CallCustomContextMenu()
    Local $contextmenu, $msg 
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc   

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

Func WinGroupActive()
    AutoItSetOption("WinTitleMatchMode", 4)
    If WinActive("classname=ExploreWClass") _
        Or WinActive("classname=CabinetWClass") _
        Or WinActive("classname=#32770") _
        Or WinActive("classname=DV2ControlHost") _
        Or WinActive("classname=MMCMainFrame") _
        Or WinActive("[CLASS:Progman; Title:Program Manager]") Then 
        Return True
    Else
        Return False
    EndIf
EndFunc

My next steps:

To read shortcut files and store the paths into arrays.

To assign those paths to context menu items.

Edited by gsx

Share this post


Link to post
Share on other sites

I did it! ;)

post-51211-12837987706805_thumb.png

#include <array.au3> ;for _ArrayDisplay()
#Include <File.au3> ;for _FileListToArray()
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1)
Global $ShortcutDir =  @ScriptDir & "\Shortcuts"
Local $dll  = DllOpen("user32.dll")
If Not FileExists($ShortcutDir) AND Not DirCreate($ShortcutDir) Then 
    Msgbox(48, @ScriptName, "There is a problem creating a directory for this program. Program Exits.")
    Exit
ElseIf Not FileCreateShortcut(@ComSpec, $ShortcutDir & '\Command Prompt.lnk') Then
    Msgbox(48, @ScriptName, "There is a problem creating shortcut files for this program. Program Exits.")
    Exit    
EndIf
BuildHiddenGUI( ) 
Local $ChkMDate = FileGetTime($ShortcutDir, 0 ,1)
;_ArrayDisplay($cmItem)
While 1
    Sleep (25)
    If _IsPressed("04", $dll) AND WinGroupActive() Then
        If $ChkMDate <> FileGetTime($ShortcutDir, 0 ,1) Then
            BuildHiddenGUI()
            $ChkMDate = FileGetTime($ShortcutDir, 0 ,1)
        EndIf
        CallCustomContextMenu()
    EndIf
    $msg = GUIGetMsg()
    For $i=1 To $cmItem[0] - 1
        If $msg = $cmItem[$i] Then ShellExecute($cmItemPath[$i])
    Next
WEnd
DllClose($dll)

Func BuildHiddenGUI()
    Global $GUI, $msg   
    Local $contextmenu
    Global $cmItem[1] = [1], $cmItemPath[1] = [1], $csmItem[1] = [1]
    Global $ShortcutDir
    $GUI = GuiCreate("GUI Context Menu",1,1, 1, 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans($GUI,'', 1)
    GUISetState()
    $contextmenu = GUICtrlCreateContextMenu()
    FilesToContextMenu($ShortcutDir, $contextmenu)
EndFunc

Func CallCustomContextMenu()
    Global $GUI
    WinActivate($GUI)
    ControlClick($GUI, "", "", "right", 1, 1, 1)
EndFunc   

Func WinGroupActive()
    AutoItSetOption("WinTitleMatchMode", 4)
    If WinActive("classname=ExploreWClass") _
        Or WinActive("classname=CabinetWClass") _
        Or WinActive("classname=32770") _
        Or WinActive("classname=#32770") _
        Or WinActive("classname=DV2ControlHost") _
        Or WinActive("classname=MMCMainFrame") _
        Or WinActive("[CLASS:Progman; Title:Program Manager]") Then 
        Return True
    Else
        Return False
    EndIf
EndFunc

;adds the given value to the given array and updates the first array element to the index (the current number of the elements)
Func _ArrayAddnuIndex(Byref $arr, $element)
    If Not IsArray($arr) OR Not _ArrayAdd($arr, $element) Then 
        Return False
    Else
        $arr[0] = Ubound($arr)
    EndIf
EndFunc

;returns the folder name from the given path
Func GetFolderName($path)
    Local $PathParts, $FName
    if StringRight($path, 1) = "\" Then $path = StringTrimRight($path, 1)
    $PathParts = _PathSplit($path, "", "", $FName, "")
    Return $PathParts[3]
EndFunc

;assign shortcuts to the context menu items
Func FilesToContextMenu($path, $cmHandle)
    Global $cmItem, $cmItemPath, $csmItem
    Local $csmHandle
    Local $FileList = _FileListToArray($path, "*.lnk", 1)
    If IsArray($FileList) Then
        For $i=1 To $FileList[0]
            _ArrayAddnuIndex($cmItem, GUICtrlCreateMenuItem(GetFolderName($FileList[$i]), $cmHandle)) 
            _ArrayAddnuIndex($cmItemPath, $path & "\" & $FileList[$i])      
        Next
    EndIf
    Local $tmpArr = _FileListToArray($path, "*", 2)
    If Not @error Then
        For $i=1 To $tmpArr[0]  
            $csmHandle = GUICtrlCreateMenu(GetFolderName($tmpArr[$i]), $cmHandle) ;create a sub menu.
            FilesToContextMenu($path & "\" & $tmpArr[$i], $csmHandle)
        Next
    EndIf
EndFunc

Usage: This scripts shows a context menu which lists up shortcut links when the user presses the middle mouse button. The user need to place favorite shortcut files(.lnk) into the directory called "Shortcuts" which the script automatically creates.

It's not bad for a first script isn't it? Still there is a little thing I concern: the memory usage. Task Manager tells it uses about 15mb of Working Set and the complied version is about 9mb. I think it is somewhat large for this tiny script. I wonder if this is normal for an Autoit script.

If anybody find a defect on my code, please let me know. Thanks.

Share this post


Link to post
Share on other sites

I get some errors...

C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_103.au3(29,28) : WARNING: $cmItem: possibly used before declaration.
    For $i=1 To $cmItem[0] -
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_103.au3(30,64) : WARNING: $cmItemPath: possibly used before declaration.
        If $msg = $cmItem[$i] Then ShellExecute($cmItemPath[$i])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_103.au3(81,54) : ERROR: _PathSplit() called with Const or expression on ByRef-param(s).
    $PathParts = _PathSplit($path, "", "", $FName, "")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Program Files\AutoIt3\Include\File.au3(580,85) : REF: definition of _PathSplit().
Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_103.au3 - 1 error(s), 2 warning(s)
!>21:07:32 AU3Check ended.rc:2
+>21:07:32 AutoIt3Wrapper Finished
>Exit code: 0    Time: 0.211

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

I get some errors...

hmm, I can't replicate the situation. I tested on Windows 7 and XP pro. Let's leave it to more advanced folks here who can fix it. ;)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Add

Global $ShortcutDir = @ScriptDir & "\Shortcuts", $msg, $cmItem, $cmItemPath

And Change

Func GetFolderName($path)
    Local $PathParts, $szDrive, $szDir, $szFName, $szExt
    If StringRight($path, 1) = "\" Then $path = StringTrimRight($path, 1)
    $PathParts = _PathSplit ( $path, $szDrive, $szDir, $szFName, $szExt )
    Return $PathParts[3]
EndFunc

but i don't understand why it give me

$path : Command Prompt.lnk

$PathParts[3] : Command Prompt

may be _ArrayAddnuIndex($cmItem, GUICtrlCreateMenuItem(GetFolderName( $path & '\' & $FileList[$i]), $cmHandle))

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Add

Global $ShortcutDir = @ScriptDir & "\Shortcuts", $msg, $cmItem, $cmItemPath

And Change

Func GetFolderName($path)
    Local $PathParts, $szDrive, $szDir, $szFName, $szExt
    If StringRight($path, 1) = "\" Then $path = StringTrimRight($path, 1)
    $PathParts = _PathSplit ( $path, $szDrive, $szDir, $szFName, $szExt )
    Return $PathParts[3]
EndFunc

I'm glad that you found a solution. ;)

I don't have to change those things though. That's weird. Does anybody know why?

but i don't understand why it give me

$path : Command Prompt.lnk

$PathParts[3] : Command Prompt

That's what _PathSplit is supposed to do. Edited by gsx

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

$path : Command Prompt.lnk is not a path it's a fullname.

so it's normal that your function doesn't return a folder name !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

$path : Command Prompt.lnk is not a path it's a fullname.

so it's normal that your function doesn't return a folder name !

Can you just run this?

#Include <File.au3>
$file = "Command Prompt.lnk"
msgbox(0, "", ReturnName($file))
Func ReturnName($path)
    Local $szFName
    $PathParts = _PathSplit($path, "", "", $szFName, "")
    Return $PathParts[3]
EndFunc

Share this post


Link to post
Share on other sites

yes it give me

Test_106.au3(6,56) : ERROR: _PathSplit() called with Const or expression on ByRef-param(s).
    $PathParts = _PathSplit($path, "", "", $szFName, "")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Program Files\AutoIt3\Include\File.au3(580,85) : REF: definition of _PathSplit().
Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_106.au3 - 1 error(s), 0 warning(s)
!>22:00:54 AU3Check ended.rc:2
+>22:00:54 AutoIt3Wrapper Finished
>Exit code: 0    Time: 0.209

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

yes it give me

Test_106.au3(6,56) : ERROR: _PathSplit() called with Const or expression on ByRef-param(s).
    $PathParts = _PathSplit($path, "", "", $szFName, "")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Program Files\AutoIt3\Include\File.au3(580,85) : REF: definition of _PathSplit().
Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_106.au3 - 1 error(s), 0 warning(s)
!>22:00:54 AU3Check ended.rc:2
+>22:00:54 AutoIt3Wrapper Finished
>Exit code: 0    Time: 0.209

I don't get this error. I'm using AutoIt v3.3.6.1. What is your AutoIt version?

Share this post


Link to post
Share on other sites

Current Installation Details

Production Version: 3.3.6.1

Date: April 16th, 2010

The same...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Let's see if anybody else gets or does not get that error. ;) Anybody who can test it, please feedback. :)

@wakillon Also can you just compile the code and see if it runs without errors?

Edited by gsx

Share this post


Link to post
Share on other sites

Let's see if anybody else gets or does not get that error. ;) Anybody who can test it, please feedback. :)

@wakillon Also can you just compile the code and see if it runs without errors?

If i try to compile i get this :

Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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
Sign in to follow this  
Followers 0