Jump to content

Run($...) and Send("#r") Difference & problem


Recommended Posts

Hello I have a problem and I have tried to find the awnser many times but I failed :)

What is the difference between:

Run($SroToolRun)

And

Send("#r")
($SroToolRun)
Send("{ENTER}")

Because if I use the 1st method the script doesn't work, and if I use the 2nd method the script works.

Here is what happens manual and with the 2nd method if you want to install:

Posted Image

YES!

Posted Image

Here is what happens manual and with the 2nd method if you want to uninstall:

Posted Image

NO!

Posted Image

YES!

Posted Image

Here is what happens with the 1st method if you want to install:

Posted Image

YES!

Posted Image

Here is what happens with the 1st method if you want to uninstall:

Posted Image

NO!

Posted Image

YES!

Posted Image

And I want to use the 1st method ofcourse because it better(faster) and it looks more professional.

Can someone please help me because I am desperate of not find the awnser ;)

Source code:

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

GuiCreate("SroTool", 400, 850, 10, 10)
GuiSetState(@SW_SHOW)
    
$hookButton = GuiCtrlCreateButton("Hook ...",10,35,120,50)
$unhookButton = GuiCtrlCreateButton("Unhook ...",130,35,120,50)
$nuconnectorButton = GuiCtrlCreateButton("Start nuconnector",10,180,120,50)
$startag...Button = GuiCtrlCreateButton("Start ...",10,335,120,50)
$updateButton = GuiCtrlCreateButton("Update ...",10,700,120,50)
$selecthookButton = GuiCtrlCreateButton("Select hook.exe",250,35,120,50)
$selectnuconnectorButton = GuiCtrlCreateButton("Select nuconnector.exe",250,180,120,50)
$selectag...Button = GuiCtrlCreateButton("Select ag.exe",250,335,120,50)
$exitButton = GuiCtrlCreateButton("Exit",10,500,120,50)

$label1 = GuiCtrlCreateLabel("1:",10,15,113,15)
$label2 = GuiCtrlCreateLabel("2:",10,160,113,15)
$label3 = GuiCtrlCreateLabel("3:",10,310,113,15)
$label4 = GuiCtrlCreateLabel("Pad naar hook.exe:",145,90,160,15)
$label5 = GuiCtrlCreateLabel("Pad naar nuconnector.exe:",145,235,160,15)
$label5 = GuiCtrlCreateLabel("Pad naar ag.exe:",145,390,160,15)
$label6 = GuiCtrlCreateLabel("This tool is made by Jeanpierre and Engin",32,570,300,15)

$padhook = GuiCtrlCreateInput("No path selected",10,110,375,20)
$padhook2 = IniRead(@AppDataDir & "\SroTool.ini", "Filepaths", "Hook.exe", "NotFound")
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetData($padhook, $padhook2)
    
$padnuconnector = GuiCtrlCreateInput("No path selected",10,255,375,20)
GUICtrlSetState(-1, $GUI_DISABLE)
$padnuconnector2 = IniRead(@AppDataDir & "\SroTool.ini", "Filepaths", "nuConnector.exe", "NotFound")
GUICtrlSetData($padnuconnector, $padnuconnector2)
    
$padag... = GuiCtrlCreateInput("No path selected",10,410,375,20)
GUICtrlSetState(-1, $GUI_DISABLE)
$padag...2 = IniRead(@AppDataDir & "\SroTool.ini", "Filepaths", "ag.exe", "NotFound")
GUICtrlSetData($padag..., $padag...2)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $hookButton
            hookButton()
        Case $msg = $unhookButton 
            unhookButton()
        Case $msg = $nuconnectorButton 
            nuconnectorButton()
        Case $msg = $startag...Button 
            startag...Button()
        Case $msg = $updateButton 
            updateButton()
        Case $msg = $selecthookButton 
            selecthookButton()
        Case $msg = $selectnuconnectorButton 
            selectnuconnectorButton()
        Case $msg = $selectag...Button 
            selectag...Button()
        Case $msg = $exitButton 
            exitButton()
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
Wend
    
Func selecthookButton()
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $bericht = "Select the hook.exe file"
    $pad = FileOpenDialog($bericht, @WindowsDir & "\", "Hook (*.exe;)", 1 + 4 )
    IniWrite($SroToolPath, "Filepaths", "hook.exe", $pad)
    GUICtrlSetData($padhook, $pad)
EndFunc

Func hookButton()
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $SroToolRun = IniRead($SroToolPath, "Filepaths", "hook.exe", "NotFound")
    Run($SroToolRun)
    ;Send("#r")
    ;Send($SroToolRun)
    ;Send("{ENTER}")
    WinWaitActive("Confirm detour install")
    Send("{RIGHT 1}")
    Sleep(50)
    Send("{ENTER}")
    ;Sleep(50)
    ;Send("{ENTER}")
EndFunc

Func unhookButton()
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $SroToolRun = IniRead($SroToolPath, "Filepaths", "Hook.exe", "NotFound")
    ;Send("#r")
    ;Send($SroToolRun)
    ;Send("{ENTER}")
    Run($SroToolRun)
    WinWaitActive("Confirm detour install")
    Send("{LEFT}")
    Sleep(50)
    Send("{ENTER}")
    Sleep(50)
    Send("{LEFT 2}")
    Sleep(100)
    Send("{ENTER}")
    ;Sleep(50)
    ;Send("{ENTER}")
EndFunc
    
Func selectnuconnectorButton()
    $bericht = "Select the nuConnector.exe file"
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $pad = FileOpenDialog($bericht, @WindowsDir & "\", "nuConnector (*.exe;)", 1 + 4 )
    IniWrite($SroToolPath, "Filepaths", "nuConnector.exe", $pad)
    GUICtrlSetData($padnuconnector, $pad)
EndFunc
    
Func nuconnectorButton()
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $SroToolRun = IniRead($SroToolPath, "Filepaths", "nuConnector.exe", "NotFound")
    Run($SroToolRun)    
EndFunc
    
Func selectagbotButton()
    $bericht = "Select the ag.exe file"
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $pad = FileOpenDialog($bericht, @WindowsDir & "\", "ag (*.exe;)", 1 + 4 )
    IniWrite($SroToolPath, "Filepaths", "ag.exe", $pad)
    GUICtrlSetData($padag..., $pad)
EndFunc

Func startag...Button()
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $SroToolRun = IniRead($SroToolPath, "Filepaths", "ag.exe", "NotFound")
    Run($SroToolRun)
    Run("ag.exe")
EndFunc

Func updateButton()
    Send("#r")
    WinWaitActive("Uitvoeren")
    Send("http://www.ag....net/f/Package3.2.12.nomap.zip")
    Sleep(50)
    Send("{ENTER}")
EndFunc

Func exitButton()
    ProcessClose("SroTool.exe")
EndFunc

Sorry I have replace some words for: "..." please dont ask why.

If you need my system information just ask.

I am running on a 64-bit windows 7

:( Happy Easter everyone :)

Maby I dont awnser in a day because of Easter

Thanks in advance,

Jeanpierre

Link to comment
Share on other sites

You need to set the "working directory" in Run() :)

Sorry I dont understand that :(

you must put the filepath + the filename + extension in Run() right? like I did?

there isn't a smiley if you dont understand something :)

Can you please give a example in my case if it isn't to mush work?

Jeanpierre

EDIT:

Run ( "program" [, "workingdir" [, show_flag[, opt_flag ]]] )

Program = "$SroToolRun"

Workingdir = "$SroToolRun - Filename + extension"

But how Must I know the workingdir? I just want that the script execute the program

Edited by Jeanpierre92
Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

A:

- 1) is valid autoit code.

- 2) is invalid autoit code.

B:

- 1) will start a new process/program.

- 2) will send some key actions to the current active window of a already running/existing process.

Yes I understand that, but the strange is that If I select the Hook.exe and the script Run(Hook.exe) it works.

But if I quit the script and open it again all the file path's are exactly the same. And then it gives the error :(

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I have put the debug part(I dont know what it is and what it does) And I execute it and the script just execute.

I saw that there must be some kind of file created but it didn't: @ScriptDir & '\DebugOut.log')

What does debug do? and can it resolve my problem?

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Whoohoo finaly it works :)

This is what I did:

Func unhookButton()  ;Klaar en werkt
    $SroToolPath = @AppDataDir & "\SroTool.ini"
    $SroToolRun = IniRead($SroToolPath, "Filepaths", "Hook.exe", "NotFound")
    $SroToolRun = StringReplace($SroToolRun, "Hook.exe", "")
    Run($SroToolRun & "\Hook.exe", $SroToolRun)
    WinWaitActive("Confirm detour install")
    Send("{LEFT}")
    Sleep(10)
    Send("{ENTER}")
    WinWaitActive("Confirm detour uninstall")
    Send("{LEFT 2}")
    Sleep(10)
    Send("{ENTER}")
    Sleep(10)
    Send("{ENTER}")
EndFunc

Thanks for all the support :(

Edited by Jeanpierre92
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...