Defining variable and printing it out
Hey guys!
I just found AHK, and I love it!
I'm currently writing a script, which allows me to select some different options from a dropdown, and then it will automatically enter the value from that dropdown in a specific field:
Now my problem is, that when I example choose "SPIRIT" - for some reason it enters these numbers:
"643232442221" and NOT the numbers it is supposed to: "6432324422"
It's like it's adding extra numbers to the field. Why is that???
#T::
Gui, Add, Text, x26 y177 w420 h30 , Vælg Handling Agent
Gui, Add, DropDownList, x26 y217 w420 h20 vCfs, WFS|Spirit
Gui, Show, x131 y91 h381 w481, New GUI Window
Submit:
Gui, Submit
varCfs = %cfs%
varConsol = %consol%
varMawb = %mawb%
if(varCfs = "WFS"){
varCfs = 6402111562
} else if (varCfs = "SPIRIT"){
varCfs = 6432324422
}
Gui, Hide
;After submit. If the console # is already opened in EDIe, make that window active
;if not, let's generate an error, saying that the user must lookup the console.
IfWinExist, Edit Consol %consol%
{
WinActivate ; use the window found above
;Arrival Info
Click 697,76
Click 651,109
Send {Ctrl Down}a{Ctrl Up}
Sleep 200
Send {Delete}
Sleep 350
Send %varCfs%
+F11::Send, %mawb% ;Shift+F11
} else {
WinActivate, ediEnterprise
MsgBox, 4, Find Consol #, Error!
Gui, Destroy
Gui, show
Return ;Then stop!
}
Return
GuiClose:
ExitApp
I can't reproduce environment to test your code. But I made some corrections that maybe can help you. Try this code:
#T::
Gui, Add, Text, x26 y177 w420 h30 , Vælg Handling Agent
Gui, Add, DropDownList, x26 y217 w420 h20 vCfs, WFS|Spirit
Gui, Show, x131 y91 h381 w481, New GUI Window
Submit:
Gui, Submit
varCfs := cfs
varConsol := consol
varMawb := mawb
if(varCfs = "WFS"){
varCfs := 6402111562
} else if (varCfs = "SPIRIT"){
varCfs := 6432324422
}
Gui, Hide
;After submit. If the console # is already opened in EDIe, make that window active
;if not, let's generate an error, saying that the user must lookup the console.
IfWinExist, Edit Consol %consol%
{
WinActivate ; use the window found above
;Arrival Info
Click 697,76
Click 651,109
Send {Ctrl Down}a{Ctrl Up}
Sleep 200
Send {Delete}
Sleep 350
Send %varCfs%
} else {
WinActivate, ediEnterprise
MsgBox, 4, Find Consol #, Error!
Gui, Destroy
Gui, show
Return ;Then stop!
}
Return
+F11::Send, %mawb% ;Shift+F11
GuiClose:
ExitApp
Related
I want to activate the button called EditBUtton2, but I'm finding it difficult. I've only been able to successfully identify it in a loop, just not activate it.
^+f7::
WinGet, OutputVar, ID
MsgBox, "%OutputVar%"
WinGet, ActiveControlList, ControlList, A
Loop, Parse, ActiveControlList, `n
{
if(A_LoopField = "EditButton2")
MsgBox, "found button successfully."
; I want to activate this button, but this doesn't work:
Send, {Space}
;controlsend,, {Space}, %A_Loopfield%
}
return
I mean detect it without pressing a hotkey that will call the lines of code that will check it if said window is active
Below example works fine but pressing 4 is required.
4::
if WinActive("*Untitled - Notepad ahk_exe notepad.exe")
{
MsgBox, Found Notepad
}
else
{
MsgBox, Did Not Find Notepad
}
Return
I have also tried this, but it just spams me with MsgBoxes.
Loop, 50
{
if WinActive("ahk_class #32770")
{
MsgBox, Found Notepad
}
else
{
MsgBox, Did Not Find Notepad
}
}
Thanks.
I'm trying to create an AHK script where the right mouse click is intercepted, similar to a $ call would work with a keyboard press. This is the code I've tried but the right click still is sent to the program.
$capslock::
send {u down}
var = 0
return
$capslock up::
send {u up}
var = 1
return
$rbutton::
if(var) {
;
} else
sendinput, {s}
return
Any help would be appreciated!
Update 05.08.16 - 12:08 AM:
Here is a video of me trying to get this to work: https://youtu.be/h9gAirlUGyI
So, I'm trying to have a key pressed once on program launch.
This is what I have:
{
Send, {F11}
}
Now when I launch the program it doesn't send the key.
Help?
flag = 0
processName := "xenia.exe"
Loop
{
If ProcessExist(processName)
{
WinGetTitle, title, ahk_exe %processName%
IfWinActive, %title%
{
if flag = 0
{
Send, {F11}
flag = 1
}
}
else
{
flag = 0
}
}
Sleep, 1000
}
ProcessExist(Name)
{
Process,Exist,%Name%
return Errorlevel
}
Per your other question and my comment there:
; This code both launches and fullscreens XENIA . . .
#Persistent
#SingleInstance, Force
Run, xenia.exe
Sleep, 500
GoSub, DoIt
return
numpad0::
GoSub, DoIt
return
DoIt:
IfWinExist, ahk_class XeniaWindowClass ahk_exe xenia.exe
{
WinActivate, ahk_class XeniaWindowClass
#IfWinActive, ahk_class XeniaWindowClass
{
Send, {F11}
}
}
return
Now, if the question is REALLY about launching xenia with a file you've clicked on, e.g., using an explorer extension, there are ways of making it work (by adding the script to the registry and/or passing the file name and path into the command line. Again, please give us details as to what you want to happen!
Really struggling with this.
I need to simply open a windows explorer window at a specified domain, wait until it is active then proceed. This is what I have so far:
#::
{
WinGet, old_active, ID, A
Run, explore C:\Users\Nathan\Documents\Test FDA
loop{
WinGet, new_active, ID, A
if(ahk_id %new_active% != ahk_id %old_active%)
{
WinMaximize, A
break
}
}
return
}
EDIT SOLVED ?>>>
DIDNT KNOW WINDOW SPY EXISTED CAME WITH IT :(((
Long time wasted, this simply works.
[::
{
Run explore C:\Users\Nathan\Documents\Test FDA
WinWaitActive Test FDA
WinMaximize A
return
}
how about this?:
"
F12::
WINDOWEXPLORER:
WinWaitActive, Windows Explorer,, 0.01
if ErrorLevel
{
Goto WINDOWEXPLORER
}
else
{
; SoundBeep 4500, 30
Return
}
"
I think you are looking for the WinWaitActive function. From the documentation:
Waits until the specified window is active
Put it after the line with Run...:
WinWaitActive, WinTitle
You will need to replace WinTitle with the title of the window that comes up after the Run command. There are other options available, such as duration to wait, titles to exclude, etc.
See the documentation for more details.