Jump to content

Use a variable in the parameters of shellexecute?


careca
 Share

Recommended Posts

Hi, i need to control the value in the parameter of shell execute function, because i want to add an edit box so i can change the value to my liking.

This a script to change the value of the computer volume by a small fraction with the pgup and pgdn hotkeys.

This executes an exe called nircmd, the syntax is "nircmd.exe changesysvolume 250" adds 250 to volume from 0 - 65535

Any solution is welcome :D

GUICreate ("Volume Control", 150, 150, 0, 0)
Local $setvol = 0
Local $volup = 1500
Local $voldn = -1500
GUISetState()

HotKeySet ("{PGUP}", "voluphk")
HotKeySet ("{PGDN}", "voldnhk")

GUICtrlCreateEdit ("", "30", "30", "80", "18")

Func voluphk()
ShellExecute ("nircmd.exe", "changesysvolume $volup", "C:\nircmd")
_WinAPI_Beep(1500, 200)
EndFunc

Func voldnhk()
ShellExecute ("nircmd.exe", "changesysvolume $voldn", "C:\nircmd")
_WinAPI_Beep(1250, 200)
EndFunc

Do
ToolTip("")
Until $setvol = 1
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Changed the code and now the code works, so the question now is how can i set a number i wanti it to increase or decrease in a editbox?

Local $volup = "changesysvolume 1500"
Local $voldn = "changesysvolume -1500"
GUISetState()

HotKeySet ("{PGUP}", "voluphk")
HotKeySet ("{PGDN}", "voldnhk")

GUICtrlCreateEdit ("", "30", "30", "80", "18")

Func voluphk()
ShellExecute ("nircmd.exe", $volup, "C:\nircmd")
_WinAPI_Beep(1500, 200)
EndFunc

Func voldnhk()
ShellExecute ("nircmd.exe", $voldn, "C:\nircmd")
_WinAPI_Beep(1250, 200)
EndFunc
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

$edit = GUICtrlCreateEdit ("", "30", "30", "80", "18")

$result = GuiCtrlRead($edit) the edit box

then Int($result)

although you'll want to add some StringRegExp to make sure that only numbers are entered...

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Thanks man

EDIT: ok, got it

Global $setvol, $editup, $editdn
Local $volup = "changesysvolume 1500"
Local $voldn = "changesysvolume -1500"
HotKeySet ("{PGUP}", "voluphk")
HotKeySet ("{PGDN}", "voldnhk")
$setvol = GUICreate ("Volume Control", 170, 100, 0, 0)

$editup = GUICtrlCreateInput ("changesysvolume 100", 10, 20, 150, 18)
Int ($volup)

$editdn = GUICtrlCreateInput ("changesysvolume -100", 10, 40, 150, 18)
Int ($voldn)

GUISetState()
Func voluphk()
$volup = GUICtrlRead ($editup)
ShellExecute ("nircmd.exe", $volup, "C:\nircmd")
_WinAPI_Beep (1500, 200)
EndFunc

Func voldnhk()
$voldn = GUICtrlRead ($editdn)
ShellExecute ("nircmd.exe", $voldn, "C:\nircmd")
_WinAPI_Beep (1250, 200)
EndFunc

like this when i press the hotkey it reads the value on the editbox and writes it, works fine! :D

Now for that tricky function

StringRegExp from what i could see, is like a filter of some sort,

but its kinda complicated, and i must do more reading,

can you give a heads up?

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

What I usually do when I want to make sure an edit box only displays what I want is, I'll put the check inside my while loop for gui msgs.

here is an example of what I mean

While 1
  $msg = GUIGetMsg();check for messages from the gui
  $newnam = GUICtrlRead($nam);read the input box
  $len = StringLen($newnam);get the length of the text in the input box
  If $len > 13 Then;if the text is more than 13 characters
   GUICtrlSetData($nam, StringLeft($newnam, 13));cut the text to only 13 characters
  EndIf

then the gui msg checks followed by the closing Wend...

*edit for more*

basically, each loop checking for Gui messeges, it reads the input, if it doesn't match the criteria, then fix it.

Because it loops so fast, it's ionstantanious.

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Thanks, i was working with that bit, but i think it doesnt seem to apply to this case, i mean, if i cut down the string, then i wont recognize the parameter.

I was thinking it would be better to just add "changesysvolume " to the left of whatever the editbox string is... say i write on the editbox 1000.

Then use some function to add "changesysvolume" to the left of this, then use it.

Can be possibly simpler and easier on me. hehe :D

What do u say? can i use something like:

GUICtrlSetData ($editup, StringLeft ($volup, changesysvolume))

?

EDIT: Btw, while i was trying your bit, my second editbox disapeared.. :S

================================================================

EDIT: Any way this could work?

Local $vol = "changesysvolume "
HotKeySet ("{PGUP}", "voluphk")
$setvol = GUICreate ("Volume Control", 170, 100, 0, 0)
GUISetState()

$editup = GUICtrlCreateInput ("100", 10, 20, 150, 18)

Func voluphk()
$volup = GUICtrlRead ($vol + $editup)
ShellExecute ("nircmd.exe", $volup, "C:\nircmd")

Adding previously set

$vol = "changesysvolume "

with the editbox

$editup

($vol + $editup)

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Ok finally did it! Goes like this:

#requireadmin
#Include <WinAPI.au3>
#include <GuiButton.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>
Opt ("TrayIconDebug", 1)
Opt ("TrayAutoPause", 0)
Opt ("TrayOnEventMode", 1)
Opt ("WinWaitDelay", 100)
Opt ("ExpandEnvStrings", 1)
Opt ("MouseCoordMode", 2)
Opt ("WinDetectHiddenText", 1)
Opt ('MustDeclareVars', 1)
Opt ('GUIEventOptions', 0)

TraySetIcon ("volume.ico")

Global $setvol, $editup, $editdn, $vol, $sysvolup, $sysvoldn, $volup, $voldn
HotKeySet ("{PGUP}", "voluphk")
HotKeySet ("{PGDN}", "voldnhk")
$vol = "changesysvolume "
$setvol = GUICreate ("Volume Control", 180, 75, 0, 0)
GUISetState()

GUICtrlCreateLabel ("Volume Up Value", 15, 20, 110, 18)
$editup = GUICtrlCreateInput ("150", 115, 20, 40, 18)
GUICtrlCreateLabel ("Volume Dn Value", 15, 40, 110, 18)
$editdn = GUICtrlCreateInput ("-150", 115, 40, 40, 18)

Func voluphk()
$volup = GUICtrlRead ($editup)
$sysvolup = ($vol & $volup)
ShellExecute ("nircmd.exe", $sysvolup, "C:\nircmd")
_WinAPI_Beep (1500, 200)
EndFunc

Func voldnhk()
$voldn = GUICtrlRead ($editdn)
$sysvoldn = ($vol & $voldn)
ShellExecute ("nircmd.exe", $sysvoldn, "C:\nircmd")
_WinAPI_Beep (1250, 200)
EndFunc

Do
ToolTip ("")
Until $setvol = 1

It works like this, set a string to a variable

$vol = "changesysvolume "

Create an editbox

$editup = GUICtrlCreateInput ("150", 115, 20, 40, 18)

have an hotkey executing a function, and in the function,

read editbox

$volup = GUICtrlRead ($editup)

then add the "stringed" variable with the value you have in the editbox

$sysvolup = ($vol & $volup)

and execute the exe with the parameter and the value added.

ShellExecute ("nircmd.exe", $sysvolup, "C:\nircmd")

Awesome!

Thanks for the help guys!

Keep it up.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

×
×
  • Create New...